Skip to content

Instantly share code, notes, and snippets.

@hafizrahman
Created April 20, 2020 08:06
Show Gist options
  • Save hafizrahman/94d232e730050d8a5eab2c27f5af012b to your computer and use it in GitHub Desktop.
Save hafizrahman/94d232e730050d8a5eab2c27f5af012b to your computer and use it in GitHub Desktop.
Observe the MediatorLiveData given by ViewModel, and update RecyclerViewAdapter accordingly.
mainViewModel = ViewModelProvider(activity!!).get(MainViewModel::class.java)
// New observer
mainViewModel.getAllData()?.observe(viewLifecycleOwner,
Observer { subjectsAndRemindersPair ->
view.sro_subject_list.adapter = SubjectRecyclerViewAdapter(
subjectsAndRemindersPair.first,
subjectsAndRemindersPair.second,
listener)
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment