From 4598b51c90c695c9ccbe5350a84e4a46b9d8e587 Mon Sep 17 00:00:00 2001 From: mac <user@users-MacBook-Pro.local> Date: 星期三, 22 五月 2024 20:19:02 +0800 Subject: [PATCH] 2024年05月22日20:18:54 --- app/src/main/java/com/hdl/photovoltaic/ui/me/MeChangePasswordActivity.java | 54 ++++++++++++++++++++++++++++++------------------------ 1 files changed, 30 insertions(+), 24 deletions(-) diff --git a/app/src/main/java/com/hdl/photovoltaic/ui/me/MeChangePasswordActivity.java b/app/src/main/java/com/hdl/photovoltaic/ui/me/MeChangePasswordActivity.java index bdffd5b..e0f93c4 100644 --- a/app/src/main/java/com/hdl/photovoltaic/ui/me/MeChangePasswordActivity.java +++ b/app/src/main/java/com/hdl/photovoltaic/ui/me/MeChangePasswordActivity.java @@ -51,7 +51,7 @@ * 鍒濆鍖栫晫闈㈢洃鍚櫒 */ private void initEvent() { - viewBinding.toolbarTopFragmentHouseListRl.topBackBtn.setOnClickListener(new View.OnClickListener() { + viewBinding.toolbarTopFragmentHouseListRl.topBackLl.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { finish(); @@ -88,15 +88,21 @@ viewBinding.homeAffirmTv.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { + String oldPsw = viewBinding.meChangePasswordOldIc.mePswEt.getText().toString().replaceAll(" ", ""); + String newPsw = viewBinding.meChangePasswordNewIc.mePswEt.getText().toString().replaceAll(" ", ""); + String affirmPsw = viewBinding.meChangePasswordAffirmIc.mePswEt.getText().toString().replaceAll(" ", ""); + if (!isEditTextPassword(oldPsw, newPsw, affirmPsw)) { + return; + } // 浜屾纭鎻愮ず妗� ConfirmationCancelDialog dialog = new ConfirmationCancelDialog(_mActivity); dialog.setTitle(getString(R.string.loading_title_tip)); - dialog.setContent("瀵嗙爜淇敼鎴愬姛,灏嗛噸鏂扮櫥褰�."); + dialog.setContent(_mActivity.getString(R.string.home_password_changed_successfully_log_in)); dialog.show(); dialog.setYesOnclickListener(new ConfirmationCancelDialog.onYesOnclickListener() { @Override public void Confirm() { - sendChangePassword(); + sendChangePassword(oldPsw, newPsw); } }); dialog.setNoOnclickListener(new ConfirmationCancelDialog.onNoOnclickListener() { @@ -112,25 +118,12 @@ /** * 鍙戦�佹洿鏀逛釜浜哄瘑鐮佹寚浠� + * + * @param oldPsw 鍘熸潵瀵嗙爜 + * @param newPsw 鏂板瘑鐮� */ - private void sendChangePassword() { - String oldPsw = viewBinding.meChangePasswordOldIc.mePswEt.getText().toString().replaceAll(" +", ""); - String newPsw = viewBinding.meChangePasswordNewIc.mePswEt.getText().toString().replaceAll(" +", ""); - String affirmPsw = viewBinding.meChangePasswordAffirmIc.mePswEt.getText().toString().replaceAll(" +", ""); + private void sendChangePassword(String oldPsw, String newPsw) { - if (isEditTextPassword(oldPsw, newPsw) || isEditTextPassword(oldPsw, affirmPsw)) { - HdlThreadLogic.tipFlashingBox(_mActivity, true, "鍘熷瘑鐮佸拰鏂板瘑鐮佷笉鑳戒竴鏍�.", -1); - return; - } - - if (newPsw.length() < 6 || affirmPsw.length() < 6) { - HdlThreadLogic.tipFlashingBox(_mActivity, true, getString(R.string.home_login_least6), -1); - return; - } - if (!isEditTextPassword(newPsw, affirmPsw)) { - HdlThreadLogic.tipFlashingBox(_mActivity, true, getString(R.string.home_login_input_unlike_psw), -1); - return; - } if (UserConfigManage.getInstance().isBAccount()) { //B绔洿鏀逛釜浜哄瘑鐮� HdlAccountLogic.getInstance().updatePassword_B(oldPsw, newPsw, new CloudCallBeak<String>() { @@ -173,7 +166,7 @@ viewBinding.toolbarTopFragmentHouseListRl.topBarView.setBackgroundColor(getResources().getColor(R.color.text_FFFFFFFF, null)); viewBinding.toolbarTopFragmentHouseListRl.topTitleTv.setText(R.string.home_login_change_password); viewBinding.toolbarTopFragmentHouseListRl.topTitleTv.setTextColor(getResources().getColor(R.color.text_030D1C, null)); - viewBinding.toolbarTopFragmentHouseListRl.topBackBtn.setVisibility(View.VISIBLE); + viewBinding.toolbarTopFragmentHouseListRl.topBackLl.setVisibility(View.VISIBLE); viewBinding.meChangePasswordOldIc.mePswTitleTv.setText(R.string.home_login_old_pws); viewBinding.meChangePasswordOldIc.mePswEt.setHint(R.string.home_login_input_old_pws); viewBinding.meChangePasswordOldIc.lineV.setVisibility(View.GONE); @@ -202,13 +195,26 @@ /** * 鏈湴鏍¢獙瀵嗙爜鏄惁姝g‘ * + * @param oldPsw 鍘熸潵瀵嗙爜 * @param newPsw 鏂板瘑鐮� * @param affirmPsw 鍐嶆纭鏂板瘑鐮� * @return 涓�鏍疯繑鍥瀟rue锛屽惁鑰協alse */ - private boolean isEditTextPassword(String newPsw, String affirmPsw) { - //鏂板瘑鐮佸拰纭瀵嗙爜涓嶄竴鏍� - return newPsw.equals(affirmPsw); + private boolean isEditTextPassword(String oldPsw, String newPsw, String affirmPsw) { + if (newPsw.length() < 6 || affirmPsw.length() < 6) { + HdlThreadLogic.tipFlashingBox(_mActivity, true, getString(R.string.home_login_least6), -1); + return false; + } + if (!newPsw.equals(affirmPsw)) { + //鏂板瘑鐮佸拰纭瀵嗙爜涓嶄竴鏍� + HdlThreadLogic.tipFlashingBox(_mActivity, true, getString(R.string.home_login_input_unlike_psw), -1); + return false; + } + if (oldPsw.equals(newPsw)) { + HdlThreadLogic.tipFlashingBox(_mActivity, true, getString(R.string.home_old_password_not_new_password), -1); + return false; + } + return true; } -- Gitblit v1.8.0