mac
2023-10-26 de2d3696f975cf6e6df2e580bab305fa9859feea
app/src/main/java/com/hdl/photovoltaic/ui/HomeLoginActivity.java
@@ -11,7 +11,6 @@
import android.text.method.HideReturnsTransformationMethod;
import android.text.method.PasswordTransformationMethod;
import android.text.style.ForegroundColorSpan;
import android.util.Log;
import android.view.View;
import android.widget.TextView;
@@ -25,6 +24,7 @@
import com.hdl.linkpm.sdk.user.callback.ILoginCallBack;
import com.hdl.photovoltaic.R;
import com.hdl.photovoltaic.base.CustomBaseActivity;
import com.hdl.photovoltaic.config.UserConfigManage;
import com.hdl.photovoltaic.other.HdlFileLogic;
import com.hdl.photovoltaic.other.HdlResidenceLogic;
import com.hdl.photovoltaic.ui.account.ChangePassword;
@@ -95,33 +95,7 @@
    private void initEvent() {
        viewBinding.homeLoginAccountEt.addTextChangedListener(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) {
                Log.d("HomeLoginActivity2", String.format("CharSequence=%s,start=%s,before=%s,count=%s", s, start, before, count));
            }
            @Override
            public void afterTextChanged(Editable s) {
                if (s.length() > 0) {
                    if (viewBinding.homeLoginClearContentsIv.getVisibility() == View.GONE) {
                        viewBinding.homeLoginClearContentsIv.setVisibility(View.VISIBLE);
                    }
                } else {
                    if (viewBinding.homeLoginClearContentsIv.getVisibility() == View.VISIBLE) {
                        viewBinding.homeLoginClearContentsIv.setVisibility(View.GONE);
                    }
                }
                isLoginTextViewEnabled();
            }
        });
        viewBinding.homeLoginAccountEt.addTextChangedListener(accountTextWatcher);
        viewBinding.homeLoginClearContentsIv.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
@@ -129,22 +103,7 @@
            }
        });
        viewBinding.homeLoginPasswordEt.addTextChangedListener(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) {
                isLoginTextViewEnabled();
            }
        });
        viewBinding.homeLoginPasswordEt.addTextChangedListener(passwordTextWatcher);
        viewBinding.homeLoginHideIv.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
@@ -165,11 +124,31 @@
            }
        });
        //选择b端,c端
        viewBinding.homeLoginInstallUserTv.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                v.setSelected(!v.isSelected());
                UserConfigManage.getInstance().setBAccount(v.isSelected());
                viewBinding.homeLoginCheckIv.setSelected(UserConfigManage.getInstance().isBAccount());
                if (UserConfigManage.getInstance().isBAccount()) {
                    viewBinding.homeLoginRegisterTv.setVisibility(View.GONE);
                } else {
                    viewBinding.homeLoginRegisterTv.setVisibility(View.VISIBLE);
                }
            }
        });
        //选择b端,c端
        viewBinding.homeLoginCheckIv.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                v.setSelected(!v.isSelected());
                UserConfigManage.getInstance().setBAccount(v.isSelected());
                if (UserConfigManage.getInstance().isBAccount()) {
                    viewBinding.homeLoginRegisterTv.setVisibility(View.GONE);
                } else {
                    viewBinding.homeLoginRegisterTv.setVisibility(View.VISIBLE);
                }
            }
        });
        viewBinding.homeLoginPrivacyCheckIv.setOnClickListener(new View.OnClickListener() {
@@ -194,11 +173,11 @@
//                    //隐私协议提示
//                    return;
//                }
                showLoading(getString(R.string.home_login_登录中));
                showLoading(getString(R.string.home_login_be_logging_in));
                HdlAccountLogic.getInstance().regionByAccount(account, new CloudCallBeak<HDLUserRegionBean>() {
                    @Override
                    public void onSuccess(HDLUserRegionBean obj) {
                        AppConfigManage.setUserRegionUrl("http://59.41.255.150:7777");//obj.getRegionUrl()
                        AppConfigManage.setUserRegionUrl(obj.getRegionUrl());
                        HDLLinkPMUser.getInstance().setUserRegionUrl(AppConfigManage.getUserRegionUrl());
                        HdlAccountLogic.getInstance().loginByPassword(account, password, new ILoginCallBack() {
                            @Override
@@ -241,6 +220,8 @@
        viewBinding.homeLoginExperienceTv.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                v.setSelected(!v.isSelected());
                UserConfigManage.getInstance().setUserExperience(v.isSelected());
//                requestPermissions();
//                startActivity(MyPowerStationActivity.class);
                HdlFileLogic.getInstance().deleteDirectory(HdlFileLogic.getInstance().getCurrentHomeRootPath());
@@ -288,12 +269,12 @@
    private boolean isLocalCheckAccountAndPassword(String account, String password) {
        if (TextUtils.isEmpty(account)) {
            viewBinding.homeLoginLine1V.setBackgroundColor(getColor(R.color.text_D34545));
            viewBinding.homeLoginAccountTextErrorTv.setText(R.string.home_login_error_账号不能为空);
            viewBinding.homeLoginAccountTextErrorTv.setText(R.string.home_login_error_account_null);
            return false;
        }
        if (TextUtils.isEmpty(password)) {
            viewBinding.homeLoginLine2V.setBackgroundColor(getColor(R.color.text_D34545));
            viewBinding.homeLoginPasswordTextErrorTv.setText(R.string.home_login_error_密码不能为空);
            viewBinding.homeLoginPasswordTextErrorTv.setText(R.string.home_login_error_password_null);
            return false;
        }
@@ -336,5 +317,56 @@
        view.setText(spannable);
    }
    /**
     * 输入账号
     */
    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) {
            if (s.length() > 0) {
                if (viewBinding.homeLoginClearContentsIv.getVisibility() == View.GONE) {
                    viewBinding.homeLoginClearContentsIv.setVisibility(View.VISIBLE);
                }
            } else {
                if (viewBinding.homeLoginClearContentsIv.getVisibility() == View.VISIBLE) {
                    viewBinding.homeLoginClearContentsIv.setVisibility(View.GONE);
                }
            }
            isLoginTextViewEnabled();
        }
    };
    /**
     * 输入密码
     */
    private final TextWatcher passwordTextWatcher = 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) {
            isLoginTextViewEnabled();
        }
    };
    @Override
    protected void onDestroy() {
        super.onDestroy();
        viewBinding.homeLoginAccountEt.removeTextChangedListener(accountTextWatcher);
        viewBinding.homeLoginPasswordEt.removeTextChangedListener(passwordTextWatcher);
    }
}