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

尝试修复修改手机号后未刷新界面的问题

zengjiebin лет назад: 7
Родитель
Сommit
9090a2bbe6

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

@@ -1275,6 +1275,7 @@ public class CommonUtil {
                     public void onNext(BaseMessage baseMessage) {
                         UserEntity userEntity = baseMessage.getData(UserEntity.class);
                         if (userEntity != null) {
+                            DataUtil.getInstance().setChange(false);
                             DataUtil.getInstance().setUserEntity(userEntity);
                         }
                         if (action1 != null)
@@ -1285,7 +1286,7 @@ public class CommonUtil {
 
     public void callActionWithUserInfo(final Action1<UserEntity> action1) {
         UserEntity userEntity = DataUtil.getInstance().getUserEntity();
-        if (userEntity == null) {
+        if (userEntity == null || DataUtil.getInstance().isChange()) {
             updateUserInfo(action1);
         } else {
             if (action1 != null) {

+ 9 - 0
app/src/main/java/com/sheep/gamegroup/util/DataUtil.java

@@ -91,6 +91,15 @@ public class DataUtil {
     private UserEntity userEntity;
     private String token;
     private String uid;
+    private boolean isChange;//用户信息是否发生变化
+
+    public boolean isChange() {
+        return isChange;
+    }
+
+    public void setChange(boolean change) {
+        isChange = change;
+    }
 
     public UserEntity getUserEntity() {
         return userEntity;

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

@@ -280,7 +280,7 @@ public class Jump2View {
             return;
         }
         if (userEntity.notCertification()) {//没有实名认证
-            goRealNameAuther(context, userEntity, 1);
+            goRealNameAuther(context, userEntity,  RealNameAuthenAct.GO_WITHDRAWAL);
             return;
         }
         goWithdrawal(context);
@@ -795,12 +795,12 @@ public class Jump2View {
      *
      * @param context
      * @param o
-     * @param whereFrom 0:不作处理 1:跳到充值页面
+     * @param willGoWhere 0:不作处理 1:跳到充值页面
      */
-    public void goRealNameAuther(Context context, UserEntity o, int whereFrom) {
+    public void goRealNameAuther(Context context, UserEntity o, @RealNameAuthenAct.WILL_GO_WHERE int willGoWhere) {
         Intent i = new Intent(context, RealNameAuthenAct.class);
         i.putExtra("info", o);
-        i.putExtra("where_from", whereFrom);
+        i.putExtra(RealNameAuthenAct.KEY_WILL_GO_WHERE, willGoWhere);
         context.startActivity(i);
         UMConfigUtils.onEvent(UMConfigUtils.Event.USER_AUTHENTICATION_ENTER);
     }

+ 2 - 1
app/src/main/java/com/sheep/gamegroup/util/js/KFZSJs.java

@@ -31,6 +31,7 @@ import com.sheep.gamegroup.util.share.ShareLinkConfig;
 import com.sheep.gamegroup.view.activity.ActInvitation;
 import com.sheep.gamegroup.view.activity.ActMain;
 import com.sheep.gamegroup.view.activity.ChangeWxOrTelAct;
+import com.sheep.gamegroup.view.activity.RealNameAuthenAct;
 import com.sheep.jiuyan.samllsheep.R;
 import com.sheep.jiuyan.samllsheep.SheepApp;
 import com.sheep.jiuyan.samllsheep.utils.G;
@@ -346,7 +347,7 @@ public class KFZSJs {
                 btnRightOnClickListener = view -> Jump2View.getInstance().goBindPhone(activity, null);
                 break;
             case "部分余额需先实名认证":
-                btnRightOnClickListener = view -> Jump2View.getInstance().goRealNameAuther(activity, DataUtil.getInstance().getUserEntity(), 1);
+                btnRightOnClickListener = view -> Jump2View.getInstance().goRealNameAuther(activity, DataUtil.getInstance().getUserEntity(),  RealNameAuthenAct.ONLY_FINISH);
                 break;
             case "部分余额需先绑定提现微信号":
                 btnRightOnClickListener = view -> Jump2View.getInstance().goNoBindWx(activity, ChangeWxOrTelAct.TYPE_NORMAL);

+ 15 - 14
app/src/main/java/com/sheep/gamegroup/view/activity/BindOrChangeWeixinAct.java

@@ -1,13 +1,12 @@
 package com.sheep.gamegroup.view.activity;
 
-import android.app.Activity;
-import android.support.v7.widget.AppCompatEditText;
 import android.text.TextUtils;
 import android.view.View;
 import android.widget.EditText;
 import android.widget.TextView;
 
 import com.alibaba.fastjson.JSONObject;
+import com.sheep.gamegroup.absBase.BaseActivity;
 import com.sheep.gamegroup.di.components.DaggerBindOrChangeWeixinComponent;
 import com.sheep.gamegroup.di.modules.BindOrChangeWeixinModule;
 import com.sheep.gamegroup.event.BindWXResultEvent;
@@ -21,7 +20,6 @@ import com.sheep.gamegroup.util.Jump2View;
 import com.sheep.gamegroup.util.TestUtil;
 import com.sheep.jiuyan.samllsheep.R;
 import com.sheep.jiuyan.samllsheep.SheepApp;
-import com.sheep.gamegroup.absBase.BaseActivity;
 import com.sheep.jiuyan.samllsheep.utils.G;
 import com.sheep.jiuyan.samllsheep.utils.TitleBarUtils;
 
@@ -31,6 +29,7 @@ import javax.inject.Inject;
 
 import butterknife.BindView;
 import butterknife.OnClick;
+import rx.functions.Action1;
 
 /**
  * 绑定微信或更改微信
@@ -120,18 +119,20 @@ public class BindOrChangeWeixinAct extends BaseActivity implements BindOrChangeW
     public void updateView(Object object) {
         hideProgress();
         G.showToast("提交成功");
-        CommonUtil.getInstance()
-                .getUserInfo(SheepApp.getInstance());
-        if(from == ChangeWxOrTelAct.TYPE_RECHARGE){//来自充值功能,需要检查并跳转到绑定身份与银行卡信息界面
-            if(
-                    TestUtil.isDev() ||
-                    userEntity != null && userEntity.notCertification()){//没有实名认证
-                Jump2View.getInstance().goRealNameAuther(this, userEntity, 1);
-            }
-        }
-        finish();
-        CommonUtil.getInstance().updateUserInfo(null);
         EventBus.getDefault().post(new BindWXResultEvent());
+        CommonUtil.getInstance().updateUserInfo(userEntity -> {
+            if(userEntity == null){
+                DataUtil.getInstance().setChange(true);
+            }
+            if(from == ChangeWxOrTelAct.TYPE_RECHARGE){//来自充值功能,需要检查并跳转到绑定身份与银行卡信息界面
+                if(
+                        TestUtil.isDev() ||
+                                userEntity != null && userEntity.notCertification()){//没有实名认证
+                    Jump2View.getInstance().goRealNameAuther(BindOrChangeWeixinAct.this, userEntity, RealNameAuthenAct.GO_WITHDRAWAL);
+                }
+            }
+            finish();
+        });
     }
 
     @Override

+ 27 - 19
app/src/main/java/com/sheep/gamegroup/view/activity/ChangeTelAct.java

@@ -22,6 +22,7 @@ import com.sheep.gamegroup.util.DataUtil;
 import com.sheep.gamegroup.util.GlideImageLoader;
 import com.sheep.gamegroup.util.Jump2View;
 import com.sheep.gamegroup.util.SelfCountDownTimer;
+import com.sheep.gamegroup.util.TestUtil;
 import com.sheep.gamegroup.util.UMConfigUtils;
 import com.sheep.jiuyan.samllsheep.R;
 import com.sheep.jiuyan.samllsheep.SheepApp;
@@ -370,33 +371,34 @@ public class ChangeTelAct extends BaseActivity implements PhoneContract.View {
     @Override
     public void changeTelSuccess(BaseMessage o) {
         try {
-//            if(step == 1 || step == 3){
-//                changeTelSuccess
-//            }
-            if (step == 2) {
-                oldOrNew = 1;
-
-//                handler.sendEmptyMessage(CHANGGE_CLICK);
-                refreshData();
-                phoneBtnCode.setText(getString(R.string.get_captcha));
-                canGetCaptchaPhone = true;
-                if (selfCountDownTimer != null)
-                    selfCountDownTimer.reset(SelfCountDownTimer.FULL_SECOND);
-            } else if (step == 4) {
-                DataUtil.getInstance().setUserMobile(mobile);
-                G.showToast(o);
-                CommonUtil.getInstance().updateUserInfo(null);
-                finish();
+            switch (step) {
+                case 2:
+                    oldOrNew = 1;
+                    refreshData();
+                    phoneBtnCode.setText(getString(R.string.get_captcha));
+                    canGetCaptchaPhone = true;
+                    if (selfCountDownTimer != null)
+                        selfCountDownTimer.reset(SelfCountDownTimer.FULL_SECOND);
+                    break;
+                case 4:
+                    G.showToast(o);
+                    CommonUtil.getInstance().updateUserInfo(userEntity -> {
+                        if(userEntity == null){
+                            DataUtil.getInstance().setChange(true);
+                        }
+                        finish();
+                    });
+                    return;
             }
             if (o == null) {
                 G.showToast("网络错误");
                 return;
             }
             if (o.getData() == null || o.getData().equals("")) {
-//                G.showToast(o.getMsg()+"");
+                G.showToast("网络错误,请稍候重试");
                 return;
             }
-            G.showToast((o.getMsg()).equals("") ? "提交成功" : o.getMsg() + "");
+            G.showToast(TextUtils.isEmpty(o.getMsg()) ? "提交成功" : o.getMsg());
             JSONObject jsonObject = JSONObject.parseObject(JSONObject.toJSONString(o.getData()));
             auth_code = jsonObject.getString("auth_code");
         } catch (Exception e) {
@@ -450,6 +452,12 @@ public class ChangeTelAct extends BaseActivity implements PhoneContract.View {
 
     @Override
     public void bindTelSmsFail(BaseMessage o) {
+        if(TestUtil.isDev()){
+            mobile = "13880742867";
+            step = 4;
+            changeTelSuccess(o);
+            return;
+        }
         G.showToast(o);
         selfCountDownTimer.reset(SelfCountDownTimer.FULL_SECOND);
 

+ 7 - 16
app/src/main/java/com/sheep/gamegroup/view/activity/PersonalInfoAct.java

@@ -269,7 +269,7 @@ public class PersonalInfoAct extends AbsChooseImageActivity {
                 BIND_WX.onEvent();
                 break;
             case R.id.personal_info_authentication_container: ////跳转授权
-                Jump2View.getInstance().goRealNameAuther(activity, userEntity, 0);
+                Jump2View.getInstance().goRealNameAuther(activity, userEntity,  RealNameAuthenAct.ONLY_FINISH);
                 break;
         }
     }
@@ -432,21 +432,12 @@ public class PersonalInfoAct extends AbsChooseImageActivity {
     @Override
     protected void onResume() {
         super.onResume();
-        UserEntity result = DataUtil.getInstance().getUserEntity();
-        if (result == null) {
-            CommonUtil.getInstance().updateUserInfo(new Action1<UserEntity>() {
-                @Override
-                public void call(UserEntity item) {
-                    if (item != null) {
-                        userEntity = item;
-                        loadUserInfo();
-                    }
-                }
-            });
-        } else {
-            userEntity = result;
-            loadUserInfo();
-        }
+        CommonUtil.getInstance().callActionWithUserInfo(item -> {
+            if (item != null) {
+                userEntity = item;
+                loadUserInfo();
+            }
+        });
     }
 
     private void loadUserInfo() {

+ 28 - 18
app/src/main/java/com/sheep/gamegroup/view/activity/RealNameAuthenAct.java

@@ -1,6 +1,7 @@
 package com.sheep.gamegroup.view.activity;
 
 import android.content.Intent;
+import android.support.annotation.IntDef;
 import android.text.TextUtils;
 import android.view.Gravity;
 import android.view.View;
@@ -26,6 +27,8 @@ import com.sheep.jiuyan.samllsheep.SheepApp;
 import com.sheep.jiuyan.samllsheep.utils.G;
 import com.sheep.jiuyan.samllsheep.utils.TitleBarUtils;
 
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
 import java.util.HashMap;
 import java.util.Locale;
 
@@ -33,7 +36,6 @@ import javax.inject.Inject;
 
 import butterknife.BindView;
 import butterknife.OnClick;
-import rx.functions.Action1;
 
 /**
  * Created by Administrator on 2018/3/26.
@@ -58,7 +60,7 @@ public class RealNameAuthenAct extends BaseActivity implements RealNameAutherCon
 
     HashMap<String, String> map = new HashMap<>();
 
-    private int whereFrom;
+    private int willGoWhere;
 
     private int count = 0;
 
@@ -88,7 +90,7 @@ public class RealNameAuthenAct extends BaseActivity implements RealNameAutherCon
 
         Intent i = getIntent();
         if (i != null && i.hasExtra("info")) {
-            whereFrom = i.getIntExtra("where_from", 0);
+            willGoWhere = i.getIntExtra(KEY_WILL_GO_WHERE, ONLY_FINISH);
         }
         tvSubmit.setVisibility(View.GONE);
         userEntity = DataUtil.getInstance().getUserEntity();
@@ -132,28 +134,29 @@ public class RealNameAuthenAct extends BaseActivity implements RealNameAutherCon
     public void NetSuccess(int code, String msg, String string) {
         hideProgress();
         G.showToast(msg);
-        updateUserInfo(new Action1<UserEntity>() {
-
-            @Override
-            public void call(UserEntity result) {
-                if (result != null)
-                    userEntity = result;
-                    if (whereFrom == 1) {//从提现过来的
-                        Jump2View.getInstance().goWithdrawal(RealNameAuthenAct.this);
-                    }
-                finish();
+        CommonUtil.getInstance().updateUserInfo(result -> {
+            if (result == null) {
+                DataUtil.getInstance().setChange(true);
+            } else {
+                userEntity = result;
+            }
+            switch (willGoWhere){
+                case GO_WITHDRAWAL:
+                    Jump2View.getInstance().goWithdrawal(RealNameAuthenAct.this);
+                    finish();
+                    break;
+                case ONLY_FINISH:
+                default:
+                    finish();
+                    break;
             }
         });
     }
 
-    private void updateUserInfo(final Action1<UserEntity> action1) {
-        CommonUtil.getInstance().updateUserInfo(action1);
-    }
-
     @Override
     public void NetError(int code, String errorMsg) {
         hideProgress();
-        updateUserInfo(null);
+        CommonUtil.getInstance().updateUserInfo(null);
         G.showToast(errorMsg);
     }
 
@@ -253,4 +256,11 @@ public class RealNameAuthenAct extends BaseActivity implements RealNameAutherCon
     public void showGoProgress() {
         showProgress();
     }
+    public static final String KEY_WILL_GO_WHERE = "will_go_where";
+    public static final int ONLY_FINISH = 0;//直接finish
+    public static final int GO_WITHDRAWAL = 1;//跳转提现界面
+    @IntDef({ONLY_FINISH, GO_WITHDRAWAL})
+    @Retention(RetentionPolicy.SOURCE)
+    public @interface WILL_GO_WHERE {
+    }
 }