SHARE
TWEET

Untitled

a guest Jul 21st, 2019 76 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. class MainActivityViewModel(//...) :
  2.     ViewModel() {
  3.     //...
  4.     val words: MediatorLiveData<PagedList<Meaning>> = MediatorLiveData()
  5.     //...
  6.    
  7.     private fun addAllWordsAndRemoveSearch() {
  8.         removeSearchObserver()
  9.         if (!mapOfLiveData.containsKey(ALL)) {
  10.             mapOfLiveData[ALL] = LivePagedListBuilder(dataSourceFactory, config).build()
  11.             words.addSource(mapOfLiveData[ALL]!!) {
  12.                 words.value = it
  13.             }
  14.         }
  15.     }
  16.    
  17.     private fun addSearchAndRemoveAllWords() {
  18.         removeAllWordsObserver()
  19.         if (!mapOfLiveData.containsKey(SEARCH)) {
  20.             mapOfLiveData[SEARCH] = LivePagedListBuilder(searchDataSourceFactory, config).build()
  21.             words.addSource(mapOfLiveData[SEARCH]!!) {
  22.                 words.value = it
  23.             }
  24.         }
  25.     }
  26.     //...
  27. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top