Created
March 21, 2018 01:44
-
-
Save CDRussell/2e9b046c73303a45a8f0d1fd88c702f3 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class TaskDiffCallback : DiffUtil.ItemCallback<Task>() { | |
override fun areItemsTheSame(oldItem: Task?, newItem: Task?): Boolean { | |
return oldItem?.id == newItem?.id | |
} | |
override fun areContentsTheSame(oldItem: Task?, newItem: Task?): Boolean { | |
return oldItem == newItem | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Thanks for this, it's very helpful.
Just as a comment, I'm not sure if I'm using a different version of DiffUtil, but the parameters of the two methods are specified as @nonnull, hence the ? needs to be removed on them to make this work. I'm no expert, so I welcome your opinion on this!