|
|
@@ -38,7 +38,7 @@ import rx.functions.Action1;
|
|
|
* Created by ljy on 2018/3/27.
|
|
|
*/
|
|
|
|
|
|
-public class ChangeTelAct extends BaseActivity implements PhoneContract.View{
|
|
|
+public class ChangeTelAct extends BaseActivity implements PhoneContract.View {
|
|
|
@BindView(R.id.tel_tv)
|
|
|
TextView telTv;
|
|
|
@BindView(R.id.sure_change_tv)
|
|
|
@@ -88,7 +88,7 @@ public class ChangeTelAct extends BaseActivity implements PhoneContract.View{
|
|
|
private SelfCountDownTimer selfCountDownTimer;
|
|
|
private boolean canGetCaptchaPhone = true;
|
|
|
|
|
|
- private int where_from ;
|
|
|
+ private int where_from;
|
|
|
|
|
|
@Override
|
|
|
protected int getLayoutId() {
|
|
|
@@ -115,14 +115,15 @@ public class ChangeTelAct extends BaseActivity implements PhoneContract.View{
|
|
|
toFinish();
|
|
|
}
|
|
|
});
|
|
|
- switch (where_from){
|
|
|
+ switch (where_from) {
|
|
|
case FROM_SPLASH://非第一次登录(如:登录后直接重启),老用户需要绑定手机号
|
|
|
titleBarUtils.setRightBtn(this, "跳过", 0, new View.OnClickListener() {
|
|
|
@Override
|
|
|
public void onClick(View view) {
|
|
|
- Intent intent = new Intent(activity, ActMain.class);
|
|
|
- activity.startActivity(intent);
|
|
|
- activity.finish();
|
|
|
+// Intent intent = new Intent(activity, ActMain.class).setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
|
|
|
+// activity.startActivity(intent);
|
|
|
+// activity.finish();
|
|
|
+ startMainAct();
|
|
|
}
|
|
|
});
|
|
|
break;
|
|
|
@@ -133,9 +134,10 @@ public class ChangeTelAct extends BaseActivity implements PhoneContract.View{
|
|
|
Jump2View.getInstance().checkLabel(activity, new Action1<BaseMessage>() {
|
|
|
@Override
|
|
|
public void call(BaseMessage baseMessage) {
|
|
|
- Intent intent = new Intent(activity, ActMain.class);
|
|
|
- activity.startActivity(intent);
|
|
|
- activity.finish();
|
|
|
+// Intent intent = new Intent(activity, ActMain.class);
|
|
|
+// activity.startActivity(intent);
|
|
|
+// activity.finish();
|
|
|
+ startMainAct();
|
|
|
}
|
|
|
});
|
|
|
}
|
|
|
@@ -146,7 +148,7 @@ public class ChangeTelAct extends BaseActivity implements PhoneContract.View{
|
|
|
break;
|
|
|
}
|
|
|
mobiles = DataUtil.getInstance().getUserMobile();
|
|
|
- if(!TextUtils.isEmpty(mobiles)){//提示
|
|
|
+ if (!TextUtils.isEmpty(mobiles)) {//提示
|
|
|
oldOrNew = 1;
|
|
|
showChangeLayout.setVisibility(View.VISIBLE);
|
|
|
changePhoneLayout.setVisibility(View.GONE);
|
|
|
@@ -156,20 +158,31 @@ public class ChangeTelAct extends BaseActivity implements PhoneContract.View{
|
|
|
refreshData();
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * 跳转到首页
|
|
|
+ */
|
|
|
+ private void startMainAct() {
|
|
|
+ Intent intent = new Intent(activity, ActMain.class).setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
|
|
|
+ activity.startActivity(intent);
|
|
|
+ activity.finish();
|
|
|
+ }
|
|
|
+
|
|
|
private void toFinish() {
|
|
|
- switch (where_from){
|
|
|
+ switch (where_from) {
|
|
|
case FROM_SPLASH://非第一次登录(如:登录后直接重启),老用户需要绑定手机号
|
|
|
- Intent intent = new Intent(activity, ActMain.class);
|
|
|
- startActivity(intent);
|
|
|
- finish();
|
|
|
+// Intent intent = new Intent(activity, ActMain.class);
|
|
|
+// startActivity(intent);
|
|
|
+// finish();
|
|
|
+ startMainAct();
|
|
|
break;
|
|
|
case FROM_LOGIN://第一次登录,老用户需要绑定手机号
|
|
|
Jump2View.getInstance().checkLabel(activity, new Action1<BaseMessage>() {
|
|
|
@Override
|
|
|
public void call(BaseMessage baseMessage) {
|
|
|
- Intent intent = new Intent(activity, ActMain.class);
|
|
|
- activity.startActivity(intent);
|
|
|
- activity.finish();
|
|
|
+// Intent intent = new Intent(activity, ActMain.class);
|
|
|
+// activity.startActivity(intent);
|
|
|
+// activity.finish();
|
|
|
+ startMainAct();
|
|
|
}
|
|
|
});
|
|
|
break;
|
|
|
@@ -214,39 +227,39 @@ public class ChangeTelAct extends BaseActivity implements PhoneContract.View{
|
|
|
/**
|
|
|
* refresh
|
|
|
*/
|
|
|
- public void refreshData(){
|
|
|
+ public void refreshData() {
|
|
|
showChangeLayout.setVisibility(View.GONE);
|
|
|
changePhoneLayout.setVisibility(View.VISIBLE);
|
|
|
- if(oldOrNew == 1){
|
|
|
+ if (oldOrNew == 1) {
|
|
|
hitStr = "请输入手机号码";
|
|
|
noticeStr = "验证原手机";
|
|
|
- phoneEtAccount.setHint(hitStr+"");
|
|
|
+ phoneEtAccount.setHint(hitStr + "");
|
|
|
// phoneEtAccount.setText(mobiles+"");
|
|
|
- }else{
|
|
|
+ } else {
|
|
|
step = 0;
|
|
|
hitStr = "请输入手机号码";
|
|
|
noticeStr = "绑定手机号";
|
|
|
- phoneEtAccount.setHint(hitStr+"");
|
|
|
+ phoneEtAccount.setHint(hitStr + "");
|
|
|
TitleBarUtils.getInstance().setTitle(this, noticeStr);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- @OnClick({ R.id.phone_btn_code, R.id.phone_sure_tv, R.id.sure_change_tv, R.id.phone_btn_code_old})
|
|
|
+ @OnClick({R.id.phone_btn_code, R.id.phone_sure_tv, R.id.sure_change_tv, R.id.phone_btn_code_old})
|
|
|
public void onViewClicked(View view) {
|
|
|
switch (view.getId()) {
|
|
|
case R.id.phone_btn_code:
|
|
|
sec_code = null;
|
|
|
- mobile = phoneEtAccount.getText().toString() +"";
|
|
|
- if(!checkPhoneInput(mobile)){
|
|
|
+ mobile = phoneEtAccount.getText().toString() + "";
|
|
|
+ if (!checkPhoneInput(mobile)) {
|
|
|
return;
|
|
|
}
|
|
|
if (!canGetCaptchaPhone) {
|
|
|
return;
|
|
|
}
|
|
|
- if(oldOrNew == 0){
|
|
|
+ if (oldOrNew == 0) {
|
|
|
selfCountDownTimer.reset(SelfCountDownTimer.FULL_SECOND);
|
|
|
JSONObject jsonObject = new JSONObject();
|
|
|
- jsonObject.put("mobile", mobile+"");
|
|
|
+ jsonObject.put("mobile", mobile + "");
|
|
|
presenter.smsBindMobile(jsonObject);
|
|
|
canGetCaptchaPhone = false;
|
|
|
selfCountDownTimer.start();
|
|
|
@@ -256,18 +269,18 @@ public class ChangeTelAct extends BaseActivity implements PhoneContract.View{
|
|
|
submit();
|
|
|
break;
|
|
|
case R.id.phone_sure_tv://更换手机号
|
|
|
- sec_code = phoneEtCode.getText().toString()+"";
|
|
|
- mobile = phoneEtAccount.getText().toString() +"";
|
|
|
- if(!checkPhoneInput(mobile)){
|
|
|
+ sec_code = phoneEtCode.getText().toString() + "";
|
|
|
+ mobile = phoneEtAccount.getText().toString() + "";
|
|
|
+ if (!checkPhoneInput(mobile)) {
|
|
|
return;
|
|
|
}
|
|
|
- if(!checkCodeInput(sec_code)){
|
|
|
+ if (!checkCodeInput(sec_code)) {
|
|
|
return;
|
|
|
}
|
|
|
- if(oldOrNew == 0){
|
|
|
+ if (oldOrNew == 0) {
|
|
|
JSONObject jsonObject = new JSONObject();
|
|
|
- jsonObject.put("mobile", mobile+"");
|
|
|
- jsonObject.put("sec_code", sec_code+"");
|
|
|
+ jsonObject.put("mobile", mobile + "");
|
|
|
+ jsonObject.put("sec_code", sec_code + "");
|
|
|
presenter.bindPhone(jsonObject);
|
|
|
return;
|
|
|
}
|
|
|
@@ -276,8 +289,8 @@ public class ChangeTelAct extends BaseActivity implements PhoneContract.View{
|
|
|
UMConfigUtils.onEvent(UMConfigUtils.Event.USER_BIND_PHONE);
|
|
|
break;
|
|
|
case R.id.sure_change_tv:
|
|
|
- sec_code = phone_et_code_old.getText().toString()+"";
|
|
|
- if(!checkCodeInput(sec_code)){
|
|
|
+ sec_code = phone_et_code_old.getText().toString() + "";
|
|
|
+ if (!checkCodeInput(sec_code)) {
|
|
|
return;
|
|
|
}
|
|
|
step = 2;
|
|
|
@@ -298,10 +311,10 @@ public class ChangeTelAct extends BaseActivity implements PhoneContract.View{
|
|
|
/**
|
|
|
* 提交
|
|
|
*/
|
|
|
- private void submit(){
|
|
|
+ private void submit() {
|
|
|
JSONObject jsonObject = new JSONObject();
|
|
|
- jsonObject.put("step", step+"");
|
|
|
- switch (step){
|
|
|
+ jsonObject.put("step", step + "");
|
|
|
+ switch (step) {
|
|
|
case 1:
|
|
|
|
|
|
selfCountDownTimer.reset(SelfCountDownTimer.FULL_SECOND);
|
|
|
@@ -309,19 +322,19 @@ public class ChangeTelAct extends BaseActivity implements PhoneContract.View{
|
|
|
selfCountDownTimer.start();
|
|
|
break;
|
|
|
case 2:
|
|
|
- jsonObject.put("sec_code", sec_code+"");
|
|
|
+ jsonObject.put("sec_code", sec_code + "");
|
|
|
break;
|
|
|
case 3:
|
|
|
- jsonObject.put("auth_code", auth_code+"");
|
|
|
- jsonObject.put("mobile", mobile+"");
|
|
|
+ jsonObject.put("auth_code", auth_code + "");
|
|
|
+ jsonObject.put("mobile", mobile + "");
|
|
|
selfCountDownTimer.reset(SelfCountDownTimer.FULL_SECOND);
|
|
|
canGetCaptchaPhone = false;
|
|
|
selfCountDownTimer.start();
|
|
|
break;
|
|
|
case 4:
|
|
|
- jsonObject.put("sec_code", sec_code+"");
|
|
|
- jsonObject.put("auth_code", auth_code+"");
|
|
|
- jsonObject.put("mobile", mobile+"");
|
|
|
+ jsonObject.put("sec_code", sec_code + "");
|
|
|
+ jsonObject.put("auth_code", auth_code + "");
|
|
|
+ jsonObject.put("mobile", mobile + "");
|
|
|
break;
|
|
|
}
|
|
|
presenter.switchPhone(jsonObject);
|
|
|
@@ -350,67 +363,68 @@ public class ChangeTelAct extends BaseActivity implements PhoneContract.View{
|
|
|
|
|
|
@Override
|
|
|
public void changeTelSuccess(BaseMessage o) {
|
|
|
- try{
|
|
|
+ try {
|
|
|
// if(step == 1 || step == 3){
|
|
|
// changeTelSuccess
|
|
|
// }
|
|
|
- if(step == 2){
|
|
|
+ if (step == 2) {
|
|
|
oldOrNew = 1;
|
|
|
|
|
|
// handler.sendEmptyMessage(CHANGGE_CLICK);
|
|
|
refreshData();
|
|
|
phoneBtnCode.setText(getString(R.string.get_captcha));
|
|
|
canGetCaptchaPhone = true;
|
|
|
- if(selfCountDownTimer != null)
|
|
|
+ if (selfCountDownTimer != null)
|
|
|
selfCountDownTimer.reset(SelfCountDownTimer.FULL_SECOND);
|
|
|
- }else if(step == 4){
|
|
|
+ } else if (step == 4) {
|
|
|
DataUtil.getInstance().setUserMobile(mobile);
|
|
|
G.showToast(o);
|
|
|
CommonUtil.getInstance().updateUserInfo(null);
|
|
|
finish();
|
|
|
}
|
|
|
- if(o == null){
|
|
|
+ if (o == null) {
|
|
|
G.showToast("网络错误");
|
|
|
return;
|
|
|
}
|
|
|
- if(o.getData() == null || o.getData().equals("")){
|
|
|
+ if (o.getData() == null || o.getData().equals("")) {
|
|
|
// G.showToast(o.getMsg()+"");
|
|
|
return;
|
|
|
}
|
|
|
- G.showToast((o.getMsg()).equals("")?"提交成功":o.getMsg()+"");
|
|
|
+ G.showToast((o.getMsg()).equals("") ? "提交成功" : o.getMsg() + "");
|
|
|
JSONObject jsonObject = JSONObject.parseObject(JSONObject.toJSONString(o.getData()));
|
|
|
auth_code = jsonObject.getString("auth_code");
|
|
|
- }catch (Exception e){
|
|
|
+ } catch (Exception e) {
|
|
|
e.printStackTrace();
|
|
|
}
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
public void changeTelFail(BaseMessage o) {
|
|
|
- if(o == null){
|
|
|
+ if (o == null) {
|
|
|
G.showToast("网络错误");
|
|
|
return;
|
|
|
}
|
|
|
- G.showToast(o.getMsg()+"");
|
|
|
+ G.showToast(o.getMsg() + "");
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
public void bindTelSuccess(BaseMessage o) {
|
|
|
G.showToast(o);
|
|
|
- switch (where_from){
|
|
|
+ switch (where_from) {
|
|
|
case FROM_LOGIN:
|
|
|
case 30001:
|
|
|
Jump2View.getInstance().checkLabel(activity, new Action1<BaseMessage>() {
|
|
|
@Override
|
|
|
public void call(BaseMessage baseMessage) {
|
|
|
- Intent intent = new Intent(activity, ActMain.class);
|
|
|
- activity.startActivity(intent);
|
|
|
- activity.finish();
|
|
|
+// Intent intent = new Intent(activity, ActMain.class);
|
|
|
+// activity.startActivity(intent);
|
|
|
+// activity.finish();
|
|
|
+ startMainAct();
|
|
|
}
|
|
|
});
|
|
|
break;
|
|
|
case FROM_SPLASH://非第一次登录(如:登录后直接重启),老用户需要绑定手机号
|
|
|
- Intent intent = new Intent(activity, ActMain.class);
|
|
|
+ Intent intent = new Intent(activity, ActMain.class).setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
|
|
|
startActivity(intent);
|
|
|
default:
|
|
|
finish();
|
|
|
@@ -420,7 +434,7 @@ public class ChangeTelAct extends BaseActivity implements PhoneContract.View{
|
|
|
|
|
|
@Override
|
|
|
public void bindTelFail(BaseMessage o) {
|
|
|
- G.showToast(o.getMsg()+"");
|
|
|
+ G.showToast(o.getMsg() + "");
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
@@ -447,6 +461,7 @@ public class ChangeTelAct extends BaseActivity implements PhoneContract.View{
|
|
|
}
|
|
|
return true;
|
|
|
}
|
|
|
+
|
|
|
private boolean checkCodeInput(String etCode) {
|
|
|
if (TextUtils.isEmpty(etCode)) {
|
|
|
G.showToast(getString(R.string.input_your_captcha));
|
|
|
@@ -467,10 +482,11 @@ public class ChangeTelAct extends BaseActivity implements PhoneContract.View{
|
|
|
@Override
|
|
|
protected void onDestroy() {
|
|
|
super.onDestroy();
|
|
|
- if(selfCountDownTimer != null){
|
|
|
+ if (selfCountDownTimer != null) {
|
|
|
selfCountDownTimer.cancel();
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
public static final int FROM_LOGIN = 1;//第一次登录,老用户需要绑定手机号
|
|
|
public static final int FROM_SPLASH = 2;//非第一次登录(如:登录后直接重启),老用户需要绑定手机号
|
|
|
}
|