Last active
March 31, 2017 09:15
-
-
Save amyu/1e4058b67b21fb11c060eee2f879c81b to your computer and use it in GitHub Desktop.
This file contains 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
import android.support.v7.util.DiffUtil | |
class DiffUtilCallback<T>(private val oldList: List<T>, private val newList: List<T>) : DiffUtil.Callback() { | |
override fun areItemsTheSame(oldItemPosition: Int, newItemPosition: Int): Boolean = oldList[oldItemPosition] == newList[newItemPosition] | |
override fun getOldListSize(): Int = oldList.size | |
override fun getNewListSize(): Int = newList.size | |
override fun areContentsTheSame(oldItemPosition: Int, newItemPosition: Int): Boolean = oldList[oldItemPosition]?.hashCode() == newList[newItemPosition]?.hashCode() | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment