Android APIs
public class

CursorObjectAdapter

extends ObjectAdapter
java.lang.Object
   ↳ android.support.v17.leanback.widget.ObjectAdapter
     ↳ android.support.v17.leanback.widget.CursorObjectAdapter

Class Overview

An ObjectAdapter implemented with a Cursor.

Summary

[Expand]
Inherited Constants
From class android.support.v17.leanback.widget.ObjectAdapter
Public Constructors
CursorObjectAdapter(PresenterSelector presenterSelector)
Construct an adapter with the given PresenterSelector.
CursorObjectAdapter(Presenter presenter)
Construct an adapter that uses the given Presenter for all items.
CursorObjectAdapter()
Construct an adapter.
Public Methods
void changeCursor(Cursor cursor)
Change the underlying cursor to a new cursor.
void close()
Closes this adapter, closing the backing Cursor as well.
Object get(int index)
Returns the item for the given position.
final Cursor getCursor()
Gets the Cursor backing the adapter.
final CursorMapper getMapper()
Gets the CursorMapper used to convert Cursor rows into Objects.
boolean isClosed()
Checks whether the adapter, and hence the backing Cursor, is closed.
final void setMapper(CursorMapper mapper)
Sets the CursorMapper used to convert Cursor rows into Objects.
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)
Remove an item from the cache.
final void invalidateCache(int index, int count)
Remove count items starting at index.
void onCursorChanged()
Called whenever the cursor changes.
void onMapperChanged()
Called when setMapper(CursorMapper) is called and a different mapper is provided.
[Expand]
Inherited Methods
From class android.support.v17.leanback.widget.ObjectAdapter
From class java.lang.Object

Public Constructors

public CursorObjectAdapter (PresenterSelector presenterSelector)

Construct an adapter with the given PresenterSelector.

public CursorObjectAdapter (Presenter presenter)

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

public CursorObjectAdapter ()

Construct an adapter.

Public Methods

public void changeCursor (Cursor cursor)

Change 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 The new cursor to be used.

public void close ()

Closes this adapter, closing the backing Cursor as well.

public Object get (int index)

Returns the item for the given position.

public final Cursor getCursor ()

Gets the Cursor backing the adapter.

public final CursorMapper getMapper ()

Gets the CursorMapper used to convert Cursor rows into Objects.

public boolean isClosed ()

Checks whether the adapter, and hence the backing Cursor, is closed.

public final void setMapper (CursorMapper mapper)

Sets the CursorMapper used to convert Cursor rows into Objects.

public int size ()

Returns the number of items in the adapter.

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 The new cursor to be used.

Protected Methods

protected final void invalidateCache (int index)

Remove an item from the cache. This will force the item to be re-read from the data source the next time (@link #get(int)} is called.

protected final void invalidateCache (int index, int count)

Remove count items starting at index.

protected void onCursorChanged ()

Called whenever the cursor changes.

protected void onMapperChanged ()

Called when setMapper(CursorMapper) is called and a different mapper is provided.