| | |
| | | mBinding.txtLogin.setOnClickListener(onclick); |
| | | mBinding.txtRegister.setOnClickListener(onclick); |
| | | mBinding.txtPrivacy.setOnClickListener(onclick); |
| | | mBinding.button.setOnClickListener(onclick); |
| | | mBinding.editPhone.setText(getStringProjectPrefrence(Configuration.KEY_USERNAME)); |
| | | mViewModel.getVerifyResult().observe(this, stringApiResult -> { |
| | | if(stringApiResult.code == 200){ |
| | | |
| | | mViewModel.getVerifyResult().observe(this, result -> { |
| | | if(result == 0){ |
| | | putLongProjectPrefrence(VERIFY_CODE,new Date().getTime()); |
| | | CodeTimer codeTimer = new CodeTimer(60000, 1000, mBinding.txtGetVerify); |
| | | codeTimer.startUp(); |
| | | }else{ |
| | | showToast(stringApiResult.msg); |
| | | |
| | | } |
| | | }); |
| | | mViewModel.getLoginResult().observe(this, loggedInUser -> { |
| | | if(loggedInUser.code == 200){ |
| | | putBooleanProjectPrefrence(Configuration.IS_LOGIN,true); |
| | | putStringProjectPrefrence(Configuration.KEY_USERNAME, mBinding.editPhone.getText().toString()); |
| | | |
| | | UserBean user = new Gson().fromJson(new Gson().toJson(loggedInUser.data) ,UserBean.class); |
| | | UserBean.setUser(user); |
| | | putStringProjectPrefrence(Configuration.KEY_TOKEN, user.getToken()); |
| | | MyLog.i("registerlogin",user.toString()); |
| | | showToast(R.string.login_success); |
| | | setResult(RESULT_CODE_SUCESS); |
| | | finish(); |
| | | }else{ |
| | | showToast(loggedInUser.msg); |
| | | } |
| | | putStringProjectPrefrence(Configuration.KEY_USERNAME, mBinding.editPhone.getText().toString()); |
| | | UserBean.setUser(loggedInUser); |
| | | putStringProjectPrefrence(Configuration.KEY_USERINFO, new Gson().toJson(loggedInUser)); |
| | | MyLog.i("registerlogin",loggedInUser.toString()); |
| | | showToast(R.string.login_success); |
| | | setResult(RESULT_CODE_SUCESS); |
| | | finish(); |
| | | }); |
| | | } |
| | | |
| | |
| | | long getTime = getLongProjectPrefrence(VERIFY_CODE); |
| | | long cha = new Date().getTime() - getTime; |
| | | if(cha <1000*60){ |
| | | CodeTimer codeTimer = new CodeTimer(cha, 1000, mBinding.txtGetVerify); |
| | | CodeTimer codeTimer = new CodeTimer((60) * 1000-cha, 1000, mBinding.txtGetVerify); |
| | | codeTimer.startUp(); |
| | | } |
| | | changeView(); |