Save the date! Android Dev Summit is coming to Sunnyvale, CA on Oct 23-24, 2019.

CursorObjectAdapter

open class CursorObjectAdapter : ObjectAdapter
kotlin.Any
   ↳ androidx.leanback.widget.ObjectAdapter
   ↳ androidx.leanback.widget.CursorObjectAdapter

An ObjectAdapter implemented with a Cursor.

Summary

Inherited constants
Public constructors
<init>(presenterSelector: PresenterSelector!)

Constructs an adapter with the given PresenterSelector.

<init>(presenter: Presenter!)

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

Constructs an adapter.

Public methods
open Unit
changeCursor(cursor: Cursor!)

Changes the underlying cursor to a new cursor.

Cursor!

Returns the Cursor backing the adapter.

CursorMapper!

Returns the CursorMapper used to convert Cursor rows into Objects.

open Int

open Any!
get(index: Int)

open Unit

Closes this adapter, closing the backing Cursor as well.

open Boolean

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

open Cursor!
swapCursor(cursor: Cursor!)

Swap in a new Cursor, returning the old Cursor.

open Boolean

Unit

Sets the CursorMapper used to convert Cursor rows into Objects.

Protected methods
Unit

Removes an item from the cache.

Unit
invalidateCache(index: Int, count: Int)

Removes count items starting at index.

open Unit

Called whenever the cursor changes.

open Unit

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

Inherited functions

Public constructors

<init>

CursorObjectAdapter(presenterSelector: PresenterSelector!)

Constructs an adapter with the given PresenterSelector.

<init>

CursorObjectAdapter(presenter: Presenter!)

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

<init>

CursorObjectAdapter()

Constructs an adapter.

Public methods

changeCursor

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

getCursor

fun getCursor(): Cursor!

Returns the Cursor backing the adapter.

getMapper

fun getMapper(): CursorMapper!

Returns the CursorMapper used to convert Cursor rows into Objects.

size

open fun size(): Int

get

open fun get(index: Int): Any!

close

open fun close(): Unit

Closes this adapter, closing the backing Cursor as well.

isClosed

open fun isClosed(): Boolean

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

swapCursor

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

isImmediateNotifySupported

open fun isImmediateNotifySupported(): Boolean

setMapper

fun setMapper(mapper: CursorMapper!): Unit

Sets the CursorMapper used to convert Cursor rows into Objects.

Protected methods

invalidateCache

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(int) is called.

invalidateCache

protected fun invalidateCache(index: Int, count: Int): Unit

Removes count items starting at index.

onCursorChanged

protected open fun onCursorChanged(): Unit

Called whenever the cursor changes.

onMapperChanged

protected open fun onMapperChanged(): Unit

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