Procházet zdrojové kódy

optmize startup skip ads

hanjing před 7 roky
rodič
revize
7aaa349013

+ 82 - 72
app/src/main/java/com/sheep/gamegroup/util/Jump2View.java

@@ -284,12 +284,12 @@ public class Jump2View {
         }
         if (
 //                TestUtil.isDev() ||
-                        TextUtils.isEmpty(DataUtil.getInstance().getUserWxOpenId())) {//这里认定没有微信id  为   没有绑定微信号
+                TextUtils.isEmpty(DataUtil.getInstance().getUserWxOpenId())) {//这里认定没有微信id  为   没有绑定微信号
             goNoBindWx(context, ChangeWxOrTelAct.TYPE_RECHARGE);
             return;
         }
         if (userEntity.notCertification()) {//没有实名认证
-            goRealNameAuther(context, userEntity,  RealNameAuthenAct.GO_WITHDRAWAL);
+            goRealNameAuther(context, userEntity, RealNameAuthenAct.GO_WITHDRAWAL);
             return;
         }
         goWithdrawal(context);
@@ -440,6 +440,7 @@ public class Jump2View {
      * @param activity
      */
     public void checkOrGoHomePage(final Activity activity) {
+        // todo checkOrGoHome
         CommonUtil.getInstance().updateUserInfo(new Action1<UserEntity>() {
             @Override
             public void call(UserEntity userEntity) {
@@ -448,21 +449,16 @@ public class Jump2View {
                     GlideImageLoader.saveAndSetRqImage(null, userEntity.getShareLink(ShareLinkConfig.FACE_TO_FACE), 800);
                 }
 
-                if (userEntity != null && userEntity.canBindMobile()
-                        && !BuildConfig.DEBUG
-                ) {//老用户没有绑定手机号
-                    Jump2View.getInstance().goBindPhone(activity, ChangeTelAct.FROM_LOGIN);
-                    activity.finish();
-                    return;
-                }
-                checkLabel(activity, new Action1<BaseMessage>() {
-                    @Override
-                    public void call(BaseMessage baseMessage) {
-                        checkCommendApp(activity, null);
-                    }
-                });
+//                if (userEntity != null && userEntity.canBindMobile() && !BuildConfig.DEBUG) {//老用户没有绑定手机号
+//                    Jump2View.getInstance().goBindPhone(activity, ChangeTelAct.FROM_LOGIN);
+//                    activity.finish();
+//                    return;
+//                }
             }
         });
+        checkLabel(activity, (baseMessage) -> {
+            checkCommendApp(activity, null);
+        });
     }
 
     /**
@@ -1728,29 +1724,36 @@ public class Jump2View {
     }
 
     public void checkLabel(final Activity activity, final Action1<BaseMessage> action1) {
-        SheepApp.getInstance().getNetComponent().getApiService().checkLabel()
-                .subscribeOn(Schedulers.io())
-                .observeOn(AndroidSchedulers.mainThread())
-                .subscribe(new SheepSubscriber<BaseMessage>(SheepApp.getInstance()) {
-                    @Override
-                    public void onNext(BaseMessage baseMessage) {
-                        CheckUserLabel checkLabel = baseMessage.getData(CheckUserLabel.class);
-                        if (
+        if (DataUtil.getAsBoolean("STARTUP_CHECKED_LABEL", false)) {
+            DataUtil.putAsBoolean("STARTUP_CHECKED_LABEL", true);
+            SheepApp.getInstance().getNetComponent().getApiService().checkLabel()
+                    .subscribeOn(Schedulers.io())
+                    .observeOn(AndroidSchedulers.mainThread())
+                    .subscribe(new SheepSubscriber<BaseMessage>(SheepApp.getInstance()) {
+                        @Override
+                        public void onNext(BaseMessage baseMessage) {
+                            CheckUserLabel checkLabel = baseMessage.getData(CheckUserLabel.class);
+                            if (
 //                                BuildConfig.DEBUG ||
-                                checkLabel != null && checkLabel.isNeed_set_label()) {//需要设置用户标签
-                            Jump2View.getInstance().gotoUserLabelList(activity, baseMessage);
-                        } else if (action1 != null) {
-                            action1.call(baseMessage);
+                                    checkLabel != null && checkLabel.isNeed_set_label()) {//需要设置用户标签
+                                Jump2View.getInstance().gotoUserLabelList(activity, baseMessage);
+                            } else if (action1 != null) {
+                                action1.call(baseMessage);
+                            }
                         }
-                    }
 
-                    @Override
-                    public void onError(BaseMessage baseMessage) {
-                        if (action1 != null) {
-                            action1.call(baseMessage);
+                        @Override
+                        public void onError(BaseMessage baseMessage) {
+                            if (action1 != null) {
+                                action1.call(baseMessage);
+                            }
                         }
-                    }
-                });
+                    });
+        } else {
+            if (action1 != null) {
+                action1.call(null);
+            }
+        }
     }
 
     public void goChangePassword(Activity activity) {
@@ -1836,8 +1839,8 @@ public class Jump2View {
      * @param item
      */
     public void goEntity(Release_task item) {
-        if(item != null){
-            switch (item.getTask().getTask_type()){
+        if (item != null) {
+            switch (item.getTask().getTask_type()) {
                 case 1019:
                     goWeb(SheepApp.getInstance().getCurrentActivity(), new WebParams(Config.getUrlByPath(Config.PATH_WELFARE_DETAIL
                             , "id", item.getId(), "device_id", DeviceUtil.getDeviceId(SheepApp.getInstance()), "app_version", String.valueOf(BuildConfig.VERSION_CODE))).setTitle(item.getName()));
@@ -1852,20 +1855,22 @@ public class Jump2View {
             }
         }
     }
+
     /**
      * 跳转游戏详情界面
      *
      * @param item
      */
     public void goEntity(GameEntity item) {
-        if(item != null){
-            if(item.getApp() != null){
+        if (item != null) {
+            if (item.getApp() != null) {
                 goEntity(item.getApp());
-            } else if(item.getRelease_task() != null){
+            } else if (item.getRelease_task() != null) {
                 goEntity(item.getRelease_task());
             }
         }
     }
+
     /**
      * 发现模块--游戏详情界面
      *
@@ -1890,7 +1895,7 @@ public class Jump2View {
      * @param item
      */
     public void goEntity(Applications item, boolean isAutoDownload) {
-        if(item == null){
+        if (item == null) {
             G.showToast(R.string.please_contact_customer_service);
             return;
         }
@@ -1981,7 +1986,7 @@ public class Jump2View {
      * 游戏代充
      */
     public void goGameRecharge(Activity activity, Object o) {
-        if(!Config.IS_OPEN_GAME_RECHARGE){//关闭游戏直充功能
+        if (!Config.IS_OPEN_GAME_RECHARGE) {//关闭游戏直充功能
             G.showToast(R.string.un_use_function);
             return;
         }
@@ -2363,6 +2368,7 @@ public class Jump2View {
     public void startDownloadService(Context context, DownLoadInfo downLoadInfo) {
         context.startService(new Intent(context, DownloadService.class).putExtra("download_url", downLoadInfo.getMDownloadUrl()).putExtra("file_path", downLoadInfo.getMApkPath()));
     }
+
     /**
      * 启动下载后台服务进行下载
      *
@@ -2373,6 +2379,7 @@ public class Jump2View {
         Context context = SheepApp.getInstance();
         context.startService(new Intent(context, DownloadService.class).putExtra("download_url", downloadUrl).putExtra("file_path", filePath));
     }
+
     /**
      * 启动下载后台服务进行下载
      *
@@ -2500,24 +2507,24 @@ public class Jump2View {
     /**
      * 播放视频
      *
-     * @param url     播放地址
+     * @param url   播放地址
      * @param title 标题
      */
     public void goActPlayVideo(String url, String title) {
-       goActPlayVideo(url, title, ActPlayVideo.getCoverByUrl(url));
+        goActPlayVideo(url, title, ActPlayVideo.getCoverByUrl(url));
     }
 
     /**
      * 播放视频
      *
-     * @param url     播放地址
-     * @param title 标题
+     * @param url      播放地址
+     * @param title    标题
      * @param coverUrl 封面
      */
     public void goActPlayVideo(String url, String title, String coverUrl) {
         String fileName = FileUtil.getLastSplitEnd(url, '/');
-        if(!fileName.endsWith(".mp4")){
-            fileName +=  ".mp4";
+        if (!fileName.endsWith(".mp4")) {
+            fileName += ".mp4";
         }
         String filePath = new File(DIR, fileName).getAbsolutePath();
         //开始下载视频
@@ -2525,7 +2532,7 @@ public class Jump2View {
         Activity activity = SheepApp.getInstance().getCurrentActivity();
         Intent intent = new Intent(activity, ActPlayVideo.class);
         intent.putExtra(ActPlayVideo.KEY_URL, filePath);
-        if(TextUtils.isEmpty(title)){//标题最不可靠,可能为空
+        if (TextUtils.isEmpty(title)) {//标题最不可靠,可能为空
             title = url;
         }
         intent.putExtra(ActPlayVideo.KEY_TITLE, title);
@@ -2876,7 +2883,7 @@ public class Jump2View {
      * 小绵羊3.4.10新增 -- 游戏组详情界面
      */
     public void goEntity(GameGroup item) {
-        if(item == null){
+        if (item == null) {
             G.showToast(R.string.please_contact_customer_service);
             return;
         }
@@ -2902,13 +2909,13 @@ public class Jump2View {
                         Activity activity = SheepApp.getInstance().getCurrentActivity();
                         Intent intent = new Intent(activity, ActGameGroupOrGameDetail.class);
                         int id = gameGroup.getFirstApplicationsId();
-                        if (id > 0){
+                        if (id > 0) {
                             intent.putExtra("id", id);
                         } else {
                             G.showToast(R.string.please_contact_customer_service);
                             return;
                         }
-                        if(ListUtil.size(gameGroup.getApplications()) > 1)//有多个游戏时才添加游戏组数据
+                        if (ListUtil.size(gameGroup.getApplications()) > 1)//有多个游戏时才添加游戏组数据
                             DataUtil.putObject(intent, gameGroup);
                         goPlayGameDetailAndCheckWelfare(activity, intent, id);
                     }
@@ -2933,7 +2940,7 @@ public class Jump2View {
      */
     public void goPlayGameDetail(int id, boolean isAutoDownload) {
         GAME_PLAY_GAME_DETAIL.onEvent();
-        if (id > 0){
+        if (id > 0) {
             Activity activity = SheepApp.getInstance().getCurrentActivity();
             Intent intent = new Intent(activity, ActGameGroupOrGameDetail.class);
             intent.putExtra("id", id);
@@ -2943,28 +2950,29 @@ public class Jump2View {
             G.showToast(R.string.please_contact_customer_service);
         }
     }
+
     /**
      * 小绵羊3.4.10新增 -- 游戏组游戏详情 界面
      */
     public void goPlayGameDetailAndCheckWelfare(Activity activity, Intent intent, int appId) {
         SheepApp.getInstance().getNetComponent().getApiService().getAppWelfareAndMoneyReward(1, DataUtil.PER_PAGE, appId)
-                        .subscribeOn(Schedulers.io())
-                        .observeOn(AndroidSchedulers.mainThread())
-                        .subscribe(new SheepSubscriber<BaseMessage>(SheepApp.getInstance()) {
-                            @Override
-                            public void onNext(BaseMessage baseMessage) {
-                                List<Release_task> list = baseMessage.getDataList(Release_task.class);
-                                boolean hasWelfare = !ListUtil.isEmpty(list);
-                                intent.putExtra(KEY_HAS_WELFARE, hasWelfare);
-                                activity.startActivity(intent);
-                            }
+                .subscribeOn(Schedulers.io())
+                .observeOn(AndroidSchedulers.mainThread())
+                .subscribe(new SheepSubscriber<BaseMessage>(SheepApp.getInstance()) {
+                    @Override
+                    public void onNext(BaseMessage baseMessage) {
+                        List<Release_task> list = baseMessage.getDataList(Release_task.class);
+                        boolean hasWelfare = !ListUtil.isEmpty(list);
+                        intent.putExtra(KEY_HAS_WELFARE, hasWelfare);
+                        activity.startActivity(intent);
+                    }
 
-                            @Override
-                            public void onError(BaseMessage baseMessage) {
-                                intent.putExtra(KEY_HAS_WELFARE, false);
-                                activity.startActivity(intent);
-                            }
-                        });
+                    @Override
+                    public void onError(BaseMessage baseMessage) {
+                        intent.putExtra(KEY_HAS_WELFARE, false);
+                        activity.startActivity(intent);
+                    }
+                });
     }
 
     /**
@@ -2973,7 +2981,7 @@ public class Jump2View {
      * @param app
      */
     public void gotoGameVipRecharge(Applications app) {
-        String url = Config.getUrlByPath(Config.PATH_DIRECTIONAL_RECHARGE + "/" + app.getGame_discount_id(),"authorization", SpUtils.getToken(SheepApp.getInstance()), "ssnocache", "1");
+        String url = Config.getUrlByPath(Config.PATH_DIRECTIONAL_RECHARGE + "/" + app.getGame_discount_id(), "authorization", SpUtils.getToken(SheepApp.getInstance()), "ssnocache", "1");
         WebParams webParams = new WebParams(url, "抢购优惠").setShowTitle(false);
         Jump2View.getInstance().goWeb(SheepApp.getInstance().getCurrentActivity(), webParams);
     }
@@ -2989,14 +2997,16 @@ public class Jump2View {
     public void goAppointTaskList() {
         goAppointTaskList(false);
     }
+
     /**
      * 小绵羊3.5.2新增 -- 跳转 定向奖励 界面
+     *
      * @param isFromActMyMoney 是否是从我的资产中的定向奖励点击进入
      */
     public void goAppointTaskList(boolean isFromActMyMoney) {
         WebParams webParams = new WebParams(Config.getUrlByPath(Config.PATH_APPOINT_TASK_LIST), "定向奖励");
         Jump2View.getInstance().goWeb(SheepApp.getInstance().getCurrentActivity(), webParams);
-        if(isFromActMyMoney) {
+        if (isFromActMyMoney) {
             DataUtil.getInstance().readAppointList();
             EventBus.getDefault().post(new ShowRedDot(ShowRedDot.WHERE_PERSONAL_CENTER).setShow(false));
         }
@@ -3016,7 +3026,7 @@ public class Jump2View {
      * 小绵羊3.5.4新增 -- 礼包中心 4个标签
      */
     public void goEntity(GiftTags item) {
-        if(item == null){
+        if (item == null) {
             G.showToast(R.string.please_contact_customer_service);
             return;
         }
@@ -3027,7 +3037,7 @@ public class Jump2View {
     }
 
     public void goGameGiftBag(int appId, String appName) {
-        if(appId == 0){
+        if (appId == 0) {
             G.showToast(R.string.please_contact_customer_service);
             return;
         }

+ 1 - 1
app/src/main/java/com/sheep/gamegroup/util/TestUtil.java

@@ -515,7 +515,7 @@ public class TestUtil {
                 break;
             case "测试内部h5": {
 //                Jump2View.getInstance().goWeb(activity, StringUtils.getCopyText().toString(), "小绵羊官网");
-                String url = "http://10.8.240.155:8082/#/game-coupon?authorization=64239%40de829becddb652d85efa02b312184abb&pf=android.sheep.app&device_id=e90a3bf5f9cfd223&invitation_code=73214122";
+                String url = "http://10.8.240.193:8082/#/home?authorization=64239%40342d72782208f5d7b3a16ae8d1b9542e&pf=android.sheep.app&device_id=e90a3bf5f9cfd223&invitation_code=73214122";
                 Jump2View.getInstance().goWeb(activity, url, "小绵羊官网");
             }
                 break;