public
abstract
class
ObjectAdapter
extends Object
java.lang.Object | |
↳ | android.support.v17.leanback.widget.ObjectAdapter |
Known Direct Subclasses |
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
.
Nested classes | |
---|---|
class |
ObjectAdapter.DataObserver
A DataObserver can be notified when an ObjectAdapter's underlying data changes. |
Constants | |
---|---|
int |
NO_ID
Indicates that an id has not been set. |
Public constructors | |
---|---|
ObjectAdapter(PresenterSelector presenterSelector)
Constructs an adapter with the given |
|
ObjectAdapter(Presenter presenter)
Constructs an adapter that uses the given |
|
ObjectAdapter()
Constructs an adapter. |
Public methods | |
---|---|
abstract
Object
|
get(int position)
Returns the item for the given position. |
long
|
getId(int position)
Returns the id for the given position. |
final
Presenter
|
getPresenter(Object item)
Returns the |
final
PresenterSelector
|
getPresenterSelector()
Returns the presenter selector for this ObjectAdapter. |
final
boolean
|
hasStableIds()
Returns true if the item ids are stable across changes to the underlying data. |
final
void
|
registerObserver(ObjectAdapter.DataObserver observer)
Registers a DataObserver for data change notifications. |
final
void
|
setHasStableIds(boolean hasStableIds)
Sets whether the item ids are stable across changes to the underlying data. |
final
void
|
setPresenterSelector(PresenterSelector presenterSelector)
Sets the presenter selector. |
abstract
int
|
size()
Returns the number of items in the adapter. |
final
void
|
unregisterAllObservers()
Unregisters all DataObservers for this ObjectAdapter. |
final
void
|
unregisterObserver(ObjectAdapter.DataObserver observer)
Unregisters a DataObserver for data change notifications. |
Protected methods | |
---|---|
final
void
|
notifyChanged()
|
final
void
|
notifyItemRangeChanged(int positionStart, int itemCount)
|
final
void
|
notifyItemRangeInserted(int positionStart, int itemCount)
|
final
void
|
notifyItemRangeRemoved(int positionStart, int itemCount)
|
void
|
onHasStableIdsChanged()
Called when |
void
|
onPresenterSelectorChanged()
Called when |
Inherited methods | |
---|---|
From
class
java.lang.Object
|
int NO_ID
Indicates that an id has not been set.
Constant Value: -1 (0xffffffff)
ObjectAdapter (PresenterSelector presenterSelector)
Constructs an adapter with the given PresenterSelector
.
Parameters | |
---|---|
presenterSelector |
PresenterSelector
|
ObjectAdapter (Presenter presenter)
Constructs an adapter that uses the given Presenter
for all items.
Parameters | |
---|---|
presenter |
Presenter
|
ObjectAdapter ()
Constructs an adapter.
Object get (int position)
Returns the item for the given position.
Parameters | |
---|---|
position |
int
|
Returns | |
---|---|
Object |
long getId (int position)
Returns the id for the given position.
Parameters | |
---|---|
position |
int
|
Returns | |
---|---|
long |
Presenter getPresenter (Object item)
Returns the Presenter
for the given item from the adapter.
Parameters | |
---|---|
item |
Object
|
Returns | |
---|---|
Presenter |
PresenterSelector getPresenterSelector ()
Returns the presenter selector for this ObjectAdapter.
Returns | |
---|---|
PresenterSelector |
boolean hasStableIds ()
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(int)
to correlate Objects across changes.
Returns | |
---|---|
boolean |
void registerObserver (ObjectAdapter.DataObserver observer)
Registers a DataObserver for data change notifications.
Parameters | |
---|---|
observer |
ObjectAdapter.DataObserver
|
void setHasStableIds (boolean hasStableIds)
Sets whether the item ids are stable across changes to the underlying data.
Parameters | |
---|---|
hasStableIds |
boolean
|
void setPresenterSelector (PresenterSelector presenterSelector)
Sets the presenter selector. May not be null.
Parameters | |
---|---|
presenterSelector |
PresenterSelector
|
int size ()
Returns the number of items in the adapter.
Returns | |
---|---|
int |
void unregisterAllObservers ()
Unregisters all DataObservers for this ObjectAdapter.
void unregisterObserver (ObjectAdapter.DataObserver observer)
Unregisters a DataObserver for data change notifications.
Parameters | |
---|---|
observer |
ObjectAdapter.DataObserver
|
void notifyChanged ()
void notifyItemRangeChanged (int positionStart, int itemCount)
Parameters | |
---|---|
positionStart |
int
|
itemCount |
int
|
void notifyItemRangeInserted (int positionStart, int itemCount)
Parameters | |
---|---|
positionStart |
int
|
itemCount |
int
|
void notifyItemRangeRemoved (int positionStart, int itemCount)
Parameters | |
---|---|
positionStart |
int
|
itemCount |
int
|
void onHasStableIdsChanged ()
Called when setHasStableIds(boolean)
is called and the status
of stable ids has changed.
void onPresenterSelectorChanged ()
Called when setPresenterSelector(PresenterSelector)
is called
and the PresenterSelector differs from the previous one.