Skip to content

Instantly share code, notes, and snippets.

Created Aug 16, 2021
What would you like to do?
fun bindItemViewModels(recyclerView: RecyclerView, itemViewModels: List<ItemViewModel>?) {
val adapter = getOrCreateAdapter(recyclerView)
private fun getOrCreateAdapter(recyclerView: RecyclerView): BindableRecyclerViewAdapter {
return if (recyclerView.adapter != null && recyclerView.adapter is BindableRecyclerViewAdapter) {
recyclerView.adapter as BindableRecyclerViewAdapter
} else {
val bindableRecyclerAdapter = BindableRecyclerViewAdapter()
recyclerView.adapter = bindableRecyclerAdapter
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment