belongs to Maven artifact com.android.support:recyclerview-v7:28.0.0-alpha1
SortedList
public
class
SortedList
extends Object
java.lang.Object | |
↳ | android.support.v7.util.SortedList<T> |
A Sorted list implementation that can keep items in order and also notify for changes in the
list
such that it can be bound to a RecyclerView.Adapter
.
It keeps items ordered using the compare(Object, Object)
method and uses
binary search to retrieve items. If the sorting criteria of your items may change, make sure you
call appropriate methods while editing them to avoid data inconsistencies.
You can control the order of items and change notifications via the SortedList.Callback
parameter.
Summary
Nested classes | |
---|---|
class |
SortedList.BatchedCallback<T2>
A callback implementation that can batch notify events dispatched by the SortedList. |
class |
SortedList.Callback<T2>
The class that controls the behavior of the |
Constants | |
---|---|
int |
INVALID_POSITION
Used by |
Public constructors | |
---|---|
SortedList(Class<T> klass, Callback<T> callback)
Creates a new SortedList of type T. |
|
SortedList(Class<T> klass, Callback<T> callback, int initialCapacity)
Creates a new SortedList of type T. |
Public methods | |
---|---|
int
|
add(T item)
Adds the given item to the list. |
void
|
addAll(T... items)
Adds the given items to the list. |
void
|
addAll(Collection<T> items)
Adds the given items to the list. |
void
|
addAll(T[] items, boolean mayModifyInput)
Adds the given items to the list. |
void
|
beginBatchedUpdates()
Batches adapter updates that happen after calling this method and before calling
|
void
|
clear()
Removes all items from the SortedList. |
void
|
endBatchedUpdates()
Ends the update transaction and dispatches any remaining event to the callback. |
T
|
get(int index)
Returns the item at the given index. |
int
|
indexOf(T item)
Returns the position of the provided item. |
void
|
recalculatePositionOfItemAt(int index)
This method can be used to recalculate the position of the item at the given index, without
triggering an |
boolean
|
remove(T item)
Removes the provided item from the list and calls |
T
|
removeItemAt(int index)
Removes the item at the given index and calls |
void
|
replaceAll(T... items)
Replaces the current items with the new items, dispatching |
void
|