SortedListAdapterCallback
abstract class SortedListAdapterCallback<T2 : Any!> : SortedList.Callback<T2>
A SortedList.Callback
implementation that can bind a SortedList
to a RecyclerView.Adapter
.
Summary
Public constructors
|
Creates a SortedList.Callback that will forward data change events to the provided Adapter.
|
Inherited functions
|
From class Callback
Boolean |
areContentsTheSame(oldItem: T2, newItem: T2)
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.
|
Boolean |
areItemsTheSame(item1: T2, item2: T2)
Called by the SortedList to decide whether two objects represent the same Item or not.
For example, if your items have unique ids, this method should check their equality.
|
Int |
compare(o1: T2, o2: T2)
Similar to java.util.Comparator#compare(Object, Object) , should compare two and return how they should be ordered.
|
Any? |
getChangePayload(item1: T2, item2: T2)
When areItemsTheSame(T2, T2) returns true for two items and areContentsTheSame(T2, T2) returns false for them, Callback calls this method to get a payload about the change.
For example, if you are using Callback with RecyclerView , you can return the particular field that changed in the item and your ItemAnimator can use that information to run the correct animation.
Default implementation returns null .
|
|
|
Public constructors
Public methods
onChanged
open fun onChanged(position: Int, count: Int): Unit
onChanged
open fun onChanged(position: Int, count: Int, payload: Any?): Unit
onInserted
open fun onInserted(position: Int, count: Int): Unit
onMoved
open fun onMoved(fromPosition: Int, toPosition: Int): Unit
onRemoved
open fun onRemoved(position: Int, count: Int): Unit