Skip to content

Instantly share code, notes, and snippets.

@tfcporciuncula
Created January 14, 2019 14:32
Show Gist options
  • Save tfcporciuncula/89ddc6109ee644819b276bbe8baacff7 to your computer and use it in GitHub Desktop.
Save tfcporciuncula/89ddc6109ee644819b276bbe8baacff7 to your computer and use it in GitHub Desktop.
BooksAdapter with multiple item types
class BooksAdapter : DataBindingAdapter<Listable>(DiffCallback()) {
class DiffCallback : DiffUtil.ItemCallback<Listable>() {
// your DiffCallback implementation
}
override fun getItemViewType(position: Int) = if (getItem(position) is Book) {
R.layout.item_book
} else {
R.layout.item_section
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment