|
@@ -17,12 +17,17 @@ import com.cooleshow.base.router.RouterPath;
|
|
import com.cooleshow.base.ui.activity.BaseMVPActivity;
|
|
import com.cooleshow.base.ui.activity.BaseMVPActivity;
|
|
import com.cooleshow.base.utils.ToastUtil;
|
|
import com.cooleshow.base.utils.ToastUtil;
|
|
import com.cooleshow.base.utils.ToastUtils;
|
|
import com.cooleshow.base.utils.ToastUtils;
|
|
|
|
+import com.cooleshow.base.widgets.dialog.ImgVerifyCodeDialog;
|
|
import com.cooleshow.student.R;
|
|
import com.cooleshow.student.R;
|
|
import com.cooleshow.student.contract.ModifyPhoneNumContract;
|
|
import com.cooleshow.student.contract.ModifyPhoneNumContract;
|
|
import com.cooleshow.student.databinding.ActivityModifyPhonenumBinding;
|
|
import com.cooleshow.student.databinding.ActivityModifyPhonenumBinding;
|
|
import com.cooleshow.student.presenter.mine.ModifyPhoneNumPresenter;
|
|
import com.cooleshow.student.presenter.mine.ModifyPhoneNumPresenter;
|
|
|
|
+import com.cooleshow.usercenter.bean.SetDetailBean;
|
|
|
|
|
|
|
|
|
|
|
|
+import org.json.JSONException;
|
|
|
|
+import org.json.JSONObject;
|
|
|
|
+
|
|
import java.util.Timer;
|
|
import java.util.Timer;
|
|
import java.util.TimerTask;
|
|
import java.util.TimerTask;
|
|
|
|
|
|
@@ -36,34 +41,45 @@ import io.rong.imkit.utils.StatusBarUtil;
|
|
*/
|
|
*/
|
|
@Route(path = RouterPath.MineCenter.MINE_MODIFY_PHONENUM)
|
|
@Route(path = RouterPath.MineCenter.MINE_MODIFY_PHONENUM)
|
|
public class ModifyPhoneNumActivity extends BaseMVPActivity<ActivityModifyPhonenumBinding, ModifyPhoneNumPresenter> implements ModifyPhoneNumContract.ModifyPhoneNumView, View.OnClickListener {
|
|
public class ModifyPhoneNumActivity extends BaseMVPActivity<ActivityModifyPhonenumBinding, ModifyPhoneNumPresenter> implements ModifyPhoneNumContract.ModifyPhoneNumView, View.OnClickListener {
|
|
|
|
+
|
|
|
|
+ private ImgVerifyCodeDialog mImgVerifyCodeDialog;
|
|
|
|
+
|
|
@Override
|
|
@Override
|
|
public void onClick(View view) {
|
|
public void onClick(View view) {
|
|
- switch (view.getId()){
|
|
|
|
|
|
+ switch (view.getId()) {
|
|
case R.id.tv_get_auth_code:
|
|
case R.id.tv_get_auth_code:
|
|
- getCodeSuccess();
|
|
|
|
|
|
+ String phone = viewBinding.etPhoneNum.getText().toString().trim();
|
|
|
|
+ if (TextUtils.isEmpty(phone)) {
|
|
|
|
+ ToastUtil.getInstance().showShort("请输入手机号");
|
|
|
|
+ break;
|
|
|
|
+ }
|
|
|
|
+ showImgVerifyCodeDialog(phone);
|
|
break;
|
|
break;
|
|
case R.id.tv_save:
|
|
case R.id.tv_save:
|
|
String phoneNum = viewBinding.etPhoneNum.getText().toString().trim();
|
|
String phoneNum = viewBinding.etPhoneNum.getText().toString().trim();
|
|
- if (TextUtils.isEmpty(phoneNum)){
|
|
|
|
|
|
+ if (TextUtils.isEmpty(phoneNum)) {
|
|
ToastUtil.getInstance().showShort("请输入手机号");
|
|
ToastUtil.getInstance().showShort("请输入手机号");
|
|
break;
|
|
break;
|
|
}
|
|
}
|
|
String authCode = viewBinding.etAuthCode.getText().toString().trim();
|
|
String authCode = viewBinding.etAuthCode.getText().toString().trim();
|
|
- if (TextUtils.isEmpty(authCode)){
|
|
|
|
|
|
+ if (TextUtils.isEmpty(authCode)) {
|
|
ToastUtil.getInstance().showShort("请输入验证码");
|
|
ToastUtil.getInstance().showShort("请输入验证码");
|
|
break;
|
|
break;
|
|
}
|
|
}
|
|
- presenter.updatePhone(oldPhone,phoneNum,authCode);
|
|
|
|
|
|
+ presenter.updatePhone(oldPhone, phoneNum, authCode);
|
|
break;
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
+
|
|
@Override
|
|
@Override
|
|
protected void onCreate(@Nullable Bundle savedInstanceState) {
|
|
protected void onCreate(@Nullable Bundle savedInstanceState) {
|
|
super.onCreate(savedInstanceState);
|
|
super.onCreate(savedInstanceState);
|
|
StatusBarUtil.setStatusBarDarkTheme(this, true);
|
|
StatusBarUtil.setStatusBarDarkTheme(this, true);
|
|
}
|
|
}
|
|
|
|
+
|
|
@Autowired(name = "oldPhone")
|
|
@Autowired(name = "oldPhone")
|
|
String oldPhone;
|
|
String oldPhone;
|
|
|
|
+
|
|
@Override
|
|
@Override
|
|
protected void initView() {
|
|
protected void initView() {
|
|
ARouter.getInstance().inject(this);
|
|
ARouter.getInstance().inject(this);
|
|
@@ -72,6 +88,24 @@ public class ModifyPhoneNumActivity extends BaseMVPActivity<ActivityModifyPhonen
|
|
viewBinding.tvSave.setOnClickListener(this);
|
|
viewBinding.tvSave.setOnClickListener(this);
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ private void showImgVerifyCodeDialog(String phone) {
|
|
|
|
+ if (mImgVerifyCodeDialog == null) {
|
|
|
|
+ mImgVerifyCodeDialog = new ImgVerifyCodeDialog(ModifyPhoneNumActivity.this);
|
|
|
|
+ }
|
|
|
|
+ if (!mImgVerifyCodeDialog.isShowing()) {
|
|
|
|
+ mImgVerifyCodeDialog.show();
|
|
|
|
+ }
|
|
|
|
+ mImgVerifyCodeDialog.setPhone(phone);
|
|
|
|
+ mImgVerifyCodeDialog.setOnEventListener(new ImgVerifyCodeDialog.OnEventListener() {
|
|
|
|
+ @Override
|
|
|
|
+ public void onVerifyImgCode(String phone, String imgCode) {
|
|
|
|
+ if (presenter != null) {
|
|
|
|
+ presenter.verifyImgCode(phone, imgCode);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ });
|
|
|
|
+ }
|
|
|
|
+
|
|
@Override
|
|
@Override
|
|
protected ActivityModifyPhonenumBinding getLayoutView() {
|
|
protected ActivityModifyPhonenumBinding getLayoutView() {
|
|
return ActivityModifyPhonenumBinding.inflate(getLayoutInflater());
|
|
return ActivityModifyPhonenumBinding.inflate(getLayoutInflater());
|
|
@@ -84,12 +118,39 @@ public class ModifyPhoneNumActivity extends BaseMVPActivity<ActivityModifyPhonen
|
|
|
|
|
|
@Override
|
|
@Override
|
|
public void updatePhoneSuccess(Object object) {
|
|
public void updatePhoneSuccess(Object object) {
|
|
- Intent intent=new Intent();
|
|
|
|
- intent.putExtra("newPhoneNum",viewBinding.etPhoneNum.getText().toString().trim());
|
|
|
|
- setResult(RESULT_OK,intent);
|
|
|
|
|
|
+ Intent intent = new Intent();
|
|
|
|
+ intent.putExtra("newPhoneNum", viewBinding.etPhoneNum.getText().toString().trim());
|
|
|
|
+ setResult(RESULT_OK, intent);
|
|
finish();
|
|
finish();
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ @Override
|
|
|
|
+ public void verifyImgCodeSuccess(String phone) {
|
|
|
|
+ if (!checkActivityExist()) {
|
|
|
|
+ return;
|
|
|
|
+ }
|
|
|
|
+ if (mImgVerifyCodeDialog != null) {
|
|
|
|
+ mImgVerifyCodeDialog.dismiss();
|
|
|
|
+ }
|
|
|
|
+ sendSmsCode(phone);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ @Override
|
|
|
|
+ public void sendSmsCodeSuccess(SetDetailBean setDetailBean) {
|
|
|
|
+ getCodeSuccess();
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ private void sendSmsCode(String phone) {
|
|
|
|
+ JSONObject jsonObject = new JSONObject();
|
|
|
|
+ try {
|
|
|
|
+ jsonObject.putOpt("mobile", phone);
|
|
|
|
+ jsonObject.putOpt("type", "PHONE");
|
|
|
|
+ } catch (JSONException e) {
|
|
|
|
+ e.printStackTrace();
|
|
|
|
+ }
|
|
|
|
+ presenter.sendSmsCode(jsonObject.toString());
|
|
|
|
+ }
|
|
|
|
+
|
|
public void getCodeSuccess() {
|
|
public void getCodeSuccess() {
|
|
ToastUtil.getInstance().showShort("验证码发送成功,请注意查收!");
|
|
ToastUtil.getInstance().showShort("验证码发送成功,请注意查收!");
|
|
startTimer();
|
|
startTimer();
|
|
@@ -169,6 +230,8 @@ public class ModifyPhoneNumActivity extends BaseMVPActivity<ActivityModifyPhonen
|
|
@Override
|
|
@Override
|
|
public void onDestroy() {
|
|
public void onDestroy() {
|
|
super.onDestroy();
|
|
super.onDestroy();
|
|
- handler.removeCallbacksAndMessages(EXECUTE_LOADING);
|
|
|
|
|
|
+ if (handler != null) {
|
|
|
|
+ handler.removeCallbacksAndMessages(null);
|
|
|
|
+ }
|
|
}
|
|
}
|
|
}
|
|
}
|