Advertisement
Guest User

Untitled

a guest
Jul 21st, 2019
98
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.82 KB | None | 0 0
  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. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement