| | |
| | | import android.widget.ImageView; |
| | | |
| | | import com.hdl.linkpm.sdk.core.exception.HDLException; |
| | | import com.hdl.linkpm.sdk.user.HDLLinkPMUser; |
| | | import com.hdl.photovoltaic.R; |
| | | import com.hdl.photovoltaic.base.BaseActivity; |
| | | import com.hdl.photovoltaic.base.CustomBaseActivity; |
| | | import com.hdl.photovoltaic.config.UserConfigManage; |
| | | import com.hdl.photovoltaic.databinding.ActivityMeChangePasswordBinding; |
| | | import com.hdl.photovoltaic.listener.CloudCallBeak; |
| | | import com.hdl.photovoltaic.other.HdlAccountLogic; |
| | | import com.hdl.photovoltaic.other.HdlThreadLogic; |
| | | import com.hdl.photovoltaic.widget.ConfirmationCancelDialog; |
| | | |
| | | /** |
| | | * 我的-修改密码-界面 |
| | | */ |
| | | public class MeChangePasswordActivity extends BaseActivity { |
| | | public class MeChangePasswordActivity extends CustomBaseActivity { |
| | | |
| | | private ActivityMeChangePasswordBinding viewBinding; |
| | | |
| | |
| | | |
| | | @Override |
| | | public void onBindView(Bundle savedInstanceState) { |
| | | setNotificationBarBackgroundColor(CustomColor.white); |
| | | setStatusBarTextColor(); |
| | | //初始化 |
| | | initView(); |
| | | //初始化界面监听器 |
| | |
| | | * 初始化界面监听器 |
| | | */ |
| | | private void initEvent() { |
| | | viewBinding.toolbarTopFragmentHouseListRl.topBackBtn.setOnClickListener(new View.OnClickListener() { |
| | | viewBinding.toolbarTopFragmentHouseListRl.topBackLl.setOnClickListener(new View.OnClickListener() { |
| | | @Override |
| | | public void onClick(View v) { |
| | | finish(); |
| | |
| | | viewBinding.homeAffirmTv.setOnClickListener(new View.OnClickListener() { |
| | | @Override |
| | | public void onClick(View v) { |
| | | 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(" ", ""); |
| | | if (!isEditTextPassword(oldPsw, newPsw, affirmPsw)) { |
| | | return; |
| | | } |
| | | // 二次确认提示框 |
| | | ConfirmationCancelDialog dialog = new ConfirmationCancelDialog(_mActivity); |
| | | dialog.setTitle(getString(R.string.loading_title_tip)); |
| | | dialog.setContent(_mActivity.getString(R.string.home_password_changed_successfully_log_in)); |
| | | dialog.show(); |
| | | dialog.setYesOnclickListener(new ConfirmationCancelDialog.onYesOnclickListener() { |
| | | @Override |
| | | public void Confirm() { |
| | | sendChangePassword(oldPsw, newPsw); |
| | | } |
| | | }); |
| | | dialog.setNoOnclickListener(new ConfirmationCancelDialog.onNoOnclickListener() { |
| | | @Override |
| | | public void Cancel() { |
| | | dialog.dismiss(); |
| | | } |
| | | }); |
| | | |
| | | } |
| | | }); |
| | | } |
| | | |
| | | /** |
| | | * 发送更改个人密码指令 |
| | | * |
| | | * @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(" +", ""); |
| | | if (!isEditTextPassword(newPsw, affirmPsw)) { |
| | | HdlThreadLogic.tipFlashingBox(_mActivity, true, getString(R.string.home_login_input_unlike_psw), -1); |
| | | return; |
| | | } |
| | | private void sendChangePassword(String oldPsw, String newPsw) { |
| | | |
| | | if (UserConfigManage.getInstance().isBAccount()) { |
| | | //B端更改个人密码 |
| | | HdlAccountLogic.getInstance().updateBPassword(oldPsw, newPsw, new CloudCallBeak<String>() { |
| | | HdlAccountLogic.getInstance().updatePassword_B(oldPsw, newPsw, new CloudCallBeak<String>() { |
| | | @Override |
| | | public void onSuccess(String str) { |
| | | HdlThreadLogic.tipFlashingBox(_mActivity, true, getString(R.string.home_login_pws_reset_succeeded), 0); |
| | | // HdlThreadLogic.tipFlashingBox(_mActivity, true, getString(R.string.home_login_pws_reset_succeeded), 0); |
| | | HDLLinkPMUser.getInstance().logout(0); |
| | | } |
| | | |
| | | @Override |
| | |
| | | }); |
| | | } else { |
| | | //C端更改个人密码 |
| | | HdlAccountLogic.getInstance().updateCPassword(oldPsw, newPsw, new CloudCallBeak<String>() { |
| | | HdlAccountLogic.getInstance().updatePassword_C(oldPsw, newPsw, new CloudCallBeak<String>() { |
| | | @Override |
| | | public void onSuccess(String obj) { |
| | | HdlThreadLogic.tipFlashingBox(_mActivity, true, getString(R.string.home_login_pws_reset_succeeded), 0); |
| | | |
| | | HDLLinkPMUser.getInstance().logout(0); |
| | | |
| | | |
| | | } |
| | | |
| | | @Override |
| | |
| | | * 初始化 |
| | | */ |
| | | private void initView() { |
| | | viewBinding.toolbarTopFragmentHouseListRl.topBarView.setBackgroundColor(getResources().getColor(R.color.text_FFFFFFFF,null)); |
| | | 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.topTitleTv.setTextColor(getResources().getColor(R.color.text_030D1C, null)); |
| | | viewBinding.toolbarTopFragmentHouseListRl.topBackLl.setVisibility(View.VISIBLE); |
| | | viewBinding.toolbarTopFragmentHouseListRl.topLeftIv.setImageResource(R.drawable.back_c); |
| | | 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); |
| | |
| | | /** |
| | | * 本地校验密码是否正确 |
| | | * |
| | | * @param oldPsw 原来密码 |
| | | * @param newPsw 新密码 |
| | | * @param affirmPsw 再次确认新密码 |
| | | * @return 一样返回true,否者false |
| | | */ |
| | | 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; |
| | | |
| | | } |
| | | |