CursorObjectAdapter


class CursorObjectAdapter : ObjectAdapter


An ObjectAdapter implemented with a Cursor.

Summary

Public constructors

Constructs an adapter.

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

Constructs an adapter with the given PresenterSelector.

Public functions

Unit
changeCursor(cursor: Cursor!)

Changes the underlying cursor to a new cursor.

Unit

Closes this adapter, closing the backing Cursor as well.

Any?
get(index: Int)

Returns the item for the given position.

Cursor!

Returns the Cursor backing the adapter.

CursorMapper!

Returns the CursorMapper used to convert Cursor rows into Objects.

Boolean

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

Boolean

Returns true if the adapter pairs each underlying data change with a call to notify and false otherwise.

Unit

Sets the CursorMapper used to convert Cursor rows into Objects.

Int

Returns the number of items in the adapter.

Cursor!
swapCursor(cursor: Cursor!)

Swap in a new Cursor, returning the old Cursor.

Protected functions

Unit

Removes an item from the cache.

Unit
invalidateCache(index: Int, count: Int)

Removes count items starting at index.

Unit

Called whenever the cursor changes.

Unit

Called when setMapper is called and a different mapper is provided.

Inherited Constants

From androidx.leanback.widget.ObjectAdapter
const Int
NO_ID = -1

Indicates that an id has not been set.

Inherited functions

From androidx.leanback.widget.ObjectAdapter
Long
getId(position: Int)

Returns the id for the given position.

Presenter?

Returns the Presenter for the given item from the adapter.

PresenterSelector

Returns the presenter selector for this ObjectAdapter.

Boolean

Returns true if the item ids are stable across changes to the underlying data.

Unit

Notifies UI that the underlying data has changed.

Unit
notifyItemMoved(fromPosition: Int, toPosition: Int)

Notifies UI that item at fromPosition has been moved to toPosition.

Unit
notifyItemRangeChanged(positionStart: Int, itemCount: Int)

Notifies UI that some items has changed.

Unit
notifyItemRangeChanged(positionStart: Int, itemCount: Int, payload: Any?)

Notifies UI that some items has changed.

Unit
notifyItemRangeInserted(positionStart: Int, itemCount: Int)

Notifies UI that new items has been inserted.

Unit
notifyItemRangeRemoved(positionStart: Int, itemCount: Int)

Notifies UI that some items that has been removed.

Unit

Called when setHasStableIds is called and the status of stable ids has changed.

Unit

Called when setPresenterSelector is called and the PresenterSelector differs from the previous one.

Unit

Registers a DataObserver for data change notifications.

Unit
setHasStableIds(hasStableIds: Boolean)

Sets whether the item ids are stable across changes to the underlying data.

Unit

Sets the presenter selector.

Unit

Unregisters all DataObservers for this ObjectAdapter.

Unit

Unregisters a DataObserver for data change notifications.

Public constructors

CursorObjectAdapter

Added in 1.1.0
CursorObjectAdapter()

Constructs an adapter.

CursorObjectAdapter

Added in 1.1.0
CursorObjectAdapter(presenter: Presenter!)

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

CursorObjectAdapter

Added in 1.1.0
CursorObjectAdapter(presenterSelector: PresenterSelector!)

Constructs an adapter with the given PresenterSelector.

Public functions

changeCursor

Added in 1.1.0
fun changeCursor(cursor: Cursor!): Unit

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.

close

Added in 1.1.0
fun close(): Unit

Closes this adapter, closing the backing Cursor as well.

get

Added in 1.2.0-alpha04
fun get(index: Int): Any?

Returns the item for the given position.

getCursor

Added in 1.1.0
fun getCursor(): Cursor!

Returns the Cursor backing the adapter.

getMapper

Added in 1.1.0
fun getMapper(): CursorMapper!

Returns the CursorMapper used to convert Cursor rows into Objects.

isClosed

Added in 1.1.0
fun isClosed(): Boolean

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

isImmediateNotifySupported

fun isImmediateNotifySupported(): Boolean

Returns true if the adapter pairs each underlying data change with a call to notify and false otherwise.

setMapper

Added in 1.1.0
fun setMapper(mapper: CursorMapper!): Unit

Sets the CursorMapper used to convert Cursor rows into Objects.

size

Added in 1.2.0-alpha04
fun size(): Int

Returns the number of items in the adapter.

swapCursor

Added in 1.1.0
fun swapCursor(cursor: 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 functions

invalidateCache

Added in 1.1.0
protected fun invalidateCache(index: Int): Unit

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

Added in 1.1.0
protected fun invalidateCache(index: Int, count: Int): Unit

Removes count items starting at index.

onCursorChanged

Added in 1.1.0
protected fun onCursorChanged(): Unit

Called whenever the cursor changes.

onMapperChanged

Added in 1.1.0
protected fun onMapperChanged(): Unit

Called when setMapper is called and a different mapper is provided.