SortedListAdapterCallback


public abstract class SortedListAdapterCallback<T2> extends SortedList.Callback


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.

Public methods

void
onChanged(int position, int count)

Called by the SortedList when the item at the given position is updated.

void
onChanged(int position, int count, Object payload)
void
onInserted(int position, int count)

Called when count} number of items are inserted at the given position.

void
onMoved(int fromPosition, int toPosition)

Called when an item changes its position in the list.

void
onRemoved(int position, int count)

Called when count} number of items are removed from the given position.

Inherited methods

From java.util.Comparator
abstract int
compare(T p, T p1)
static Comparator<T>
<T, U> comparing(
    Function<T, U> keyExtractor,
    Comparator<U> keyComparator
)
static Comparator<T>
<T> comparingDouble(ToDoubleFunction<T> keyExtractor)
static Comparator<T>
<T> comparingInt(ToIntFunction<T> keyExtractor)
static Comparator<T>
<T> comparingLong(ToLongFunction<T> keyExtractor)
static Comparator<T>
<T extends Comparable<T>> naturalOrder()
static Comparator<T>
<T> nullsFirst(Comparator<T> comparator)
static Comparator<T>
<T> nullsLast(Comparator<T> comparator)
static Comparator<T>
<T extends Comparable<T>> reverseOrder()
Comparator<T>
Comparator<T>
Comparator<T>
Comparator<T>
Comparator<T>
From androidx.recyclerview.widget.ListUpdateCallback
abstract void
onChanged(int position, int count, @Nullable Object payload)

Called when count number of items are updated at the given position.

From androidx.recyclerview.widget.SortedList.Callback
abstract boolean
areContentsTheSame(T2 oldItem, T2 newItem)

Called by the SortedList when it wants to check whether two items have the same data or not.

abstract boolean
areItemsTheSame(T2 item1, T2 item2)

Called by the SortedList to decide whether two objects represent the same Item or not.

abstract int
compare(T2 o1, T2 o2)

Similar to compare, should compare two and return how they should be ordered.

@Nullable Object
getChangePayload(T2 item1, T2 item2)

When areItemsTheSame returns true for two items and areContentsTheSame returns false for them, Callback calls this method to get a payload about the change.

Public constructors

SortedListAdapterCallback

Added in 1.3.0
public SortedListAdapterCallback(RecyclerView.Adapter<Object> adapter)

Creates a SortedList.Callback that will forward data change events to the provided Adapter.

Parameters
RecyclerView.Adapter<Object> adapter

The Adapter instance which should receive events from the SortedList.

Public methods

onChanged

Added in 1.4.0-rc01
public void onChanged(int position, int count)

Called by the SortedList when the item at the given position is updated.

onChanged

public void onChanged(int position, int count, Object payload)

onInserted

Added in 1.4.0-rc01
public void onInserted(int position, int count)

Called when count} number of items are inserted at the given position.

onMoved

Added in 1.4.0-rc01
public void onMoved(int fromPosition, int toPosition)

Called when an item changes its position in the list.

onRemoved

Added in 1.4.0-rc01
public void onRemoved(int position, int count)

Called when count} number of items are removed from the given position.