张钢
2024-09-02 63608b5dca9eebb6fa2cb1a8652b395f1d910c3e
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
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<DataRepository> {
 
    private MutableLiveData<WebbackBean> beanLiveData;
    private MutableLiveData<Boolean> typeLiveData;//true 编辑状态 false 展示状态
    private final List<String> uploadFileList = new ArrayList<>();//需要上传的文件列表
    public WebbackDetailActivityViewModel(@NonNull Application application) {
        super(application);
    }
 
    @Override
    protected DataRepository initModel() {
        return DataRepository.getInstance();
    }
 
 
    public MutableLiveData<WebbackBean> getBeanLiveData() {
        if (beanLiveData == null){
            beanLiveData = new MutableLiveData<>();
        }
        if (beanLiveData.getValue() == null){
            beanLiveData.setValue(new WebbackBean());
        }
        return beanLiveData;
    }
 
    public void setBeanLiveData(MutableLiveData<WebbackBean> beanLiveData) {
        this.beanLiveData = beanLiveData;
    }
 
    public MutableLiveData<Boolean> getTypeLiveData() {
        if (typeLiveData == null){
            typeLiveData = new MutableLiveData<>();
        }
        return typeLiveData;
    }
 
    public void setTypeLiveData(MutableLiveData<Boolean> typeLiveData) {
        this.typeLiveData = typeLiveData;
    }
 
    public List<String> getUploadFileList() {
        return uploadFileList;
    }
 
    public void addUploadFile(String url) {
        uploadFileList.add(url);
    }
 
 
}