| | |
| | | package com.application.zhangshi_app_android.ui.function; |
| | | |
| | | import static com.android.app_base.base.BaseConfig.CODE_SUCCESS; |
| | | |
| | | import android.app.Application; |
| | | |
| | | import androidx.annotation.NonNull; |
| | | import androidx.lifecycle.MutableLiveData; |
| | | |
| | | import com.android.app_base.base.StateViewEnum; |
| | | import com.android.app_base.base.viewmodel.BaseViewModel; |
| | | import com.android.app_base.http.ResultData; |
| | | import com.android.app_base.utils.RxUtils; |
| | | import com.application.zhangshi_app_android.bean.GrowthExperienceInformationBean; |
| | | import com.application.zhangshi_app_android.bean.MarriageInfoBean; |
| | | import com.application.zhangshi_app_android.data.DataRepository; |
| | | |
| | | import io.reactivex.Observer; |
| | | import io.reactivex.disposables.Disposable; |
| | | |
| | | /** |
| | | * @author Ljj |
| | |
| | | private MutableLiveData<Boolean> isSpouseExpendedLiveData; |
| | | private MutableLiveData<Boolean> isPredecessorExpendedLiveData; |
| | | private MutableLiveData<Boolean> isProcreateExpendedLiveData; |
| | | |
| | | private MutableLiveData<MarriageInfoBean> infoLiveData; |
| | | public MarriageActivityViewModel(@NonNull Application application) { |
| | | super(application); |
| | | } |
| | |
| | | return DataRepository.getInstance(); |
| | | } |
| | | |
| | | /** |
| | | * 获取个人婚姻 |
| | | */ |
| | | public void getMarriageInfo(){ |
| | | model.getMarriageInfo() |
| | | .compose(RxUtils.schedulersTransformer()) |
| | | .subscribe(new Observer<ResultData<MarriageInfoBean>>() { |
| | | @Override |
| | | public void onSubscribe(Disposable d) { |
| | | addSubscribe(d); |
| | | } |
| | | |
| | | @Override |
| | | public void onNext(ResultData<MarriageInfoBean> data) { |
| | | if (data.getCode() == CODE_SUCCESS){ |
| | | changeStateView(StateViewEnum.HIDE); |
| | | infoLiveData.postValue(data.getData()); |
| | | }else if (data.getCode() == 500){ |
| | | changeStateView(StateViewEnum.DATA_NULL); |
| | | messageLiveData.postValue(data.getMsg()); |
| | | }else { |
| | | messageLiveData.postValue(data.getMsg()); |
| | | } |
| | | } |
| | | |
| | | |
| | | @Override |
| | | public void onError(Throwable e) { |
| | | messageLiveData.postValue(e.getMessage()); |
| | | } |
| | | |
| | | @Override |
| | | public void onComplete() { |
| | | |
| | | } |
| | | }); |
| | | } |
| | | |
| | | public MutableLiveData<MarriageInfoBean> getInfoLiveData() { |
| | | if (infoLiveData == null){ |
| | | infoLiveData = new MutableLiveData<>(); |
| | | } |
| | | return infoLiveData; |
| | | } |
| | | |
| | | public void setInfoLiveData(MutableLiveData<MarriageInfoBean> infoLiveData) { |
| | | this.infoLiveData = infoLiveData; |
| | | } |
| | | |
| | | public MutableLiveData<Boolean> getIsSpouseExpendedLiveData() { |
| | | if (isSpouseExpendedLiveData == null){ |
| | | isSpouseExpendedLiveData = new MutableLiveData<>(); |