Linjiajia
2023-04-28 15cd434674051e5d29215b47862686c773625fd4
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
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
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.http.ResultData;
import com.android.app_base.utils.RxUtils;
import com.android.app_base.base.viewmodel.BaseViewModel;
import com.application.zhangshi_app_android.bean.GrowthExperienceAbroadConditionBean;
import com.application.zhangshi_app_android.bean.GrowthExperienceAutobiographyBean;
import com.application.zhangshi_app_android.bean.GrowthExperienceBean;
import com.application.zhangshi_app_android.bean.GrowthExperienceHolderConditionBean;
import com.application.zhangshi_app_android.bean.GrowthExperienceInformationBean;
import com.application.zhangshi_app_android.bean.GrowthExperienceRelationshipBean;
import com.application.zhangshi_app_android.data.DataRepository;
 
import java.util.List;
 
import io.reactivex.Observer;
import io.reactivex.disposables.Disposable;
/**
 * @author Gss
 * @date 2023.03.31. 21:33
 * @desc 成长经历 viewModel
 */
public class GrowthExperienceActivityViewModel extends BaseViewModel<DataRepository>  {
    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);
    }
    @Override
    protected DataRepository initModel() {
        return DataRepository.getInstance();
    }
 
 
    /**
     * 获取成长经历
     */
    public void getGrowthExperience(){
         model.getGrowthExperience()
                 .compose(RxUtils.schedulersTransformer())
                 .subscribe(new Observer<ResultData<List<GrowthExperienceBean>>>() {
                     @Override
                     public void onSubscribe(Disposable d) {
                         addSubscribe(d);
                     }
 
                     @Override
                     public void onNext(ResultData<List<GrowthExperienceBean>> data) {
                         if (data.getCode() == CODE_SUCCESS){
                             experienceListLiveData.postValue(data.getData());
                         }else {
                             messageLiveData.postValue(data.getMsg());
                         }
                     }
 
 
                     @Override
                     public void onError(Throwable e) {
                         messageLiveData.postValue(e.getMessage());
                     }
 
                     @Override
                     public void onComplete() {
 
                     }
                 });
 
    }
 
    /**
     * 获取个人信息
     */
    public void getInfo(){
        model.getGrowthExperienceInformation()
                .compose(RxUtils.schedulersTransformer())
                .subscribe(new Observer<ResultData<GrowthExperienceInformationBean>>() {
                    @Override
                    public void onSubscribe(Disposable d) {
                        addSubscribe(d);
                    }
 
                    @Override
                    public void onNext(ResultData<GrowthExperienceInformationBean> data) {
                        if (data.getCode() == CODE_SUCCESS){
                            infoLiveData.postValue(data.getData());
                        }else {
                            messageLiveData.postValue(data.getMsg());
                        }
                    }
 
 
                    @Override
                    public void onError(Throwable e) {
                        messageLiveData.postValue(e.getMessage());
                    }
 
                    @Override
                    public void onComplete() {
 
                    }
                });
    }
    /**
     * 获取自传
     */
    public void getGrowthExperienceAutobiography(){
        model.getGrowthExperienceAutobiography()
                .compose(RxUtils.schedulersTransformer())
                .subscribe(new Observer<ResultData<List<GrowthExperienceAutobiographyBean>>>() {
                    @Override
                    public void onSubscribe(Disposable d) {
                        addSubscribe(d);
                    }
                    @Override
                    public void onNext(ResultData<List<GrowthExperienceAutobiographyBean>> data) {
                        if (data.getCode() == CODE_SUCCESS) {
                            if (autobiographyLiveData != null) {
                                autobiographyLiveData.postValue(data.getData());
                            }
                        } else {
                            if (messageLiveData != null) {
                                messageLiveData.postValue(data.getMsg());
                            }
                        }
                    }
                    @Override
                    public void onError(Throwable e) {
                        messageLiveData.postValue(e.getMessage());
                    }
 
                    @Override
                    public void onComplete() {
 
                    }
                });
    }
 
    /**
     * 获取关系情况
     */
    public void getRelation(){
        model.getGrowthExperienceRelationship()
                .compose(RxUtils.schedulersTransformer())
                .subscribe(new Observer<ResultData<List<GrowthExperienceRelationshipBean>>>() {
                    @Override
                    public void onSubscribe(Disposable d) {
                        addSubscribe(d);
                    }
 
                    @Override
                    public void onNext(ResultData<List<GrowthExperienceRelationshipBean>> data) {
                        if (data.getCode() == CODE_SUCCESS){
                            relationLiveData.postValue(data.getData());
                        }else {
                            messageLiveData.postValue(data.getMsg());
                        }
                    }
 
 
                    @Override
                    public void onError(Throwable e) {
                        messageLiveData.postValue(e.getMessage());
                    }
 
                    @Override
                    public void onComplete() {
 
                    }
                });
    }
    /**
     * 获取持有出入境证件情况
     */
    public void getHolder(){
        model.getGrowthExperienceHolderCondition()
                .compose(RxUtils.schedulersTransformer())
                .subscribe(new Observer<ResultData<List<GrowthExperienceHolderConditionBean>>>() {
                    @Override
                    public void onSubscribe(Disposable d) {
                        addSubscribe(d);
                    }
 
                    @Override
                    public void onNext(ResultData<List<GrowthExperienceHolderConditionBean>> data) {
                        if (data.getCode() == CODE_SUCCESS){
                            holderLiveData.postValue(data.getData());
                        }else {
                            messageLiveData.postValue(data.getMsg());
                        }
                    }
 
 
                    @Override
                    public void onError(Throwable e) {
                        messageLiveData.postValue(e.getMessage());
                    }
 
                    @Override
                    public void onComplete() {
 
                    }
                });
    }
 
 
    /**
     * 获取出国境情况
     */
    public void getAbroad(){
        model.getGrowthExperienceAbroadCondition()
                .compose(RxUtils.schedulersTransformer())
                .subscribe(new Observer<ResultData<List<GrowthExperienceAbroadConditionBean>>>() {
                    @Override
                    public void onSubscribe(Disposable d) {
                        addSubscribe(d);
                    }
 
                    @Override
                    public void onNext(ResultData<List<GrowthExperienceAbroadConditionBean>> data) {
                        if (data.getCode() == CODE_SUCCESS){
                            abroadLiveData.postValue(data.getData());
                        }else {
                            messageLiveData.postValue(data.getMsg());
                        }
                    }
 
 
                    @Override
                    public void onError(Throwable e) {
                        messageLiveData.postValue(e.getMessage());
                    }
 
                    @Override
                    public void onComplete() {
 
                    }
                });
    }
 
 
 
    public MutableLiveData<List<GrowthExperienceBean>> getExperienceListLiveData() {
        if (experienceListLiveData == null){
            experienceListLiveData = new MutableLiveData<>();
        }
        return experienceListLiveData;
    }
 
    public void setExperienceListLiveData(MutableLiveData<List<GrowthExperienceBean>> experienceListLiveData) {
        this.experienceListLiveData = experienceListLiveData;
    }
 
    public MutableLiveData<List<GrowthExperienceRelationshipBean>> getRelationLiveData() {
        if (relationLiveData == null){
            relationLiveData = new MutableLiveData<>();
        }
        return relationLiveData;
    }
 
    public void setRelationLiveData(MutableLiveData<List<GrowthExperienceRelationshipBean>> relationLiveData) {
        this.relationLiveData = relationLiveData;
    }
 
    public MutableLiveData<GrowthExperienceInformationBean> getInfoLiveData() {
        if (infoLiveData == null){
            infoLiveData = new MutableLiveData<>();
        }
        return infoLiveData;
    }
 
    public void setInfoLiveData(MutableLiveData<GrowthExperienceInformationBean> infoLiveData) {
        this.infoLiveData = infoLiveData;
    }
    public void setHolderLiveData(MutableLiveData<List<GrowthExperienceHolderConditionBean>> holderLiveData) {
        this.holderLiveData = holderLiveData;
    }
 
    public MutableLiveData<List<GrowthExperienceHolderConditionBean>> getHolderLiveData() {
        if (holderLiveData == null){
            holderLiveData = new MutableLiveData<>();
        }
        return holderLiveData;
    }
 
    public void setAbroadLiveData(MutableLiveData<List<GrowthExperienceAbroadConditionBean>> abroadLiveData) {
        this.abroadLiveData = abroadLiveData;
    }
 
    public MutableLiveData<List<GrowthExperienceAbroadConditionBean>> getAbroadLiveData() {
        if (abroadLiveData == null){
            abroadLiveData = new MutableLiveData<>();
        }
        return abroadLiveData;
    }
 
 
 
    public MutableLiveData<List<GrowthExperienceAutobiographyBean>> getAutobiographyLiveData() {
        if (autobiographyLiveData == null){
            autobiographyLiveData = new MutableLiveData<>();
        }
        return autobiographyLiveData;
    }
 
    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;
    }
}