张钢
2024-09-02 63608b5dca9eebb6fa2cb1a8652b395f1d910c3e
app/src/main/java/com/application/zhangshi_app_android/ui/login/LoginActivityViewModel.java
@@ -4,6 +4,7 @@
import android.app.Application;
import android.text.TextUtils;
import android.util.Log;
import androidx.annotation.NonNull;
import androidx.lifecycle.MutableLiveData;
@@ -38,6 +39,7 @@
    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) {
@@ -92,7 +94,7 @@
            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
@@ -105,8 +107,9 @@
                            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());
@@ -226,4 +229,12 @@
    public void setValue(MutableLiveData<String> value) {
        this.value = value;
    }
    public MutableLiveData<String> getSelectLoginBackgroundLiveData() {
        return selectLoginBackgroundLiveData;
    }
    public void setSelectLoginBackgroundLiveData(MutableLiveData<String> selectLoginBackgroundLiveData) {
        this.selectLoginBackgroundLiveData = selectLoginBackgroundLiveData;
    }
}