Skip to content

Instantly share code, notes, and snippets.

@1jGabriel
Created July 19, 2020 15:32
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 1jGabriel/23186f69f6271c82d7530c5c767ccebe to your computer and use it in GitHub Desktop.
Save 1jGabriel/23186f69f6271c82d7530c5c767ccebe to your computer and use it in GitHub Desktop.
Adapter utilizando PagingV3
class MyAdapter : PagingDataAdapter<MyModel, MyAdapter.MyViewHolder>(DiffUtilCallback()) {
// a implementação do corpo do adapter permanece a mesma
}
class DiffUtilCallBack : DiffUtil.ItemCallback<MyModel>() {
override fun areItemsTheSame(oldItem: MyModel, newItem: MyModel): Boolean {
return oldItem.id == newItem.id
}
override fun areContentsTheSame(oldItem: MyModel, newItem: MyModel): Boolean {
return oldItem == newItem
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment