ソースを参照

添加微信挂机功能状态:为true时,可以使用该功能,为false时提示该功能正在建设中

zengjiebin 8 年 前
コミット
117681a5a4
共有2 個のファイルを変更した40 個の追加6 個の削除を含む
  1. 35 2
      app/src/main/java/com/kfzs/duanduan/fragment/FgtSmallSheep.java
  2. 5 4
      app/src/main/java/com/sheep/gamegroup/model/api/ApiService.java

+ 35 - 2
app/src/main/java/com/kfzs/duanduan/fragment/FgtSmallSheep.java

@@ -206,8 +206,35 @@ public class FgtSmallSheep extends BaseCompatFragment implements SmallSheepContr
         if(views.size() < 1 ){
             pagePresenter.getAwardDetail();
         }
+        initWechatIsOpen();
 
     }
+    private Boolean wechatIsOpen = null;
+    /**
+     * 获取微信挂机是否开启状态
+     */
+    private void initWechatIsOpen() {
+        SheepApp.getInstance().getNetComponent().getApiService().getWebchatIsOpen()
+                        .subscribeOn(Schedulers.io())
+                        .observeOn(AndroidSchedulers.mainThread())
+                        .subscribe(new SheepSubscriber<BaseMessage>(getContext()) {
+                            @Override
+                            public void onNext(BaseMessage baseMessage) {
+                                if(BuildConfig.DEBUG)
+                                    System.out.println("baseMessage onNext "+JSON.toJSONString(baseMessage));
+                                if(baseMessage.getData() instanceof Boolean)
+                                    wechatIsOpen = (Boolean) baseMessage.getData();
+                                else
+                                    wechatIsOpen = false;
+                            }
+
+                            @Override
+                            public void onError(BaseMessage baseMessage) {
+                                if(BuildConfig.DEBUG)
+                                    System.out.println("baseMessage onError "+JSON.toJSONString(baseMessage));
+                            }
+                        });
+    }
 
     @OnClick({R.id.icon_img_iv, R.id.user_layout, R.id.withdrawal, R.id.couple_red_packets_iv, R.id.try_play_layout, R.id.invitation_layout, R.id.lying_layout, R.id.newbie_task})
     public void onViewClicked(View view) {
@@ -232,8 +259,14 @@ public class FgtSmallSheep extends BaseCompatFragment implements SmallSheepContr
                 UMConfigUtils.onEvent(UMConfigUtils.Event.SHEEP_TASK_INVITE);
                 break;
             case R.id.lying_layout://躺着赚钱
-                Jump2View.getInstance().goLyingView(activity, null);
-                UMConfigUtils.onEvent(UMConfigUtils.Event.SHEEP_TASK_LIE);
+                if(wechatIsOpen == null) {
+                    G.showToast("网络异常,请稍候重试");
+                } else if(wechatIsOpen) {
+                    Jump2View.getInstance().goLyingView(activity, null);
+                    UMConfigUtils.onEvent(UMConfigUtils.Event.SHEEP_TASK_LIE);
+                } else {
+                    G.showToast("该功能正在建设中");
+                }
                 break;
             case R.id.newbie_task://新手任务
                 if(userEntity == null){

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

@@ -3,7 +3,6 @@ package com.sheep.gamegroup.model.api;
 import com.alibaba.fastjson.JSONObject;
 import com.sheep.gamegroup.model.entity.BaseMessage;
 
-
 import java.util.Map;
 
 import retrofit2.Call;
@@ -18,8 +17,6 @@ import retrofit2.http.Query;
 import retrofit2.http.Streaming;
 import rx.Observable;
 
-import static com.sheep.gamegroup.util.ConnectAddress.*;
-
 /**
  * 暂时没接口
  * Created by ljy on 2018/3/8.
@@ -65,7 +62,11 @@ public interface ApiService {
      */
     @PUT("app/wechat/{id}")
     Observable<BaseMessage> putWebchat(@Path("id") int id, @Body JSONObject jsonObject);
-
+    /**
+     * 获取微信挂机功能是否开启
+     */
+    @GET("app/wechat/is_open")
+    Observable<BaseMessage> getWebchatIsOpen();
     /**
      * 绑定手机号
      */