Просмотр исходного кода

notice bar in play game center

hanjing лет назад: 6
Родитель
Сommit
41122cce94

+ 4 - 0
app/src/main/java/com/sheep/gamegroup/model/api/ApiService.java

@@ -1886,4 +1886,8 @@ public interface ApiService {
 
     @GET("app/find/app_special")
     Observable<BaseMessage> getAppSpecial();
+
+    @GET("app/url/{name}")
+    Observable<BaseMessage> getNameUrl(@Path("name") String name);
+
 }

+ 41 - 0
app/src/main/java/com/sheep/gamegroup/module/game/util/FocusGameHelper.java

@@ -1,9 +1,12 @@
 package com.sheep.gamegroup.module.game.util;
 
+import android.text.TextUtils;
+import android.util.Log;
 import android.view.View;
 import android.widget.ImageView;
 import android.widget.TextView;
 
+import com.alibaba.fastjson.JSONObject;
 import com.bumptech.glide.Glide;
 import com.sheep.gamegroup.model.entity.Applications;
 import com.sheep.gamegroup.model.entity.BaseMessage;
@@ -19,6 +22,7 @@ import com.youth.banner.loader.ImageLoader;
 
 import org.afinal.simplecache.ApiKey;
 
+
 import butterknife.BindView;
 import butterknife.ButterKnife;
 import butterknife.OnClick;
@@ -43,6 +47,8 @@ public class FocusGameHelper {
     public TextView tagView3;
     @BindView(R.id.item_focus_size_tv)
     public TextView sizeView;
+    @BindView(R.id.notice_bar)
+    public ImageView noticeBar;
 
     public FocusGameHelper(View rootView) {
         this.rootView = rootView;
@@ -55,6 +61,41 @@ public class FocusGameHelper {
     }
 
     public void refresh() {
+        SheepApp.getInstance().getNetComponent().getApiService().getNameUrl("game_center_banner")
+                .subscribeOn(Schedulers.io())
+                .observeOn(AndroidSchedulers.mainThread())
+                .subscribe(new SheepSubscriber<BaseMessage>(SheepApp.getInstance()) {
+                    @Override
+                    public void onError(BaseMessage baseMessage) {
+                        noticeBar.setVisibility(View.GONE);
+                    }
+
+                    @Override
+                    public void onNext(BaseMessage baseMessage) {
+                        Log.e("-----------", baseMessage.getData().toString());
+                        JSONObject mainjson = JSONObject.parseObject(baseMessage.getData().toString());
+                        if (mainjson.containsKey("game_center_banner")) {
+                            JSONObject json = mainjson.getJSONObject("game_center_banner");
+                            if (json.containsKey("status")) {
+                                int status = json.getInteger("status");
+                                if (status == 1) {
+                                    noticeBar.setVisibility(View.VISIBLE);
+                                    Glide.with(rootView.getContext()).load(json.getString("img_url")).into(noticeBar);
+                                    if (json.containsKey("jump_url") && !TextUtils.isEmpty(json.getString("jump_url"))) {
+                                        noticeBar.setOnClickListener(v -> {
+                                            Jump2View.getInstance().goWeb(rootView.getContext(), json.getString("jump_url"));
+                                        });
+                                    } else {
+                                        noticeBar.setOnClickListener(null);
+                                    }
+                                    return;
+                                }
+                            }
+                        }
+                        noticeBar.setVisibility(View.GONE);
+                    }
+                });
+
         SheepApp.getInstance().getNetComponent().getApiService().getDailyFocusApp()
                 .subscribeOn(Schedulers.io())
                 .observeOn(AndroidSchedulers.mainThread())

+ 6 - 3
app/src/main/res/layout/item_game_focus.xml

@@ -5,10 +5,13 @@
     xmlns:app="http://schemas.android.com/apk/res-auto"
     android:orientation="vertical">
 
-    <View
+    <ImageView
+        android:id="@+id/notice_bar"
+        android:visibility="gone"
+        android:adjustViewBounds="true"
         android:layout_width="match_parent"
-        android:layout_height="10dp"
-        android:background="@color/bg_home_color" />
+        android:layout_height="wrap_content" />
+
     <TextView
         android:id="@+id/hp_focus_tv1"
         android:layout_width="wrap_content"