Callback
abstract class Callback<T2 : Any!> : Comparator<T2>, ListUpdateCallback
kotlin.Any | |
↳ | androidx.recyclerview.widget.SortedList.Callback |
The class that controls the behavior of the SortedList
.
It defines how items should be sorted and how duplicates should be handled.
SortedList calls the callback methods on this class to notify changes about the underlying data.
Summary
Public constructors | |
---|---|
<init>() The class that controls the behavior of the |
Public methods | |
---|---|
abstract Boolean |
areContentsTheSame(oldItem: T2, newItem: T2) Called by the SortedList when it wants to check whether two items have the same data or not. |
abstract Boolean |
areItemsTheSame(item1: T2, item2: T2) Called by the SortedList to decide whether two objects represent the same Item or not. |
abstract Int |
compare(o1: T2, o2: T2) Similar to |
open Any? |
getChangePayload(item1: T2, item2: T2) When |
abstract Unit |
Called by the SortedList when the item at the given position is updated. |
open Unit |
Inherited functions | |
---|---|
Public constructors
<init>
Callback()
The class that controls the behavior of the SortedList
.
It defines how items should be sorted and how duplicates should be handled.
SortedList calls the callback methods on this class to notify changes about the underlying data.
Public methods
areContentsTheSame
abstract fun areContentsTheSame(
oldItem: T2,
newItem: T2
): Boolean
Called by the SortedList when it wants to check whether two items have the same data or not. SortedList uses this information to decide whether it should call onChanged(int, int)
or not.
SortedList uses this method to check equality instead of Object#equals(Object)
so that you can change its behavior depending on your UI.
For example, if you are using SortedList with a RecyclerView.Adapter
, you should return whether the items' visual representations are the same or not.
Parameters | |
---|---|
oldItem |
T2: The previous representation of the object. |
newItem |
T2: The new object that replaces the previous one. |
Return | |
---|---|
Boolean |
True if the contents of the items are the same or false if they are different. |
areItemsTheSame
abstract fun areItemsTheSame(