From 3ccff7173fb73322f7785d8eaedc90a1b5d8765d Mon Sep 17 00:00:00 2001 From: wjc <1243177876@qq.com> Date: 星期二, 10 十二月 2024 22:44:03 +0800 Subject: [PATCH] 2024年12月10日22:43:59 --- app/src/main/java/com/hdl/photovoltaic/ui/me/BindPhoneActivity.java | 87 ++++++++++++++++++++++++++++++++++++++++++- 1 files changed, 84 insertions(+), 3 deletions(-) diff --git a/app/src/main/java/com/hdl/photovoltaic/ui/me/BindPhoneActivity.java b/app/src/main/java/com/hdl/photovoltaic/ui/me/BindPhoneActivity.java index c972828..b161c89 100644 --- a/app/src/main/java/com/hdl/photovoltaic/ui/me/BindPhoneActivity.java +++ b/app/src/main/java/com/hdl/photovoltaic/ui/me/BindPhoneActivity.java @@ -3,7 +3,9 @@ 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; @@ -34,8 +36,7 @@ @Override public void onBindView(Bundle savedInstanceState) { - setNotificationBarBackgroundColor(CustomColor.white); - setStatusBarTextColor(); + setStatusBarTranslucent(); //鍒濆鍖� initView(); //鍒濆鍖栫晫闈㈢洃鍚櫒 @@ -72,10 +73,15 @@ viewBinding.bindPhoneEt.setText(""); } }); + + //杈撳叆璐﹀彿 + viewBinding.bindPhoneEt.addTextChangedListener(accountTextWatcher); + //杈撳叆楠岃瘉鐮� + viewBinding.changePhoneVerificationEt.addTextChangedListener(verificationCodeTextWatcher); viewBinding.bindPhoneTv.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { - if (isLocalCheck()) { + if (isEnabled()) { String phoneStr = viewBinding.bindPhoneEt.getText().toString(); String verificationStr = viewBinding.changePhoneVerificationEt.getText().toString(); HdlAccountLogic.getInstance().bindingAccount_C(phoneStr, "", verificationStr, new CloudCallBeak<Boolean>() { @@ -101,6 +107,7 @@ private void initView() { viewBinding.toolbarTopRl.topTitleTv.setText(R.string.set_change_bind_phone_number); viewBinding.toolbarTopRl.topBackLl.setVisibility(View.VISIBLE); + checkClearIconShowOrNot(viewBinding.bindPhoneEt.getText().toString()); try { Country.load(this); } catch (Exception e) { @@ -173,6 +180,39 @@ }; /** + * 妫�娴嬫竻闄ゅ浘鏍囨槸鍚︽樉绀� + */ + private void checkClearIconShowOrNot(String s) { + if (s.replace(" ", "").length() > 0) { + if (viewBinding.bindPhoneClearIv.getVisibility() == View.GONE) { + viewBinding.bindPhoneClearIv.setVisibility(View.VISIBLE); + } + } else { + if (viewBinding.bindPhoneClearIv.getVisibility() == View.VISIBLE) { + viewBinding.bindPhoneClearIv.setVisibility(View.GONE); + } + } + } + + /** + * 鏍¢獙纭鎸夐挳鏄惁鍚敤 + */ + private boolean isEnabled() { + String account = viewBinding.bindPhoneEt.getText().toString().replace(" ", ""); + String verificationCode = viewBinding.changePhoneVerificationEt.getText().toString().replace(" ", ""); + boolean isEnabled = account.length() > 0 && verificationCode.length() > 0; + if (isEnabled) { + viewBinding.bindPhoneTv.setTextColor(getColor(R.color.text_E6FFFFFF)); + } else { + viewBinding.bindPhoneTv.setTextColor(getColor(R.color.text_66FFFFFF)); + } + viewBinding.bindPhoneTv.setEnabled(isEnabled); + return isEnabled; + + } + + + /** * 鏈湴鏍¢獙 */ private boolean isLocalCheck() { @@ -190,6 +230,45 @@ } + /** + * 杈撳叆璐﹀彿 + */ + 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() { super.onDestroy(); @@ -198,6 +277,8 @@ countDownTimer.cancel(); countDownTimer = null; } + viewBinding.bindPhoneEt.removeTextChangedListener(accountTextWatcher); + viewBinding.changePhoneVerificationEt.removeTextChangedListener(verificationCodeTextWatcher); } -- Gitblit v1.8.0