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)
Constructs an adapter with the given PresenterSelector.
CursorObjectAdapter(Presenter presenter)
Constructs an adapter that uses the given Presenter for all items.
CursorObjectAdapter()
Constructs an adapter.
Public Methods
void changeCursor(Cursor cursor)
Changes 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()
Returns the Cursor backing the adapter.
final CursorMapper getMapper()
Returns the CursorMapper used to convert Cursor rows into Objects.
boolean isClosed()
Returns true if the adapter, and hence the backing Cursor, is closed; false otherwise.
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)
Removes an item from the cache.
final void invalidateCache(int index, int count)
Removes 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)

Constructs an adapter with the given PresenterSelector.

public CursorObjectAdapter (Presenter presenter)

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

public CursorObjectAdapter ()

Constructs an adapter.

Public Methods

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 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 ()

Returns the Cursor backing the adapter.

public final CursorMapper getMapper ()

Returns the CursorMapper used to convert Cursor rows into Objects.

public boolean isClosed ()

Returns true if the adapter, and hence the backing Cursor, is closed; false otherwise.

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)

Removes 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)

Removes 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.