| | |
| | | |
| | | import android.app.Application; |
| | | import android.text.TextUtils; |
| | | import android.util.Log; |
| | | |
| | | import androidx.annotation.NonNull; |
| | | import androidx.lifecycle.MutableLiveData; |
| | |
| | | private MutableLiveData<String> againPassword = new MutableLiveData<>(); |
| | | private MutableLiveData<Boolean> passwordVisibility = new MutableLiveData<>(); |
| | | private MutableLiveData<Boolean> againPasswordVisibility = new MutableLiveData<>(); |
| | | private MutableLiveData<String> selectLoginBackgroundLiveData = new MutableLiveData<>();//背景图 |
| | | |
| | | private MutableLiveData<String> value = new MutableLiveData<>(); |
| | | public LoginActivityViewModel(@NonNull Application application) { |
| | |
| | | return; |
| | | } |
| | | if (captchaImageLiveData.getValue() != null){ |
| | | model.login(new LoginRequestBean(username.getValue(),password.getValue(),captchaImageLiveData.getValue().getValue(),captchaImageLiveData.getValue().getUuid())) |
| | | model.login(new LoginRequestBean(username.getValue(),password.getValue(),value.getValue(),captchaImageLiveData.getValue().getUuid())) |
| | | .compose(RxUtils.schedulersTransformer()) |
| | | .subscribe(new Observer<ResultData<LoginResponseBean>>() { |
| | | @Override |
| | |
| | | if (loginResponseBeanResultData.getCode() == CODE_SUCCESS){ |
| | | String token = loginResponseBeanResultData.getData().getToken(); |
| | | UserManager.getInstance().setToken(token); |
| | | ToastUtils.showShort("登陆成功"); |
| | | AppManager.getAppManager().startActivity(MainActivity.class); |
| | | AppManager.getAppManager().finishCurrentActivity(); |
| | | ToastUtils.showShort("登陆成功"); |
| | | }else { |
| | | changeStateView(StateViewEnum.DATA_ERROR); |
| | | messageLiveData.postValue(loginResponseBeanResultData.getMsg()); |
| | |
| | | public void setValue(MutableLiveData<String> value) { |
| | | this.value = value; |
| | | } |
| | | |
| | | public MutableLiveData<String> getSelectLoginBackgroundLiveData() { |
| | | return selectLoginBackgroundLiveData; |
| | | } |
| | | |
| | | public void setSelectLoginBackgroundLiveData(MutableLiveData<String> selectLoginBackgroundLiveData) { |
| | | this.selectLoginBackgroundLiveData = selectLoginBackgroundLiveData; |
| | | } |
| | | } |