Skip to content

Instantly share code, notes, and snippets.

@mucahidkambur
Created October 27, 2019 11:19
Show Gist options
  • Save mucahidkambur/599bdb78473aae8d22180a39867b0f56 to your computer and use it in GitHub Desktop.
Save mucahidkambur/599bdb78473aae8d22180a39867b0f56 to your computer and use it in GitHub Desktop.
import androidx.recyclerview.widget.DiffUtil
class NumberDiffCallBack (
private val oldNumbers: List<Int>,
private val newNumbers: List<Int>
) : DiffUtil.Callback() {
override fun getOldListSize(): Int = oldNumbers.size
override fun getNewListSize(): Int = newNumbers.size
override fun areItemsTheSame(oldItemPosition: Int, newItemPosition: Int): Boolean {
return oldNumbers[oldItemPosition] == newNumbers[newItemPosition]
}
override fun areContentsTheSame(oldItemPosition: Int, newItemPosition: Int): Boolean {
return oldNumbers[oldItemPosition] == newNumbers[newItemPosition]
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment