| | |
| | | import androidx.appcompat.app.AppCompatActivity; |
| | | |
| | | import android.os.Bundle; |
| | | import android.text.TextUtils; |
| | | import android.text.method.HideReturnsTransformationMethod; |
| | | import android.text.method.PasswordTransformationMethod; |
| | | import android.view.View; |
| | | import android.widget.Toast; |
| | | |
| | | import com.doumee.keyCabinet.BuildConfig; |
| | | import com.doumee.keyCabinet.R; |
| | | import com.doumee.keyCabinet.base.MyBaseActivity; |
| | | import com.doumee.keyCabinet.databinding.ManageLoginActivityBinding; |
| | | import com.doumee.keyCabinet.event.TimeClockEvent; |
| | | import com.doumee.keyCabinet.utils.LMobileInfo; |
| | | import com.doumee.lib_coremodel.bean.event.ActionEventData; |
| | | |
| | | import org.greenrobot.eventbus.Subscribe; |
| | | |
| | | import dagger.hilt.android.AndroidEntryPoint; |
| | | |
| | |
| | | |
| | | @Override |
| | | public void initData(@Nullable Bundle savedInstanceState) { |
| | | getDB().tvNo.setText("NO:"+ LMobileInfo.getDeviceUniqueId()); |
| | | getDB().tvV.setText("V"+ BuildConfig.VERSION_NAME); |
| | | |
| | | |
| | | } |
| | | |
| | | @Override |
| | | protected void doRegister(int type, ActionEventData data) { |
| | | switch (type){ |
| | | case 1: |
| | | //显示密码 |
| | | isShowPw = !isShowPw; |
| | | updatePassword(); |
| | | break; |
| | | case 2: |
| | | if(TextUtils.isEmpty(getDB().etName.getText().toString())){ |
| | | Toast.makeText(mContext, "请输入登录账号", Toast.LENGTH_SHORT).show(); |
| | | return; |
| | | } |
| | | if(TextUtils.isEmpty(getDB().etPw.getText().toString())){ |
| | | Toast.makeText(mContext, "请输入账号密码", Toast.LENGTH_SHORT).show(); |
| | | return; |
| | | } |
| | | getVM().loginCabinet(getDB().etName.getText().toString(),getDB().etPw.getText().toString()); |
| | | break; |
| | | case 3: |
| | | //显示加载 |
| | | getDB().clProgress.setVisibility(View.VISIBLE); |
| | | getDB().clTip.setVisibility(View.GONE); |
| | | break; |
| | | case 4: |
| | | getDB().clProgress.setVisibility(View.GONE); |
| | | tipDownCount = 60; |
| | | isShowTip = true; |
| | | getDB().clTip.setVisibility(View.VISIBLE); |
| | | break; |
| | | case 5: |
| | | startActivity(ManageCabinetActivity.class); |
| | | finish(); |
| | | break; |
| | | default: |
| | | break; |
| | | } |
| | | } |
| | | |
| | | private boolean isShowPw = false; |
| | | private void updatePassword() { |
| | | if(isShowPw){ |
| | | getDB().img3.setImageResource(R.mipmap.login_eyeopen); |
| | | // 显示密码 |
| | | getDB().etPw.setTransformationMethod(HideReturnsTransformationMethod.getInstance()); |
| | | }else { |
| | | getDB().img3.setImageResource(R.mipmap.login_eyeclose); |
| | | // 隐藏密码 |
| | | getDB().etPw.setTransformationMethod(PasswordTransformationMethod.getInstance()); |
| | | } |
| | | } |
| | | |
| | | private int tipDownCount = 60; |
| | | private boolean isShowTip; |
| | | @Subscribe |
| | | public void TimeClockEvent(TimeClockEvent e){ |
| | | if(isShowTip){ |
| | | if(tipDownCount==0){ |
| | | isShowTip = false; |
| | | finish(); |
| | | }else { |
| | | tipDownCount--; |
| | | getDB().tvClKmClose.setText(tipDownCount+"s 自动关闭"); |
| | | } |
| | | } |
| | | } |
| | | } |