app/src/main/java/com/application/zhangshi_app_android/ui/function/GrowthExperienceActivityViewModel.java
@@ -6,8 +6,11 @@
import androidx.lifecycle.MutableLiveData;
import com.android.app_base.http.ResultData;
import com.android.app_base.manager.UserManager;
import com.android.app_base.utils.RxUtils;
import com.android.app_base.base.viewmodel.BaseViewModel;
import com.android.app_base.utils.rxbus.MessageEvent;
import com.android.app_base.utils.rxbus.RxBus;
import com.application.zhangshi_app_android.bean.GrowthExperienceAbroadConditionBean;
import com.application.zhangshi_app_android.bean.GrowthExperienceAutobiographyBean;
import com.application.zhangshi_app_android.bean.GrowthExperienceBean;
@@ -16,7 +19,6 @@
import com.application.zhangshi_app_android.bean.GrowthExperienceRelationshipBean;
import com.application.zhangshi_app_android.data.DataRepository;
import java.util.HashMap;
import java.util.List;
import io.reactivex.Observer;
@@ -27,12 +29,17 @@
 * @desc 成长经历 viewModel
 */
public class GrowthExperienceActivityViewModel extends BaseViewModel<DataRepository>  {
    private MutableLiveData<List<GrowthExperienceBean>> primaryLiveData;//数据
    private MutableLiveData<GrowthExperienceInformationBean> infoLiveData;
    private MutableLiveData<List<GrowthExperienceAutobiographyBean>> autobiographyLiveData;
    private MutableLiveData<List<GrowthExperienceRelationshipBean>>  relationLiveData;
    private MutableLiveData<List<GrowthExperienceHolderConditionBean>>  holderLiveData;
    private MutableLiveData<List<GrowthExperienceAbroadConditionBean>>  abroadLiveData;
    private MutableLiveData<List<GrowthExperienceBean>> experienceListLiveData;//成长经历列表
    private MutableLiveData<GrowthExperienceInformationBean> infoLiveData;//个人信息
    private MutableLiveData<List<GrowthExperienceAutobiographyBean>> autobiographyLiveData;//自传列表
    private MutableLiveData<List<GrowthExperienceRelationshipBean>>  relationLiveData;//关系列表
    private MutableLiveData<List<GrowthExperienceHolderConditionBean>>  holderLiveData;//持证情况列表
    private MutableLiveData<List<GrowthExperienceAbroadConditionBean>>  abroadLiveData;//出国情况列表
    private MutableLiveData<Boolean> isExperienceExpendedLiveData;//成长经历是否展开
    private MutableLiveData<Boolean> isRelationExpendedLiveData;//关系是否展开
    private MutableLiveData<Boolean> isHolderExpendedLiveData;//持证情况是否展开
    private MutableLiveData<Boolean> isAbroadExpendedLiveData;//出国情况是否展开
    public GrowthExperienceActivityViewModel(@NonNull Application application) {
        super(application);
    }
@@ -57,7 +64,7 @@
                     @Override
                     public void onNext(ResultData<List<GrowthExperienceBean>> data) {
                         if (data.getCode() == CODE_SUCCESS){
                             primaryLiveData.postValue(data.getData());
                             experienceListLiveData.postValue(data.getData());
                         }else {
                             messageLiveData.postValue(data.getMsg());
                         }
@@ -92,7 +99,13 @@
                    @Override
                    public void onNext(ResultData<GrowthExperienceInformationBean> data) {
                        if (data.getCode() == CODE_SUCCESS){
                            infoLiveData.postValue(data.getData());
                            GrowthExperienceInformationBean informationBean = data.getData();
                            infoLiveData.postValue(informationBean);
                            if(informationBean != null){
                                UserManager.getInstance().setUserName(informationBean.getNickName());
                                UserManager.getInstance().setUserAvatar(informationBean.getImg());
                                RxBus.getInstance().post(new MessageEvent(MessageEvent.EVENT_UPDATE_USER_INFO,informationBean));
                            }
                        }else {
                            messageLiveData.postValue(data.getMsg());
                        }
@@ -125,8 +138,6 @@
                    public void onNext(ResultData<List<GrowthExperienceAutobiographyBean>> data) {
                        if (data.getCode() == CODE_SUCCESS) {
                            if (autobiographyLiveData != null) {
                                //这一看就是已经获取到数据了,没法显示就是你写的代码问题,自己找问题啊
                                //就给livedata设置数据,然后呢,它的数据改变后,谁来发生ui变化,观察者呢???谁是观察者
                                autobiographyLiveData.postValue(data.getData());
                            }
                        } else {
@@ -135,8 +146,6 @@
                            }
                        }
                    }
                    @Override
                    public void onError(Throwable e) {
                        messageLiveData.postValue(e.getMessage());
@@ -253,15 +262,15 @@
    public MutableLiveData<List<GrowthExperienceBean>> getPrimaryLiveData() {
        if (primaryLiveData == null){
            primaryLiveData = new MutableLiveData<>();
    public MutableLiveData<List<GrowthExperienceBean>> getExperienceListLiveData() {
        if (experienceListLiveData == null){
            experienceListLiveData = new MutableLiveData<>();
        }
        return primaryLiveData;
        return experienceListLiveData;
    }
    public void setPrimaryLiveData(MutableLiveData<List<GrowthExperienceBean>> primaryLiveData) {
        this.primaryLiveData = primaryLiveData;
    public void setExperienceListLiveData(MutableLiveData<List<GrowthExperienceBean>> experienceListLiveData) {
        this.experienceListLiveData = experienceListLiveData;
    }
    public MutableLiveData<List<GrowthExperienceRelationshipBean>> getRelationLiveData() {
@@ -319,4 +328,52 @@
    public void setAutobiographyLiveData(MutableLiveData<List<GrowthExperienceAutobiographyBean>> autobiographyLiveData) {
        this.autobiographyLiveData = autobiographyLiveData;
    }
    public MutableLiveData<Boolean> getIsExperienceExpendedLiveData() {
        if (isExperienceExpendedLiveData == null){
            isExperienceExpendedLiveData = new MutableLiveData<>();
            isExperienceExpendedLiveData.setValue(false);
        }
        return isExperienceExpendedLiveData;
    }
    public void setIsExperienceExpendedLiveData(MutableLiveData<Boolean> isExperienceExpendedLiveData) {
        this.isExperienceExpendedLiveData = isExperienceExpendedLiveData;
    }
    public MutableLiveData<Boolean> getIsRelationExpendedLiveData() {
        if (isRelationExpendedLiveData == null){
            isRelationExpendedLiveData = new MutableLiveData<>();
            isRelationExpendedLiveData.setValue(false);
        }
        return isRelationExpendedLiveData;
    }
    public void setIsRelationExpendedLiveData(MutableLiveData<Boolean> isRelationExpendedLiveData) {
        this.isRelationExpendedLiveData = isRelationExpendedLiveData;
    }
    public MutableLiveData<Boolean> getIsHolderExpendedLiveData() {
        if (isHolderExpendedLiveData == null){
            isHolderExpendedLiveData = new MutableLiveData<>();
            isHolderExpendedLiveData.setValue(false);
        }
        return isHolderExpendedLiveData;
    }
    public void setIsHolderExpendedLiveData(MutableLiveData<Boolean> isHolderExpendedLiveData) {
        this.isHolderExpendedLiveData = isHolderExpendedLiveData;
    }
    public MutableLiveData<Boolean> getIsAbroadExpendedLiveData() {
        if (isAbroadExpendedLiveData == null){
            isAbroadExpendedLiveData = new MutableLiveData<>();
            isAbroadExpendedLiveData.setValue(false);
        }
        return isAbroadExpendedLiveData;
    }
    public void setIsAbroadExpendedLiveData(MutableLiveData<Boolean> isAbroadExpendedLiveData) {
        this.isAbroadExpendedLiveData = isAbroadExpendedLiveData;
    }
}