|
@@ -1,17 +1,59 @@
|
|
package com.cooleshow.teacher.ui.mine;
|
|
package com.cooleshow.teacher.ui.mine;
|
|
|
|
|
|
|
|
+import android.os.Handler;
|
|
|
|
+import android.os.Looper;
|
|
|
|
+import android.text.SpannableString;
|
|
import android.text.TextUtils;
|
|
import android.text.TextUtils;
|
|
|
|
+import android.view.View;
|
|
|
|
|
|
|
|
+import com.alibaba.android.arouter.facade.annotation.Route;
|
|
|
|
+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.UiUtils;
|
|
|
|
+import com.cooleshow.base.widgets.dialog.CommonDialog;
|
|
|
|
+import com.cooleshow.base.widgets.dialog.ImgVerifyCodeDialog;
|
|
|
|
+import com.cooleshow.teacher.R;
|
|
|
|
+import com.cooleshow.teacher.bean.UnBindTenantDetailBean;
|
|
|
|
+import com.cooleshow.teacher.contract.UnbindTenantContract;
|
|
import com.cooleshow.teacher.databinding.AcUnbindTenantLayoutBinding;
|
|
import com.cooleshow.teacher.databinding.AcUnbindTenantLayoutBinding;
|
|
import com.cooleshow.teacher.presenter.mine.UnbindTenantPresenter;
|
|
import com.cooleshow.teacher.presenter.mine.UnbindTenantPresenter;
|
|
|
|
+import com.cooleshow.usercenter.constants.UserConstants;
|
|
import com.cooleshow.usercenter.helper.UserHelper;
|
|
import com.cooleshow.usercenter.helper.UserHelper;
|
|
|
|
+import com.cooleshow.usercenter.ui.activity.setting.SignOutAccountActivity;
|
|
|
|
|
|
/**
|
|
/**
|
|
* Author by pq, Date on 2023/9/14.
|
|
* Author by pq, Date on 2023/9/14.
|
|
*/
|
|
*/
|
|
-public class UnBindTenantActivity extends BaseMVPActivity<AcUnbindTenantLayoutBinding, UnbindTenantPresenter> {
|
|
|
|
|
|
+@Route(path = RouterPath.MineCenter.UNBIND_TENANT)
|
|
|
|
+public class UnBindTenantActivity extends BaseMVPActivity<AcUnbindTenantLayoutBinding, UnbindTenantPresenter> implements UnbindTenantContract.View, View.OnClickListener {
|
|
private String mPhoneNum;
|
|
private String mPhoneNum;
|
|
|
|
+ private int countTimeValue = UserConstants.VERIFY_CODE_COUNT_TIME;
|
|
|
|
+ private Handler mHandler = new Handler(Looper.getMainLooper());
|
|
|
|
+ public static final String DOING = "DOING";
|
|
|
|
+ public static final String PASS = "PASS";
|
|
|
|
+ public static final String UNPASS = "UNPASS";
|
|
|
|
+ private boolean isOnApply = false;
|
|
|
|
+ private ImgVerifyCodeDialog mImgVerifyCodeDialog;
|
|
|
|
+ Runnable mRunnable = new Runnable() {
|
|
|
|
+ @Override
|
|
|
|
+ public void run() {
|
|
|
|
+ countTimeValue--;
|
|
|
|
+ viewBinding.tvSendVerifyCode.setText(countTimeValue + "s");
|
|
|
|
+ viewBinding.tvSendVerifyCode.setClickable(false);
|
|
|
|
+ if (countTimeValue < 0) {
|
|
|
|
+ resetBt();
|
|
|
|
+ } else {
|
|
|
|
+ mHandler.postDelayed(mRunnable, 1000);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ };
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ private void resetBt() {
|
|
|
|
+ viewBinding.tvSendVerifyCode.setClickable(true);
|
|
|
|
+ viewBinding.tvSendVerifyCode.setText("获取验证码");
|
|
|
|
+ }
|
|
|
|
|
|
@Override
|
|
@Override
|
|
protected void initView() {
|
|
protected void initView() {
|
|
@@ -27,16 +69,38 @@ public class UnBindTenantActivity extends BaseMVPActivity<AcUnbindTenantLayoutBi
|
|
finish();
|
|
finish();
|
|
return;
|
|
return;
|
|
}
|
|
}
|
|
|
|
+ presenter.queryUnBindDetail();
|
|
try {
|
|
try {
|
|
String cPhone = mPhoneNum.substring(0, 3) + "****" + mPhoneNum.substring(7, mPhoneNum.length());
|
|
String cPhone = mPhoneNum.substring(0, 3) + "****" + mPhoneNum.substring(7, mPhoneNum.length());
|
|
viewBinding.tvTitle.setText(String.format("将%s所绑定的机构解绑", cPhone));
|
|
viewBinding.tvTitle.setText(String.format("将%s所绑定的机构解绑", cPhone));
|
|
|
|
+ String tenantName = UserHelper.getTenantName();
|
|
|
|
+ SpannableString spannableString = UiUtils.diffColorString("解绑机构后,在此机构的数据将无法恢复,确认要继续解绑", tenantName, "吗?", getResources().getColor(com.dayayuemeng.classroom.R.color.color_777777), getResources().getColor(com.cooleshow.base.R.color.color_ff5a56));
|
|
|
|
+ viewBinding.tvTip.setText(spannableString);
|
|
} catch (Exception e) {
|
|
} catch (Exception e) {
|
|
e.printStackTrace();
|
|
e.printStackTrace();
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
private void initListener() {
|
|
private void initListener() {
|
|
|
|
+ viewBinding.tvConfirm.setOnClickListener(this);
|
|
|
|
+ }
|
|
|
|
|
|
|
|
+ private void showImgVerifyCodeDialog() {
|
|
|
|
+ if (mImgVerifyCodeDialog == null) {
|
|
|
|
+ mImgVerifyCodeDialog = new ImgVerifyCodeDialog(UnBindTenantActivity.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);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ });
|
|
}
|
|
}
|
|
|
|
|
|
@Override
|
|
@Override
|
|
@@ -48,4 +112,124 @@ public class UnBindTenantActivity extends BaseMVPActivity<AcUnbindTenantLayoutBi
|
|
protected UnbindTenantPresenter createPresenter() {
|
|
protected UnbindTenantPresenter createPresenter() {
|
|
return new UnbindTenantPresenter();
|
|
return new UnbindTenantPresenter();
|
|
}
|
|
}
|
|
|
|
+
|
|
|
|
+ @Override
|
|
|
|
+ public void onDestroy() {
|
|
|
|
+ super.onDestroy();
|
|
|
|
+ if (mHandler != null) {
|
|
|
|
+ mHandler.removeCallbacksAndMessages(null);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ @Override
|
|
|
|
+ public void verifyImgCodeSuccess(String phone) {
|
|
|
|
+ if (isFinishing() || isDestroyed()) {
|
|
|
|
+ return;
|
|
|
|
+ }
|
|
|
|
+ if (mImgVerifyCodeDialog != null) {
|
|
|
|
+ mImgVerifyCodeDialog.dismiss();
|
|
|
|
+ }
|
|
|
|
+ presenter.sendSmsCode(mPhoneNum);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ @Override
|
|
|
|
+ public void sendVerifyCodeSuccess() {
|
|
|
|
+ ToastUtil.getInstance().showShort("验证码发送成功,请注意查收!");
|
|
|
|
+ startTimer();
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ private void startTimer() {
|
|
|
|
+ countTimeValue = UserConstants.VERIFY_CODE_COUNT_TIME;
|
|
|
|
+ mHandler.removeCallbacksAndMessages(null);
|
|
|
|
+ mHandler.postDelayed(mRunnable, 1000);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ @Override
|
|
|
|
+ public void sendVerifyCodeFail() {
|
|
|
|
+ if (isFinishing() || isDestroyed()) {
|
|
|
|
+ return;
|
|
|
|
+ }
|
|
|
|
+ if (mHandler != null) {
|
|
|
|
+ mHandler.removeCallbacksAndMessages(null);
|
|
|
|
+ }
|
|
|
|
+ resetBt();
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ @Override
|
|
|
|
+ public void unBindTenantSubmitSuccess() {
|
|
|
|
+ if (!checkActivityExist()) {
|
|
|
|
+ return;
|
|
|
|
+ }
|
|
|
|
+ presenter.queryUnBindDetail();
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ @Override
|
|
|
|
+ public void cancelUnbindApplySuccess() {
|
|
|
|
+ if (!checkActivityExist()) {
|
|
|
|
+ return;
|
|
|
|
+ }
|
|
|
|
+ presenter.queryUnBindDetail();
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ @Override
|
|
|
|
+ public void queryDetailSuccess(UnBindTenantDetailBean data) {
|
|
|
|
+ if (!checkActivityExist()) {
|
|
|
|
+ return;
|
|
|
|
+ }
|
|
|
|
+ if (data != null) {
|
|
|
|
+ String status = data.getStatus();
|
|
|
|
+ isOnApply = TextUtils.equals(status, DOING);
|
|
|
|
+ viewBinding.tvConfirm.setVisibility(View.VISIBLE);
|
|
|
|
+ viewBinding.scrollView.setVisibility(isOnApply ? View.GONE : View.VISIBLE);
|
|
|
|
+ viewBinding.csUnbindDetail.setVisibility(isOnApply ? View.VISIBLE : View.GONE);
|
|
|
|
+ viewBinding.tvConfirm.setText(isOnApply ? "撤回解绑" : "确认解绑");
|
|
|
|
+ viewBinding.tvReason.setText(data.getReason());
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ @Override
|
|
|
|
+ public void onClick(View v) {
|
|
|
|
+ int id = v.getId();
|
|
|
|
+ if (id == R.id.tv_confirm) {
|
|
|
|
+ if (isOnApply) {
|
|
|
|
+ //撤销申请
|
|
|
|
+ presenter.cancelApply();
|
|
|
|
+ } else {
|
|
|
|
+ //提交申请
|
|
|
|
+ viewBinding.etNum.getText().toString();
|
|
|
|
+ }
|
|
|
|
+ return;
|
|
|
|
+ }
|
|
|
|
+ if (id == R.id.tv_send_verify_code) {
|
|
|
|
+ showImgVerifyCodeDialog();
|
|
|
|
+ return;
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ private void showConfirmDialog() {
|
|
|
|
+ String authCode = viewBinding.etNum.getText().toString().trim();
|
|
|
|
+ if (TextUtils.isEmpty(authCode)) {
|
|
|
|
+ ToastUtil.getInstance().showShort("请输入验证码");
|
|
|
|
+ return;
|
|
|
|
+ }
|
|
|
|
+ String reason = viewBinding.etContent.getText().toString().trim();
|
|
|
|
+ CommonDialog commonConfirmDialog = new CommonDialog(this);
|
|
|
|
+ commonConfirmDialog.show();
|
|
|
|
+ commonConfirmDialog.setTitle("提示");
|
|
|
|
+ commonConfirmDialog.setContent("确认解绑机构?");
|
|
|
|
+ commonConfirmDialog.setOnConfirmClickListener(new View.OnClickListener() {
|
|
|
|
+ @Override
|
|
|
|
+ public void onClick(View v) {
|
|
|
|
+ presenter.unBind(authCode, reason);
|
|
|
|
+ commonConfirmDialog.dismiss();
|
|
|
|
+ }
|
|
|
|
+ });
|
|
|
|
+ commonConfirmDialog.setOnCancelClickListener(new View.OnClickListener() {
|
|
|
|
+ @Override
|
|
|
|
+ public void onClick(View v) {
|
|
|
|
+ commonConfirmDialog.dismiss();
|
|
|
|
+ }
|
|
|
|
+ });
|
|
|
|
+ }
|
|
}
|
|
}
|