package com.hdl.photovoltaic.ui.me;
|
|
import androidx.appcompat.app.AppCompatActivity;
|
import androidx.appcompat.content.res.AppCompatResources;
|
|
import android.os.Bundle;
|
import android.text.Editable;
|
import android.text.TextUtils;
|
import android.text.TextWatcher;
|
import android.text.method.HideReturnsTransformationMethod;
|
import android.text.method.PasswordTransformationMethod;
|
import android.view.View;
|
import android.widget.EditText;
|
import android.widget.ImageView;
|
|
import com.hdl.photovoltaic.R;
|
import com.hdl.photovoltaic.base.BaseActivity;
|
import com.hdl.photovoltaic.databinding.ActivityMeChangePasswordBinding;
|
|
public class MeChangePasswordActivity extends BaseActivity implements View.OnClickListener {
|
|
private ActivityMeChangePasswordBinding viewBinding;
|
|
@Override
|
public Object getContentView() {
|
viewBinding = ActivityMeChangePasswordBinding.inflate(getLayoutInflater());
|
return viewBinding.getRoot();
|
}
|
|
@Override
|
public void onBindView(Bundle savedInstanceState) {
|
//初始化
|
initView();
|
//初始化界面监听器
|
initEvent();
|
}
|
|
/**
|
* 初始化界面监听器
|
*/
|
private void initEvent() {
|
viewBinding.toolbarTopFragmentHouseListRl.topBackBtn.setOnClickListener(this);
|
viewBinding.meChangePasswordOldIc.mePswEt.addTextChangedListener(textWatcher1);
|
viewBinding.meChangePasswordOldIc.mePswHideIv.setOnClickListener(this);
|
viewBinding.meChangePasswordNewIc.mePswEt.addTextChangedListener(textWatcher2);
|
viewBinding.meChangePasswordNewIc.mePswHideIv.setOnClickListener(this);
|
viewBinding.meChangePasswordAffirmIc.mePswEt.addTextChangedListener(textWatcher3);
|
viewBinding.meChangePasswordAffirmIc.mePswHideIv.setOnClickListener(this);
|
}
|
|
/**
|
* 初始化
|
*/
|
private void initView() {
|
viewBinding.toolbarTopFragmentHouseListRl.topBarView.setBackgroundColor(getResources().getColor(R.color.text_FFFFFFFF));
|
viewBinding.toolbarTopFragmentHouseListRl.topTitleTv.setText(R.string.home_login_change_password);
|
viewBinding.toolbarTopFragmentHouseListRl.topTitleTv.setTextColor(getResources().getColor(R.color.text_030D1C));
|
viewBinding.toolbarTopFragmentHouseListRl.topBackBtn.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.meChangePasswordNewIc.mePswTitleTv.setText(R.string.home_login_new_pws);
|
viewBinding.meChangePasswordNewIc.mePswEt.setHint(R.string.home_login_input_new_pws);
|
viewBinding.meChangePasswordAffirmIc.mePswTitleTv.setText(R.string.home_login_affirm_psw);
|
viewBinding.meChangePasswordAffirmIc.mePswEt.setHint(R.string.home_login_input_affirm_psw);
|
|
|
}
|
|
@Override
|
public void onClick(View v) {
|
if (v.getId() == viewBinding.toolbarTopFragmentHouseListRl.topBackBtn.getId()) {
|
finish();
|
} else if (v.getId() == viewBinding.meChangePasswordOldIc.mePswHideIv.getId()) {
|
setEditTextStyle(viewBinding.meChangePasswordOldIc.mePswEt, viewBinding.meChangePasswordOldIc.mePswHideIv);
|
} else if (v.getId() == viewBinding.meChangePasswordNewIc.mePswHideIv.getId()) {
|
setEditTextStyle(viewBinding.meChangePasswordNewIc.mePswEt, viewBinding.meChangePasswordNewIc.mePswHideIv);
|
} else if (v.getId() == viewBinding.meChangePasswordAffirmIc.mePswHideIv.getId()) {
|
setEditTextStyle(viewBinding.meChangePasswordAffirmIc.mePswEt, viewBinding.meChangePasswordAffirmIc.mePswHideIv);
|
}
|
}
|
|
private void setEditTextStyle(EditText editText, ImageView imageView) {
|
if (imageView.isSelected()) {
|
imageView.setSelected(false);
|
imageView.setImageDrawable(AppCompatResources.getDrawable(_mActivity, R.drawable.hide));
|
editText.setTransformationMethod(PasswordTransformationMethod.getInstance());
|
} else {
|
imageView.setSelected(true);
|
imageView.setImageDrawable(AppCompatResources.getDrawable(_mActivity, R.drawable.show));
|
editText.setTransformationMethod(HideReturnsTransformationMethod.getInstance());
|
}
|
//设置光标位置
|
if (!TextUtils.isEmpty(editText.getText())) {
|
editText.setSelection(editText.length());
|
}
|
}
|
|
|
@Override
|
protected void onDestroy() {
|
super.onDestroy();
|
viewBinding.meChangePasswordOldIc.mePswEt.removeTextChangedListener(textWatcher1);
|
viewBinding.meChangePasswordNewIc.mePswEt.removeTextChangedListener(textWatcher2);
|
viewBinding.meChangePasswordAffirmIc.mePswEt.removeTextChangedListener(textWatcher3);
|
}
|
|
private final TextWatcher textWatcher1 = 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) {
|
|
}
|
};
|
|
private final TextWatcher textWatcher2 = 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) {
|
|
}
|
};
|
|
private final TextWatcher textWatcher3 = 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) {
|
|
}
|
};
|
|
|
}
|