| | |
| | | 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; |
| | | |
| | |
| | | |
| | | 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) { |
| | |
| | | } |
| | | }); |
| | | |
| | | 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) { |
| | |
| | | // //隐私协议提示 |
| | | // 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 |
| | |
| | | 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; |
| | | } |
| | | |
| | |
| | | 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); |
| | | } |
| | | } |