From efafbbf142c81c233c71de636a2d3ce9dc2124f0 Mon Sep 17 00:00:00 2001 From: Linjiajia <319408893@qq.com> Date: 星期二, 12 九月 2023 19:20:05 +0800 Subject: [PATCH] 修复bug --- app/src/main/java/com/application/zhangshi_app_android/ui/function/PropertyDetailActivityViewModel.java | 57 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 files changed, 57 insertions(+), 0 deletions(-) diff --git a/app/src/main/java/com/application/zhangshi_app_android/ui/function/PropertyDetailActivityViewModel.java b/app/src/main/java/com/application/zhangshi_app_android/ui/function/PropertyDetailActivityViewModel.java index ae7e9d1..4d6ccff 100644 --- a/app/src/main/java/com/application/zhangshi_app_android/ui/function/PropertyDetailActivityViewModel.java +++ b/app/src/main/java/com/application/zhangshi_app_android/ui/function/PropertyDetailActivityViewModel.java @@ -1,14 +1,25 @@ 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.viewmodel.BaseViewModel; +import com.android.app_base.http.ResultData; +import com.android.app_base.utils.RxUtils; import com.application.zhangshi_app_android.bean.CleanStorageBean; +import com.application.zhangshi_app_android.bean.MemoBean; import com.application.zhangshi_app_android.bean.PropertyBean; import com.application.zhangshi_app_android.data.DataRepository; + +import java.util.List; + +import io.reactivex.Observer; +import io.reactivex.disposables.Disposable; /** * @author Ljj @@ -18,6 +29,7 @@ public class PropertyDetailActivityViewModel extends BaseViewModel<DataRepository> { private MutableLiveData<PropertyBean> beanLiveData; + private MutableLiveData<List<MemoBean>> memoListLiveData; public PropertyDetailActivityViewModel(@NonNull Application application) { super(application); @@ -28,7 +40,41 @@ return DataRepository.getInstance(); } + /** + * 鑾峰彇澶囧繕褰� + */ + public void getMemos() { + if (beanLiveData.getValue() == null) { + return; + } + model.getMemos(BaseConfig.MEMO_FID_PROPERTY+"", 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() { + + } + }); + } public MutableLiveData<PropertyBean> getBeanLiveData() { if (beanLiveData == null) { beanLiveData = new MutableLiveData<>(); @@ -39,4 +85,15 @@ public void setBeanLiveData(MutableLiveData<PropertyBean> beanLiveData) { this.beanLiveData = beanLiveData; } + + public MutableLiveData<List<MemoBean>> getMemoListLiveData() { + if (memoListLiveData == null){ + memoListLiveData = new MutableLiveData<>(); + } + return memoListLiveData; + } + + public void setMemoListLiveData(MutableLiveData<List<MemoBean>> memoListLiveData) { + this.memoListLiveData = memoListLiveData; + } } -- Gitblit v1.9.1