package com.application.zhangshi_app_android.ui.function; import android.app.Application; import androidx.annotation.NonNull; import androidx.lifecycle.MutableLiveData; import com.android.app_base.base.viewmodel.BaseViewModel; import com.application.zhangshi_app_android.bean.WebbackBean; import com.application.zhangshi_app_android.data.DataRepository; import java.util.ArrayList; import java.util.List; public class WebbackDetailActivityViewModel extends BaseViewModel { private MutableLiveData beanLiveData; private MutableLiveData typeLiveData;//true 编辑状态 false 展示状态 private final List uploadFileList = new ArrayList<>();//需要上传的文件列表 public WebbackDetailActivityViewModel(@NonNull Application application) { super(application); } @Override protected DataRepository initModel() { return DataRepository.getInstance(); } public MutableLiveData getBeanLiveData() { if (beanLiveData == null){ beanLiveData = new MutableLiveData<>(); } if (beanLiveData.getValue() == null){ beanLiveData.setValue(new WebbackBean()); } return beanLiveData; } public void setBeanLiveData(MutableLiveData beanLiveData) { this.beanLiveData = beanLiveData; } public MutableLiveData getTypeLiveData() { if (typeLiveData == null){ typeLiveData = new MutableLiveData<>(); } return typeLiveData; } public void setTypeLiveData(MutableLiveData typeLiveData) { this.typeLiveData = typeLiveData; } public List getUploadFileList() { return uploadFileList; } public void addUploadFile(String url) { uploadFileList.add(url); } }