Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Default implementation of a DiffUtil.Callback
import android.support.v7.util.DiffUtil
open class DiffUtilCallback<T>(val oldList: List<T>, val newList: List<T>) : DiffUtil.Callback() {
override fun areItemsTheSame(oldItemPosition: Int, newItemPosition: Int)
= oldList[oldItemPosition] == newList[newItemPosition]
override fun getOldListSize()
= oldList.size
override fun getNewListSize()
= newList.size
override fun areContentsTheSame(oldItemPosition: Int, newItemPosition: Int)
= oldList[oldItemPosition] == newList[newItemPosition]
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment