ObjectAdapter
abstract class ObjectAdapter
ArrayObjectAdapter |
An |
CursorObjectAdapter |
An |
PagingDataAdapter |
An |
SparseArrayObjectAdapter |
An |
Base class adapter to be used in leanback activities. Provides access to a data model and is decoupled from the presentation of the items via PresenterSelector.
Summary
Nested types |
|---|
abstract class ObjectAdapter.DataObserverA DataObserver can be notified when an ObjectAdapter's underlying data changes. |
Public constructors |
|---|
|
Constructs an adapter. |
ObjectAdapter(presenter: Presenter)Constructs an adapter that uses the given |
ObjectAdapter(presenterSelector: PresenterSelector)Constructs an adapter with the given |
Public functions |
|
|---|---|
abstract Any? |
Returns the item for the given position. |
Long |
Returns the id for the given position. |
Presenter? |
getPresenter(item: Any)Returns the |
PresenterSelector |
Returns the presenter selector for this ObjectAdapter. |
Boolean |
Returns true if the item ids are stable across changes to the underlying data. |
Boolean |
Returns true if the adapter pairs each underlying data change with a call to notify and false otherwise. |
Unit |
notifyItemRangeChanged(positionStart: Int, itemCount: Int)Notifies UI that some items has changed. |
Unit |
notifyItemRangeChanged(positionStart: Int, itemCount: Int, payload: Any?)Notifies UI that some items has changed. |
Unit |
registerObserver(observer: ObjectAdapter.DataObserver)Registers a DataObserver for data change notifications. |
Unit |
setHasStableIds(hasStableIds: Boolean)Sets whether the item ids are stable across changes to the underlying data. |
Unit |
setPresenterSelector(presenterSelector: PresenterSelector)Sets the presenter selector. |
abstract Int |
size()Returns the number of items in the adapter. |
Unit |
Unregisters all DataObservers for this ObjectAdapter. |
Unit |
unregisterObserver(observer: ObjectAdapter.DataObserver)Unregisters a DataObserver for data change notifications. |
Protected functions |
|
|---|---|
Unit |
Notifies UI that the underlying data has changed. |
Unit |
notifyItemMoved(fromPosition: Int, toPosition: Int)Notifies UI that item at fromPosition has been moved to toPosition. |
Unit |
notifyItemRangeInserted(positionStart: Int, itemCount: Int)Notifies UI that new items has been inserted. |
Unit |
notifyItemRangeRemoved(positionStart: Int, itemCount: Int)Notifies UI that some items that has been removed. |
Unit |
Called when |
Unit |
Called when |
Public constructors
ObjectAdapter
ObjectAdapter(presenter: Presenter)
Constructs an adapter that uses the given Presenter for all items.
ObjectAdapter
ObjectAdapter(presenterSelector: PresenterSelector)
Constructs an adapter with the given PresenterSelector.
Public functions
getPresenter
fun getPresenter(item: Any): Presenter?
Returns the Presenter for the given item from the adapter.
getPresenterSelector
fun getPresenterSelector(): PresenterSelector
Returns the presenter selector for this ObjectAdapter.
hasStableIds
fun hasStableIds(): Boolean
Returns true if the item ids are stable across changes to the underlying data. When this is true, clients of the ObjectAdapter can use getId to correlate Objects across changes.
isImmediateNotifySupported
fun isImmediateNotifySupported(): Boolean
Returns true if the adapter pairs each underlying data change with a call to notify and false otherwise.
notifyItemRangeChanged
fun notifyItemRangeChanged(positionStart: Int, itemCount: Int): Unit
Notifies UI that some items has changed.
notifyItemRangeChanged
fun notifyItemRangeChanged(positionStart: Int, itemCount: Int, payload: Any?): Unit
Notifies UI that some items has changed.
registerObserver
fun registerObserver(observer: ObjectAdapter.DataObserver): Unit
Registers a DataObserver for data change notifications.
setHasStableIds
fun setHasStableIds(hasStableIds: Boolean): Unit
Sets whether the item ids are stable across changes to the underlying data.
setPresenterSelector
fun setPresenterSelector(presenterSelector: PresenterSelector): Unit
Sets the presenter selector. May not be null.
unregisterAllObservers
fun unregisterAllObservers(): Unit
Unregisters all DataObservers for this ObjectAdapter.
unregisterObserver
fun unregisterObserver(observer: ObjectAdapter.DataObserver): Unit
Unregisters a DataObserver for data change notifications.
Protected functions
notifyChanged
protected fun notifyChanged(): Unit
Notifies UI that the underlying data has changed.
notifyItemMoved
protected fun notifyItemMoved(fromPosition: Int, toPosition: Int): Unit
Notifies UI that item at fromPosition has been moved to toPosition.
notifyItemRangeInserted
protected fun notifyItemRangeInserted(positionStart: Int, itemCount: Int): Unit
Notifies UI that new items has been inserted.
notifyItemRangeRemoved
protected fun notifyItemRangeRemoved(positionStart: Int, itemCount: Int): Unit
Notifies UI that some items that has been removed.
onHasStableIdsChanged
protected fun onHasStableIdsChanged(): Unit
Called when setHasStableIds is called and the status of stable ids has changed.
onPresenterSelectorChanged
protected fun onPresenterSelectorChanged(): Unit
Called when setPresenterSelector is called and the PresenterSelector differs from the previous one.