瀏覽代碼

登录界面去掉邀请码输入框

zengjiebin 7 年之前
父節點
當前提交
d92fb958e3
共有 1 個文件被更改,包括 32 次插入19 次删除
  1. 32 19
      app/src/main/java/com/sheep/gamegroup/view/activity/LoginAct.java

+ 32 - 19
app/src/main/java/com/sheep/gamegroup/view/activity/LoginAct.java

@@ -36,6 +36,7 @@ import com.sheep.gamegroup.util.SelfCountDownTimer;
 import com.sheep.gamegroup.util.StringUtils;
 import com.sheep.gamegroup.util.TestUtil;
 import com.sheep.gamegroup.util.UMConfigUtils;
+import com.sheep.gamegroup.util.ViewUtil;
 import com.sheep.jiuyan.samllsheep.R;
 import com.sheep.jiuyan.samllsheep.SheepApp;
 import com.sheep.jiuyan.samllsheep.utils.G;
@@ -84,7 +85,7 @@ public class LoginAct extends BaseUMActivity implements LoginContract.View {
     AppCompatEditText loginEtCode;
     @BindView(R.id.login_btn_code)
     TextView loginBtnCode;
-    @BindView(R.id.login_et_scope)
+//    @BindView(R.id.login_et_scope)
     AppCompatEditText loginEtScope;
     @BindView(R.id.test_change)
     TextView testChange;
@@ -109,25 +110,27 @@ public class LoginAct extends BaseUMActivity implements LoginContract.View {
         TestUtil.testChange(this, (TextView) findViewById(R.id.test_change));
         TestUtil.testChangeUser(this, (TextView) findViewById(R.id.test_change_user));
         channelName = ChannelContent.getInstance().getChannel_name();
-        if(!TextUtils.isEmpty(channelName)){
-            loginEtScope.setVisibility(View.GONE);
-        } else {
-            loginEtAccount.addTextChangedListener(new TextWatcher() {
-                @Override
-                public void beforeTextChanged(CharSequence charSequence, int i, int i1, int i2) {
+        if(loginEtScope != null) {
+            if (!TextUtils.isEmpty(channelName)) {
+                loginEtScope.setVisibility(View.GONE);
+            } else {
+                loginEtAccount.addTextChangedListener(new TextWatcher() {
+                    @Override
+                    public void beforeTextChanged(CharSequence charSequence, int i, int i1, int i2) {
 
-                }
+                    }
 
-                @Override
-                public void onTextChanged(CharSequence charSequence, int i, int i1, int i2) {
+                    @Override
+                    public void onTextChanged(CharSequence charSequence, int i, int i1, int i2) {
 
-                }
+                    }
 
-                @Override
-                public void afterTextChanged(Editable editable) {
-                    checkAccountScope(editable);
-                }
-            });
+                    @Override
+                    public void afterTextChanged(Editable editable) {
+                        checkAccountScope(editable);
+                    }
+                });
+            }
         }
 
         if (TestUtil.isTest()) {
@@ -140,6 +143,8 @@ public class LoginAct extends BaseUMActivity implements LoginContract.View {
      * 根据输入的手机号检查账号有没有邀请码
      */
     private void checkAccountScope(Editable editable) {
+        if(loginEtScope == null)
+            return;
         String mobile = editable.toString();
         if(StringUtils.isMobile(mobile)){//是手机号才检查
             //调用接口检查账号中的邀请码
@@ -149,7 +154,10 @@ public class LoginAct extends BaseUMActivity implements LoginContract.View {
                             .subscribe(new SheepSubscriber<BaseMessage>(SheepApp.getInstance()) {
                                 @Override
                                 public void onNext(BaseMessage baseMessage) {
-                                    loginEtScope.setVisibility(baseMessage.getData(Boolean.class) ? View.VISIBLE : View.GONE);
+                                    Boolean result = baseMessage.getData(Boolean.class);
+                                    if(result == null)
+                                        result = false;
+                                    ViewUtil.setVisibility(loginEtScope, result);
                                 }
 
                                 @Override
@@ -157,7 +165,7 @@ public class LoginAct extends BaseUMActivity implements LoginContract.View {
                                 }
                             });
         } else {
-            loginEtScope.setVisibility(View.VISIBLE);
+            ViewUtil.setVisibility(loginEtScope, true);
         }
 
     }
@@ -334,7 +342,12 @@ public class LoginAct extends BaseUMActivity implements LoginContract.View {
         if (!checkCodeInput()) {
             return;
         }
-        String scope = !TextUtils.isEmpty(channelName) ? channelName : loginEtScope.getText().toString();
+        String scope;
+        if(loginEtScope == null){
+            scope = channelName;
+        } else {
+            scope = !TextUtils.isEmpty(channelName) ? channelName : loginEtScope.getText().toString();
+        }
         showProgress();
         JSONObject jsonObject = new JSONObject();
         jsonObject.put("account", etPhone);