From 819940c20dfb8a0c797b3423a3c0a0c67c9fd955 Mon Sep 17 00:00:00 2001
From: hxb <hxb@hdlchina.com.cn>
Date: 星期五, 27 十二月 2024 18:06:23 +0800
Subject: [PATCH] 处理后台运行被释放的问题

---
 app/src/main/java/com/hdl/photovoltaic/ui/me/BindPhoneActivity.java |   97 ++++++++++++++++++++++++++++++++++++++++++++----
 1 files changed, 88 insertions(+), 9 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 03cfe22..d02e562 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;
@@ -13,6 +15,7 @@
 import com.hdl.photovoltaic.databinding.ActivityBindPhoneBinding;
 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;
 import com.sahooz.library.countrypicker.Country;
@@ -34,8 +37,8 @@
 
     @Override
     public void onBindView(Bundle savedInstanceState) {
-        setNotificationBarBackgroundColor(CustomColor.white);
-        setStatusBarTextColor();
+        setStatusBarTranslucent();
+        getWindow().setNavigationBarColor(getColor(R.color.text_FF000000));
         //鍒濆鍖�
         initView();
         //鍒濆鍖栫晫闈㈢洃鍚櫒
@@ -72,10 +75,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>() {
@@ -100,15 +108,15 @@
 
     private void initView() {
         viewBinding.toolbarTopRl.topTitleTv.setText(R.string.set_change_bind_phone_number);
-        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.bindPhoneEt.getText().toString());
         try {
             Country.load(this);
         } catch (Exception e) {
             e.printStackTrace();
         }
+        HdlCommonLogic.getInstance().setSpan(viewBinding.bindPhoneVerificationTv, viewBinding.bindPhoneVerificationTv.getText().toString(), true, null);
     }
 
     /**
@@ -162,7 +170,6 @@
             long time = (millisUntilFinished / 1000);
             String str = time + "s" + getString(R.string.home_login_psw_verification_repeater);
             viewBinding.bindPhoneVerificationTv.setText(str);
-            viewBinding.bindPhoneVerificationTv.setTextColor(getResources().getColor(R.color.text_25000000, null));
             viewBinding.bindPhoneVerificationTv.setEnabled(false);
 
         }
@@ -170,12 +177,44 @@
         @Override
         public void onFinish() {
             viewBinding.bindPhoneVerificationTv.setText(getString(R.string.home_login_verification_regain));
-            viewBinding.bindPhoneVerificationTv.setTextColor(getResources().getColor(R.color.text_245EC3, null));
             viewBinding.bindPhoneVerificationTv.setEnabled(true);
 
 
         }
     };
+
+    /**
+     * 妫�娴嬫竻闄ゅ浘鏍囨槸鍚︽樉绀�
+     */
+    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;
+
+    }
+
 
     /**
      * 鏈湴鏍¢獙
@@ -191,10 +230,48 @@
             HdlThreadLogic.tipFlashingBox(this, false, getString(R.string.home_login_null_verification_code), -1);
             return false;
         }
-
         return true;
 
     }
+
+    /**
+     * 杈撳叆璐﹀彿
+     */
+    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() {
@@ -204,6 +281,8 @@
             countDownTimer.cancel();
             countDownTimer = null;
         }
+        viewBinding.bindPhoneEt.removeTextChangedListener(accountTextWatcher);
+        viewBinding.changePhoneVerificationEt.removeTextChangedListener(verificationCodeTextWatcher);
 
     }
 

--
Gitblit v1.8.0