|
@@ -1,24 +1,55 @@
|
|
|
package com.cooleshow.usercenter.ui.activity.setting;
|
|
|
|
|
|
import android.os.Bundle;
|
|
|
+import android.os.CountDownTimer;
|
|
|
+import android.os.Handler;
|
|
|
import android.text.TextUtils;
|
|
|
import android.view.View;
|
|
|
|
|
|
+import com.alibaba.android.arouter.facade.annotation.Route;
|
|
|
+import com.alibaba.android.arouter.launcher.ARouter;
|
|
|
import com.cooleshow.base.constanst.StyleConfig;
|
|
|
+import com.cooleshow.base.router.RouterPath;
|
|
|
import com.cooleshow.base.ui.activity.BaseMVPActivity;
|
|
|
+import com.cooleshow.base.utils.ToastUtil;
|
|
|
+import com.cooleshow.base.utils.UiUtils;
|
|
|
import com.cooleshow.base.utils.helper.QMUIStatusBarHelper;
|
|
|
+import com.cooleshow.base.widgets.dialog.ImgVerifyCodeDialog;
|
|
|
+import com.cooleshow.usercenter.R;
|
|
|
+import com.cooleshow.usercenter.bean.SetDetailBean;
|
|
|
import com.cooleshow.usercenter.databinding.AcForgetPwdLayoutBinding;
|
|
|
import com.cooleshow.usercenter.helper.UserHelper;
|
|
|
import com.cooleshow.usercenter.presenter.ForgetPasswordPresenter;
|
|
|
import com.cooleshow.usercenter.presenter.contract.ForgetPasswordContract;
|
|
|
|
|
|
+import java.util.HashMap;
|
|
|
+import java.util.Map;
|
|
|
+
|
|
|
import androidx.annotation.Nullable;
|
|
|
|
|
|
/**
|
|
|
* Author by pq, Date on 2023/9/26.
|
|
|
*/
|
|
|
+@Route(path = RouterPath.UserCenter.FORGET_PASSWORD)
|
|
|
public class ForgetPasswordActivity extends BaseMVPActivity<AcForgetPwdLayoutBinding, ForgetPasswordPresenter> implements ForgetPasswordContract.View, View.OnClickListener {
|
|
|
|
|
|
+ private ImgVerifyCodeDialog mImgVerifyCodeDialog;
|
|
|
+ private String mPhoneNum;
|
|
|
+
|
|
|
+
|
|
|
+ CountDownTimer mDownTimer = new CountDownTimer(60000, 1000) {
|
|
|
+ @Override
|
|
|
+ public void onTick(long millisUntilFinished) {
|
|
|
+ int untilTime = (int) (millisUntilFinished / 1000);
|
|
|
+ updateTimeCountText(String.valueOf(untilTime));
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void onFinish() {
|
|
|
+ resetCount();
|
|
|
+ }
|
|
|
+ };
|
|
|
+
|
|
|
@Override
|
|
|
protected void onCreate(@Nullable Bundle savedInstanceState) {
|
|
|
StyleConfig.setTheme(this);
|
|
@@ -28,13 +59,16 @@ public class ForgetPasswordActivity extends BaseMVPActivity<AcForgetPwdLayoutBin
|
|
|
|
|
|
@Override
|
|
|
protected void initView() {
|
|
|
- initMidTitleToolBar(viewBinding.toolbarInclude.toolbar, "修改密码");
|
|
|
- String phoneNum = UserHelper.getUserPhone();
|
|
|
- if (!TextUtils.isEmpty(phoneNum)) {
|
|
|
- String cPhone = phoneNum.substring(0, 3) + "****" + phoneNum.substring(7, phoneNum.length());
|
|
|
- viewBinding.tvPhone.setText(cPhone);
|
|
|
+ initMidTitleToolBar(viewBinding.toolbarInclude.toolbar, "忘记密码");
|
|
|
+ mPhoneNum = UserHelper.getUserPhone();
|
|
|
+ if (!TextUtils.isEmpty(mPhoneNum)) {
|
|
|
+ try {
|
|
|
+ String cPhone = mPhoneNum.substring(0, 3) + "****" + mPhoneNum.substring(7, mPhoneNum.length());
|
|
|
+ viewBinding.tvPhone.setText(cPhone);
|
|
|
+ } catch (Exception e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ }
|
|
|
}
|
|
|
-
|
|
|
}
|
|
|
|
|
|
@Override
|
|
@@ -60,6 +94,98 @@ public class ForgetPasswordActivity extends BaseMVPActivity<AcForgetPwdLayoutBin
|
|
|
|
|
|
@Override
|
|
|
public void onClick(View v) {
|
|
|
+ if (UiUtils.isFastClick()) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ int id = v.getId();
|
|
|
+ if (id == R.id.tv_get_auth_code) {
|
|
|
+ showImgVerifyCodeDialog();
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ if (id == R.id.tv_confirm) {
|
|
|
+ String code = viewBinding.etAuthCode.getText().toString().trim();
|
|
|
+ if (TextUtils.isEmpty(code)) {
|
|
|
+ ToastUtil.getInstance().showShort("请输入验证码");
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ presenter.checkSmsCode(code);
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ private void showImgVerifyCodeDialog() {
|
|
|
+ if (mImgVerifyCodeDialog == null) {
|
|
|
+ mImgVerifyCodeDialog = new ImgVerifyCodeDialog(this);
|
|
|
+ }
|
|
|
+ if (!mImgVerifyCodeDialog.isShowing()) {
|
|
|
+ mImgVerifyCodeDialog.show();
|
|
|
+ }
|
|
|
+ mImgVerifyCodeDialog.setPhone(mPhoneNum);
|
|
|
+ mImgVerifyCodeDialog.setOnEventListener(new ImgVerifyCodeDialog.OnEventListener() {
|
|
|
+ @Override
|
|
|
+ public void onVerifyImgCode(String phone, String imgCode) {
|
|
|
+ if (presenter != null) {
|
|
|
+ presenter.verifyImgCode(phone, imgCode);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ });
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ private void updateTimeCountText(String time) {
|
|
|
+ viewBinding.tvGetAuthCode.setText(String.format("%ss", time));
|
|
|
+ viewBinding.tvGetAuthCode.setClickable(false);
|
|
|
+ }
|
|
|
|
|
|
+ private void resetCount() {
|
|
|
+ viewBinding.tvGetAuthCode.setClickable(true);
|
|
|
+ viewBinding.tvGetAuthCode.setText("获取验证码");
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void verifyImgCodeSuccess(String phone) {
|
|
|
+ if (!checkActivityExist()) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ if (mImgVerifyCodeDialog != null) {
|
|
|
+ mImgVerifyCodeDialog.dismiss();
|
|
|
+ }
|
|
|
+ Map<String, String> map = new HashMap<>();
|
|
|
+ map.put("mobile", phone);
|
|
|
+ map.put("type", "PASSWD");
|
|
|
+ presenter.sendSmsCode(map);
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void sendSmsCodeSuccess(SetDetailBean data) {
|
|
|
+ if (!checkActivityExist()) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ ToastUtil.getInstance().showShort("验证码发送成功,请注意查收!");
|
|
|
+ if (mDownTimer != null) {
|
|
|
+ mDownTimer.cancel();
|
|
|
+ mDownTimer.start();
|
|
|
+ viewBinding.tvGetAuthCode.setClickable(false);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void checkSmsCodeSuccess() {
|
|
|
+ if (!checkActivityExist()) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ ARouter.getInstance().build(RouterPath.MineCenter.MINE_MODIFY_PASSWORD)
|
|
|
+ .withString("phoneNum", UserHelper.getUserPhone())
|
|
|
+ .withBoolean("isNeedSmsCode", false)
|
|
|
+ .navigation();
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void onDestroy() {
|
|
|
+ super.onDestroy();
|
|
|
+ if (mDownTimer != null) {
|
|
|
+ mDownTimer.cancel();
|
|
|
+ mDownTimer = null;
|
|
|
+ }
|
|
|
}
|
|
|
}
|