Last active
March 5, 2017 00:38
-
-
Save roschlau/2c57f050222a51cf7002a8a17c03082d to your computer and use it in GitHub Desktop.
Default implementation of a DiffUtil.Callback
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 | |
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