Skip to content

Instantly share code, notes, and snippets.

@steliosfran
Created March 13, 2022 23:55
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save steliosfran/7a7d18b428f45a8ac26c7d238a2bdc77 to your computer and use it in GitHub Desktop.
Save steliosfran/7a7d18b428f45a8ac26c7d238a2bdc77 to your computer and use it in GitHub Desktop.
class MyFragment : Fragment() {
// ...
fun setupAdapter() {
myAdapter = MyAdapter(context, viewLifecycleOwner)
}
}
class MyAdapter(
private val context: Context,
private val viewLifecycleOwner: LifecycleOwner
) : RecyclerView.Adapter<RecyclerView.ViewHolder>() {
init {
viewModel.items.observe(viewLifecycleOwner) {
// Update items and dispatch updates
}
}
// ...
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment