| | |
| | | package com.duqing.missions.ui.main.home; |
| | | |
| | | import androidx.lifecycle.LiveData; |
| | | import androidx.lifecycle.MutableLiveData; |
| | | import androidx.lifecycle.ViewModel; |
| | | |
| | | import com.duqing.missions.base.model.BaseLoadPageViewModel; |
| | | import com.duqing.missions.ui.main.home.model.MissionDesc; |
| | | |
| | | import java.util.ArrayList; |
| | | import java.util.List; |
| | | |
| | | public class HomeViewModel extends ViewModel { |
| | | public class HomeViewModel extends BaseLoadPageViewModel { |
| | | |
| | | private MutableLiveData<String> mText; |
| | | private MutableLiveData<List<MissionDesc>> topMissions = new MutableLiveData<>(); |
| | | private MutableLiveData<List<MissionDesc>> recommendMissions = new MutableLiveData<>(); |
| | | |
| | | public HomeViewModel() { |
| | | mText = new MutableLiveData<>(); |
| | | mText.setValue("This is home fragment"); |
| | | } |
| | | |
| | | public LiveData<String> getText() { |
| | | return mText; |
| | | } |
| | | |
| | | public MutableLiveData<List<MissionDesc>> getTopMissions() { |
| | | return topMissions; |
| | |
| | | return recommendMissions; |
| | | } |
| | | |
| | | @Override |
| | | public void onRefresh(){ |
| | | List<MissionDesc> list = topMissions.getValue() == null? new ArrayList<>() :topMissions.getValue(); |
| | | list.clear(); |
| | |
| | | recommendMissions.setValue(list2); |
| | | } |
| | | |
| | | @Override |
| | | public void onLoadMore(){ |
| | | List<MissionDesc> list = recommendMissions.getValue() == null? new ArrayList<>():recommendMissions.getValue() ; |
| | | list.add(new MissionDesc()); |