Skip to content

Instantly share code, notes, and snippets.

@nxsyed
Created February 19, 2019 19:11
Show Gist options
  • Select an option

  • Save nxsyed/27947bf40938473418112614d6d9a523 to your computer and use it in GitHub Desktop.

Select an option

Save nxsyed/27947bf40938473418112614d6d9a523 to your computer and use it in GitHub Desktop.
class SpotDiffCallback(
private val old: List<Spot>,
private val new: List<Spot>
) : DiffUtil.Callback() {
override fun getOldListSize(): Int {
return old.size
}
override fun getNewListSize(): Int {
return new.size
}
override fun areItemsTheSame(oldPosition: Int, newPosition: Int): Boolean {
return old[oldPosition].id == new[newPosition].id
}
override fun areContentsTheSame(oldPosition: Int, newPosition: Int): Boolean {
return old[oldPosition] == new[newPosition]
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment