| | |
| | | |
| | | import android.os.Bundle; |
| | | import android.os.CountDownTimer; |
| | | import android.text.Editable; |
| | | import android.text.TextUtils; |
| | | import android.text.TextWatcher; |
| | | import android.view.View; |
| | | |
| | | import com.hdl.linkpm.sdk.core.exception.HDLException; |
| | |
| | | import com.hdl.photovoltaic.base.CustomBaseActivity; |
| | | import com.hdl.photovoltaic.config.UserConfigManage; |
| | | import com.hdl.photovoltaic.databinding.ActivityBindMailBinding; |
| | | import com.hdl.photovoltaic.enums.VerifyType; |
| | | import com.hdl.photovoltaic.listener.CloudCallBeak; |
| | | import com.hdl.photovoltaic.other.HdlAccountLogic; |
| | | import com.hdl.photovoltaic.other.HdlCommonLogic; |
| | | import com.hdl.photovoltaic.other.HdlLogLogic; |
| | | import com.hdl.photovoltaic.other.HdlThreadLogic; |
| | | |
| | |
| | | |
| | | @Override |
| | | public void onBindView(Bundle savedInstanceState) { |
| | | setNotificationBarBackgroundColor(CustomBaseActivity.CustomColor.white); |
| | | setStatusBarTextColor(); |
| | | setStatusBarTranslucent(); |
| | | getWindow().setNavigationBarColor(getColor(R.color.text_FF000000)); |
| | | //初始化 |
| | | initView(); |
| | | //初始化界面监听器 |
| | |
| | | viewBinding.bindMailEt.setText(""); |
| | | } |
| | | }); |
| | | //输入账号 |
| | | viewBinding.bindMailEt.addTextChangedListener(accountTextWatcher); |
| | | //输入验证码 |
| | | viewBinding.changeMailVerificationEt.addTextChangedListener(verificationCodeTextWatcher); |
| | | viewBinding.bindPhoneTv.setOnClickListener(new View.OnClickListener() { |
| | | @Override |
| | | public void onClick(View v) { |
| | | if (isLocalCheck()) { |
| | | if (isEnabled()) { |
| | | String mailStr = viewBinding.bindMailEt.getText().toString(); |
| | | String verificationStr = viewBinding.changeMailVerificationEt.getText().toString(); |
| | | HdlAccountLogic.getInstance().bindingAccount_C("", mailStr, verificationStr, new CloudCallBeak<Boolean>() { |
| | | HdlAccountLogic.getInstance().bindingAccount_C("", mailStr, verificationStr,"", new CloudCallBeak<Boolean>() { |
| | | @Override |
| | | public void onSuccess(Boolean obj) { |
| | | UserConfigManage.getInstance().setBingEmail(mailStr); |
| | |
| | | |
| | | private void initView() { |
| | | viewBinding.toolbarTopRl.topTitleTv.setText(R.string.set_change_bind_mail); |
| | | viewBinding.toolbarTopRl.topTitleTv.setTextColor(getResources().getColor(R.color.text_030D1C, null)); |
| | | viewBinding.toolbarTopRl.topBackLl.setVisibility(View.VISIBLE); |
| | | viewBinding.toolbarTopRl.topLeftIv.setImageResource(R.drawable.back_c); |
| | | viewBinding.toolbarTopRl.topBarView.setBackgroundColor(getResources().getColor(R.color.text_FFECECEC, null)); |
| | | checkClearIconShowOrNot(viewBinding.bindMailEt.getText().toString()); |
| | | HdlCommonLogic.getInstance().setSpan(viewBinding.bindMailVerificationTv, viewBinding.bindMailVerificationTv.getText().toString(), true, null); |
| | | } |
| | | |
| | | /** |
| | |
| | | HdlThreadLogic.tipFlashingBox(this, false, getString(R.string.home_login_mail_null), -1); |
| | | return; |
| | | } |
| | | HdlAccountLogic.getInstance().sendVerifyCode(false, account, "86", 3, new CloudCallBeak<Boolean>() { |
| | | HdlAccountLogic.getInstance().sendVerifyCode_C(false, account, "86", VerifyType.VerifyType_3, new CloudCallBeak<Boolean>() { |
| | | @Override |
| | | public void onSuccess(Boolean obj) { |
| | | countDownTimer.start(); |
| | |
| | | |
| | | } |
| | | |
| | | /** |
| | | * 检测清除图标是否显示 |
| | | */ |
| | | private void checkClearIconShowOrNot(String s) { |
| | | if (s.replace(" ", "").length() > 0) { |
| | | if (viewBinding.bindMailClearIv.getVisibility() == View.GONE) { |
| | | viewBinding.bindMailClearIv.setVisibility(View.VISIBLE); |
| | | } |
| | | } else { |
| | | if (viewBinding.bindMailClearIv.getVisibility() == View.VISIBLE) { |
| | | viewBinding.bindMailClearIv.setVisibility(View.GONE); |
| | | } |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 校验确认按钮是否启用 |
| | | */ |
| | | private boolean isEnabled() { |
| | | String account = viewBinding.bindMailEt.getText().toString().replace(" ", ""); |
| | | String verificationCode = viewBinding.changeMailVerificationEt.getText().toString().replace(" ", ""); |
| | | boolean isEnabled = account.length() > 0 && verificationCode.length() > 0; |
| | | if (isEnabled) { |
| | | viewBinding.bindPhoneTv.setTextColor(getColor(R.color.text_FFACACAC)); |
| | | } else { |
| | | viewBinding.bindPhoneTv.setTextColor(getColor(R.color.text_FF5B5B5B)); |
| | | } |
| | | viewBinding.bindPhoneTv.setEnabled(isEnabled); |
| | | return isEnabled; |
| | | |
| | | } |
| | | |
| | | /** |
| | | * 输入账号 |
| | | */ |
| | | private final TextWatcher accountTextWatcher = new TextWatcher() { |
| | | @Override |
| | | public void beforeTextChanged(CharSequence s, int start, int count, int after) { |
| | | |
| | | } |
| | | |
| | | @Override |
| | | public void onTextChanged(CharSequence s, int start, int before, int count) { |
| | | } |
| | | |
| | | @Override |
| | | public void afterTextChanged(Editable s) { |
| | | checkClearIconShowOrNot(s.toString()); |
| | | isEnabled(); |
| | | } |
| | | }; |
| | | |
| | | /** |
| | | * 输入验证码 |
| | | */ |
| | | private final TextWatcher verificationCodeTextWatcher = new TextWatcher() { |
| | | @Override |
| | | public void beforeTextChanged(CharSequence s, int start, int count, int after) { |
| | | |
| | | } |
| | | |
| | | @Override |
| | | public void onTextChanged(CharSequence s, int start, int before, int count) { |
| | | } |
| | | |
| | | @Override |
| | | public void afterTextChanged(Editable s) { |
| | | isEnabled(); |
| | | } |
| | | }; |
| | | |
| | | @Override |
| | | protected void onDestroy() { |
| | |
| | | countDownTimer.cancel(); |
| | | countDownTimer = null; |
| | | } |
| | | |
| | | viewBinding.bindMailEt.removeTextChangedListener(accountTextWatcher); |
| | | viewBinding.changeMailVerificationEt.removeTextChangedListener(verificationCodeTextWatcher); |
| | | } |
| | | |
| | | |