| | |
| | | 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.BaseConfig; |
| | | 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.CaptchaImageBean; |
| | | import com.application.zhangshi_app_android.bean.FamilyAssetsBean; |
| | | import com.application.zhangshi_app_android.bean.MemoBean; |
| | | import com.application.zhangshi_app_android.bean.PageResponseBean; |
| | | import com.application.zhangshi_app_android.data.DataRepository; |
| | | |
| | | import java.util.List; |
| | | |
| | | import io.reactivex.Observer; |
| | | import io.reactivex.disposables.Disposable; |
| | | |
| | | /** |
| | | * @author Ljj |
| | |
| | | */ |
| | | public class FamilyAssetsDetailActivityViewModel extends BaseViewModel<DataRepository> { |
| | | private MutableLiveData<FamilyAssetsBean> beanLiveData; |
| | | private MutableLiveData<List<MemoBean>> memoListLiveData; |
| | | |
| | | public MutableLiveData<FamilyAssetsBean> getBeanLiveData() { |
| | | if (beanLiveData == null){ |
| | |
| | | super(application); |
| | | } |
| | | |
| | | public MutableLiveData<List<MemoBean>> getMemoListLiveData() { |
| | | if (memoListLiveData == null){ |
| | | memoListLiveData = new MutableLiveData<>(); |
| | | } |
| | | return memoListLiveData; |
| | | } |
| | | |
| | | public void setMemoListLiveData(MutableLiveData<List<MemoBean>> memoListLiveData) { |
| | | this.memoListLiveData = memoListLiveData; |
| | | } |
| | | |
| | | @Override |
| | | protected DataRepository initModel() { |
| | | return DataRepository.getInstance(); |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 获取备忘录 |
| | | */ |
| | | public void getMemos() { |
| | | if (beanLiveData.getValue() == null) { |
| | | return; |
| | | } |
| | | model.getMemos(BaseConfig.MEMO_FID_FAMILY_ASSETS+"", String.valueOf(beanLiveData.getValue().getId())) |
| | | .compose(RxUtils.schedulersTransformer()) |
| | | .subscribe(new Observer<ResultData<List<MemoBean>>>() { |
| | | @Override |
| | | public void onSubscribe(Disposable d) { |
| | | addSubscribe(d); |
| | | } |
| | | |
| | | @Override |
| | | public void onNext(ResultData<List<MemoBean>> data) { |
| | | if (data.getCode() == CODE_SUCCESS){ |
| | | memoListLiveData.postValue(data.getData()); |
| | | }else { |
| | | messageLiveData.postValue(data.getMsg()); |
| | | } |
| | | } |
| | | |
| | | @Override |
| | | public void onError(Throwable e) { |
| | | messageLiveData.postValue(e.getMessage()); |
| | | } |
| | | |
| | | @Override |
| | | public void onComplete() { |
| | | |
| | | } |
| | | }); |
| | | } |
| | | } |