Skip to content

Instantly share code, notes, and snippets.

@plusmobileapps
Created December 11, 2018 07:31
Show Gist options
  • Save plusmobileapps/7d8de1f55f0176d037cdc9dcc2a0172f to your computer and use it in GitHub Desktop.
Save plusmobileapps/7d8de1f55f0176d037cdc9dcc2a0172f to your computer and use it in GitHub Desktop.
class MainFragment : Fragment() {
val viewModel: MainViewModel by viewModel()
override fun onActivityCreated(savedInstanceState: Bundle?) {
super.onActivityCreated(savedInstanceState)
val adapter = RecyclerViewListAdapter(
carouselItemClickListener = { viewModel.onCarouselItemClicked(it) },
cardClickListener = { viewModel.onCardClicked(it) },
cardDeleteListener = { viewModel.onCardDeleted(it) },
glide = Glide.with(this)
)
view?.findViewById<RecyclerView>(R.id.recyclerview).apply {
this?.adapter = adapter
}
viewModel.getData().observe(this@MainFragment, Observer { data ->
adapter.submitList(data)
})
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment