ArrayObjectAdapter
class ArrayObjectAdapter : ObjectAdapter
An ObjectAdapter
implemented with an ArrayList
.
Summary
Public constructors |
---|
Constructs an adapter. |
ArrayObjectAdapter(presenter: Presenter) Constructs an adapter that uses the given |
ArrayObjectAdapter(presenterSelector: PresenterSelector) Constructs an adapter with the given |
Public functions |
|
---|---|
Unit |
Adds an item to the end of the adapter. |
Unit |
Inserts an item into this adapter at the specified index. |
Unit |
addAll(index: Int, items: (Mutable)Collection<Any!>) Adds the objects in the given collection to the adapter, starting at the given index. |
Unit |
clear() Removes all items from this adapter, leaving it empty. |
Any? |
Returns the item for the given position. |
Int |
Returns the index for the first occurrence of item in the adapter, or -1 if not found. |
Boolean |
Returns true if the adapter pairs each underlying data change with a call to notify and false otherwise. |
Unit |
Moved the item at fromPosition to toPosition. |
Unit |
notifyArrayItemRangeChanged(positionStart: Int, itemCount: Int) Notify that the content of a range of items changed. |
Boolean |
Removes the first occurrence of the given item from the adapter. |
Int |
removeItems(position: Int, count: Int) Removes a range of items from the adapter. |
Unit |
Replaces item at position with a new item and calls notifyItemRangeChanged() at the given position. |
Unit |
setItems(itemList: (Mutable)List, callback: DiffCallback?) Set a new item list to adapter. |
Int |
size() Returns the number of items in the adapter. |
(Mutable)List<E!> |
<E> unmodifiableList() Gets a read-only view of the list of object of this ArrayObjectAdapter. |
Inherited functions |
||||||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
Public constructors
ArrayObjectAdapter
ArrayObjectAdapter(presenter: Presenter)
Constructs an adapter that uses the given Presenter
for all items.
ArrayObjectAdapter
ArrayObjectAdapter(presenterSelector: PresenterSelector)
Constructs an adapter with the given PresenterSelector
.
Public functions
add
fun add(item: Any): Unit
Adds an item to the end of the adapter.
Parameters | |
---|---|
item: Any |
The item to add to the end of the adapter. |
add
fun add(index: Int, item: Any): Unit
Inserts an item into this adapter at the specified index. If the index is >size
an exception will be thrown.
addAll
fun addAll(index: Int, items: (Mutable)Collection<Any!>): Unit
Adds the objects in the given collection to the adapter, starting at the given index. If the index is >= size
an exception will be thrown.
Parameters | |
---|---|
index: Int |
The index at which the items should be inserted. |
items: (Mutable)Collection<Any!> |
A |
indexOf
fun indexOf(item: Any): Int
Returns the index for the first occurrence of item in the adapter, or -1 if not found.
Parameters | |
---|---|
item: Any |
The item to find in the list. |
Returns | |
---|---|
Int |
Index of the first occurrence of the item in the adapter, or -1 if not found. |
isImmediateNotifySupported
fun isImmediateNotifySupported(): Boolean
Returns true if the adapter pairs each underlying data change with a call to notify and false otherwise.
move
fun move(fromPosition: Int, toPosition: Int): Unit
Moved the item at fromPosition to toPosition.
notifyArrayItemRangeChanged
fun notifyArrayItemRangeChanged(positionStart: Int, itemCount: Int): Unit
Notify that the content of a range of items changed. Note that this is not same as items being added or removed.
remove
fun remove(item: Any): Boolean
Removes the first occurrence of the given item from the adapter.
Parameters | |
---|---|
item: Any |
The item to remove from the adapter. |
Returns | |
---|---|
Boolean |
True if the item was found and thus removed from the adapter. |
removeItems
fun removeItems(position: Int, count: Int): Int
Removes a range of items from the adapter. The range is specified by giving the starting position and the number of elements to remove.
Parameters | |
---|---|
position: Int |
The index of the first item to remove. |
count: Int |
The number of items to remove. |
Returns | |
---|---|
Int |
The number of items removed. |
replace
fun replace(position: Int, item: Any): Unit
Replaces item at position with a new item and calls notifyItemRangeChanged() at the given position. Note that this method does not compare new item to existing item.
setItems
fun setItems(itemList: (Mutable)List, callback: DiffCallback?): Unit
Set a new item list to adapter. The DiffUtil will compute the difference and dispatch it to specified position.
Parameters | |
---|---|
itemList: (Mutable)List |
List of new Items |
callback: DiffCallback? |
Optional DiffCallback Object to compute the difference between the old data set and new data set. When null, |
unmodifiableList
fun <E> unmodifiableList(): (Mutable)List<E!>
Gets a read-only view of the list of object of this ArrayObjectAdapter.