CursorObjectAdapter
public class CursorObjectAdapter extends ObjectAdapter
| java.lang.Object | ||
| ↳ | androidx.leanback.widget.ObjectAdapter | |
| ↳ | androidx.leanback.widget.CursorObjectAdapter |
An ObjectAdapter implemented with a Cursor.
Summary
Public constructors |
|---|
|
Constructs an adapter. |
CursorObjectAdapter(Presenter presenter)Constructs an adapter that uses the given |
CursorObjectAdapter(PresenterSelector presenterSelector)Constructs an adapter with the given |
Public methods |
|
|---|---|
void |
changeCursor(Cursor cursor)Changes the underlying cursor to a new cursor. |
void |
close()Closes this adapter, closing the backing |
@Nullable Object |
get(int index)Returns the item for the given position. |
final Cursor |
Returns the |
final CursorMapper |
Returns the |
boolean |
isClosed()Returns true if the adapter, and hence the backing |
boolean |
Returns true if the adapter pairs each underlying data change with a call to notify and false otherwise. |
final void |
setMapper(CursorMapper mapper)Sets the |
int |
size()Returns the number of items in the adapter. |
Cursor |
swapCursor(Cursor cursor)Swap in a new Cursor, returning the old Cursor. |
Protected methods |
|
|---|---|
final void |
invalidateCache(int index)Removes an item from the cache. |
final void |
invalidateCache(int index, int count)Removes |
void |
Called whenever the cursor changes. |
void |
Called when |
Inherited Constants |
||
|---|---|---|
|
Inherited methods |
||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
Public constructors
CursorObjectAdapter
public CursorObjectAdapter(Presenter presenter)
Constructs an adapter that uses the given Presenter for all items.
CursorObjectAdapter
public CursorObjectAdapter(PresenterSelector presenterSelector)
Constructs an adapter with the given PresenterSelector.
Public methods
changeCursor
public void changeCursor(Cursor cursor)
Changes the underlying cursor to a new cursor. If there is an existing cursor it will be closed if it is different than the new cursor.
| Parameters | |
|---|---|
Cursor cursor |
The new cursor to be used. |
getMapper
public final CursorMapper getMapper()
Returns the CursorMapper used to convert Cursor rows into Objects.
isClosed
public boolean isClosed()
Returns true if the adapter, and hence the backing Cursor, is closed; false otherwise.
isImmediateNotifySupported
public boolean isImmediateNotifySupported()
Returns true if the adapter pairs each underlying data change with a call to notify and false otherwise.
setMapper
public final void setMapper(CursorMapper mapper)
Sets the CursorMapper used to convert Cursor rows into Objects.
swapCursor
public Cursor swapCursor(Cursor cursor)
Swap in a new Cursor, returning the old Cursor. Unlike changeCursor(Cursor), the returned old Cursor is not closed.
| Parameters | |
|---|---|
Cursor cursor |
The new cursor to be used. |
Protected methods
invalidateCache
protected final void invalidateCache(int index)
Removes an item from the cache. This will force the item to be re-read from the data source the next time get is called.
invalidateCache
protected final void invalidateCache(int index, int count)
Removes count items starting at index.
onMapperChanged
protected void onMapperChanged()
Called when setMapper is called and a different mapper is provided.