ArrayObjectAdapter

open class ArrayObjectAdapter : ObjectAdapter
kotlin.Any
   ↳ androidx.leanback.widget.ObjectAdapter
   ↳ androidx.leanback.widget.ArrayObjectAdapter

An ObjectAdapter implemented with an ArrayList.

Summary

Inherited constants

Public constructors

<init>(presenterSelector: PresenterSelector!)

Constructs an adapter with the given PresenterSelector.

<init>(presenter: Presenter!)

Constructs an adapter that uses the given Presenter for all items.

Constructs an adapter.

Public methods

open Unit
add(item: Any!)

Adds an item to the end of the adapter.

open Unit
add(index: Int, item: Any!)

Inserts an item into this adapter at the specified index.

open Unit
addAll(index: Int, items: MutableCollection<Any?>!)

Adds the objects in the given collection to the adapter, starting at the given index.

open Unit

Removes all items from this adapter, leaving it empty.

open Any!
get(index: Int)

open Int
indexOf(item: Any!)

Returns the index for the first occurrence of item in the adapter, or -1 if not found.

open Boolean

open Unit
move(fromPosition: Int, toPosition: Int)

Moved the item at fromPosition to toPosition.

open Unit
notifyArrayItemRangeChanged(positionStart: Int, itemCount: Int)

Notify that the content of a range of items changed.

open Boolean
remove(item: Any!)

Removes the first occurrence of the given item from the adapter.

open Int
removeItems(position: Int, count: Int)

Removes a range of items from the adapter.

open Unit
replace(position: Int, item: Any!)

Replaces item at position with a new item and calls notifyItemRangeChanged() at the given position.

open Unit
setItems(itemList: MutableList<Any?>!, callback: DiffCallback<Any!>!)

Set a new item list to adapter.

open Int

open MutableList<E>!

Gets a read-only view of the list of object of this ArrayObjectAdapter.

Inherited functions

Public constructors

<init>

ArrayObjectAdapter(presenterSelector: PresenterSelector!)

Constructs an adapter with the given PresenterSelector.

<init>

ArrayObjectAdapter(presenter: Presenter!)

Constructs an adapter that uses the given Presenter for all items.

<init>

ArrayObjectAdapter()

Constructs an adapter.

Public methods

add

open 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

open 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.

Parameters
index Int: The index at which the item should be inserted.
item Int: The item to insert into the adapter.

addAll

open fun addAll(index: Int, items: MutableCollection<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 Int: A Collection of items to insert.

clear

open fun clear(): Unit

Removes all items from this adapter, leaving it empty.

get

open fun get(index: Int): Any!

indexOf

open 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.
Return
Int: Index of the first occurrence of the item in the adapter, or -1 if not found.

isImmediateNotifySupported

open fun isImmediateNotifySupported(): Boolean

move

open fun move(fromPosition: Int, toPosition: Int): Unit

Moved the item at fromPosition to toPosition.

Parameters
fromPosition Int: Previous position of the item.
toPosition Int: New position of the item.

notifyArrayItemRangeChanged

open 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.

Parameters
positionStart Int: The position of first item that has changed.
itemCount Int: The count of how many items have changed.

remove

open 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.
Return
Boolean: True if the item was found and thus removed from the adapter.

removeItems

open 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.
Return
Int: The number of items removed.

replace

open 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.

Parameters
position Int: The index of item to replace.
item Int: The new item to be placed at given position.

setItems

open fun setItems(itemList: MutableList<Any?>!, callback: DiffCallback<Any!>!): Unit

Set a new item list to adapter. The DiffUtil will compute the difference and dispatch it to specified position.

Parameters
itemList MutableList<Any?>!: List of new Items
callback MutableList<Any?>!: Optional DiffCallback Object to compute the difference between the old data set and new data set. When null, notifyChanged() will be fired.

size

open fun size(): Int

unmodifiableList

open fun <E : Any!> unmodifiableList(): MutableList<E>!

Gets a read-only view of the list of object of this ArrayObjectAdapter.