Methods Summary |
---|
public void | changeCursor(android.database.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.
if (cursor == mCursor) {
return;
}
if (mCursor != null) {
mCursor.close();
}
mCursor = cursor;
mItemCache.trimToSize(0);
onCursorChanged();
|
public void | close()Closes this adapter, closing the backing {@link Cursor} as well.
if (mCursor != null) {
mCursor.close();
mCursor = null;
}
|
public java.lang.Object | get(int index)
if (mCursor == null) {
return null;
}
if (!mCursor.moveToPosition(index)) {
throw new ArrayIndexOutOfBoundsException();
}
Object item = mItemCache.get(index);
if (item != null) {
return item;
}
item = mMapper.convert(mCursor);
mItemCache.put(index, item);
return item;
|
public final android.database.Cursor | getCursor()Gets the {@link Cursor} backing the adapter.
return mCursor;
|
public final android.support.v17.leanback.database.CursorMapper | getMapper()Gets the {@link CursorMapper} used to convert {@link Cursor} rows into
Objects.
return mMapper;
|
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.
mItemCache.remove(index);
|
protected final void | invalidateCache(int index, int count)Remove {@code count} items starting at {@code index}.
for (int limit = count + index; index < limit; index++) {
invalidateCache(index);
}
|
public boolean | isClosed()Checks whether the adapter, and hence the backing {@link Cursor}, is closed.
return mCursor == null || mCursor.isClosed();
|
protected void | onCursorChanged()Called whenever the cursor changes.
notifyChanged();
|
protected void | onMapperChanged()Called when {@link #setMapper(CursorMapper)} is called and a different
mapper is provided.
|
public final void | setMapper(android.support.v17.leanback.database.CursorMapper mapper)Sets the {@link CursorMapper} used to convert {@link Cursor} rows into
Objects.
boolean changed = mMapper != mapper;
mMapper = mapper;
if (changed) {
onMapperChanged();
}
|
public int | size()
if (mCursor == null) {
return 0;
}
return mCursor.getCount();
|
public android.database.Cursor | swapCursor(android.database.Cursor cursor)Swap in a new Cursor, returning the old Cursor. Unlike changeCursor(Cursor),
the returned old Cursor is not closed.
if (cursor == mCursor) {
return mCursor;
}
Cursor oldCursor = mCursor;
mCursor = cursor;
mItemCache.trimToSize(0);
onCursorChanged();
return oldCursor;
|