The Android Developer Challenge is back! Submit your idea before December 2.

SparseArrayObjectAdapter

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

An ObjectAdapter implemented with a android.util.SparseArray. This class maintains an array of objects where each object is associated with an integer key which determines its order relative to other objects.

Summary

Inherited constants

Public constructors

<init>(presenterSelector: PresenterSelector!)

Constructs an adapter with the given PresenterSelector.

<init>(presenter: Presenter!)

Constructs an adapter with the given Presenter.

Constructs an adapter.

Public methods

open Unit
clear(key: Int)

Clears the given key and associated item from the adapter.

open Unit

Removes all items from this adapter, leaving it empty.

open Any!
get(position: Int)

open Int
indexOf(item: Any!)

Returns the index for the given item in the adapter.

open Int
indexOf(key: Int)

Returns the index for the given key in the adapter.

open Boolean

open Any!
lookup(key: Int)

Returns the object for the given key, or null if no mapping for that key exists.

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

Notify that the content of a range of items changed.

open Unit
set(key: Int, item: Any!)

Sets the item for the given key.

open Int

Inherited functions

Public constructors

<init>

SparseArrayObjectAdapter(presenterSelector: PresenterSelector!)

Constructs an adapter with the given PresenterSelector.

<init>

SparseArrayObjectAdapter(presenter: Presenter!)

Constructs an adapter with the given Presenter.

<init>

SparseArrayObjectAdapter()

Constructs an adapter.

Public methods

clear

open fun clear(key: Int): Unit

Clears the given key and associated item from the adapter.

Parameters
key Int: The key to be cleared.

clear

open fun clear(): Unit

Removes all items from this adapter, leaving it empty.

get

open fun get(position: Int): Any!

indexOf

open fun indexOf(item: Any!): Int

Returns the index for the given item in the adapter.

Parameters
item Any!: The item to find in the array.
Return
Int: Index of the item, or a negative value if not found.

indexOf

open fun indexOf(key: Int): Int

Returns the index for the given key in the adapter.

Parameters
key Int: The key to find in the array.
Return
Int: Index of the item, or a negative value if not found.

isImmediateNotifySupported

open fun isImmediateNotifySupported(): Boolean

lookup

open fun lookup(key: Int): Any!

Returns the object for the given key, or null if no mapping for that key exists.

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.

set

open fun set(key: Int, item: Any!): Unit

Sets the item for the given key.

Parameters
key Int: The key associated with the item.
item Int: The item associated with the key.

size

open fun size(): Int