Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class MainActivityViewModel(//...) :
- ViewModel() {
- //...
- val words: MediatorLiveData<PagedList<Meaning>> = MediatorLiveData()
- //...
- private fun addAllWordsAndRemoveSearch() {
- removeSearchObserver()
- if (!mapOfLiveData.containsKey(ALL)) {
- mapOfLiveData[ALL] = LivePagedListBuilder(dataSourceFactory, config).build()
- words.addSource(mapOfLiveData[ALL]!!) {
- words.value = it
- }
- }
- }
- private fun addSearchAndRemoveAllWords() {
- removeAllWordsObserver()
- if (!mapOfLiveData.containsKey(SEARCH)) {
- mapOfLiveData[SEARCH] = LivePagedListBuilder(searchDataSourceFactory, config).build()
- words.addSource(mapOfLiveData[SEARCH]!!) {
- words.value = it
- }
- }
- }
- //...
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement