Google 致力于为黑人社区推动种族平等。查看具体举措

ItemSnapshotList

class ItemSnapshotList<T> : AbstractList<T?>
kotlin.Any
   ↳ kotlin.collections.AbstractCollection<E>
   ↳ kotlin.collections.AbstractList<T>
   ↳ androidx.paging.ItemSnapshotList

Snapshot of data being presented by a AsyncPagingDataDiffer or a PagingDataAdapter.

Summary

Public constructors
<init>(@IntRange(0) placeholdersBefore: Int, @IntRange(0) placeholdersAfter: Int, items: List<T>)

Snapshot of data being presented by a AsyncPagingDataDiffer or a PagingDataAdapter.

Public methods
T?
get(index: Int)

Returns the item at index, where index includes the position of placeholders.

Properties
List<T>

The presented data, excluding placeholders.

Int

Number of placeholders after the presented items, 0 if enablePlaceholders is false.

Int

Number of placeholders before the presented items, 0 if enablePlaceholders is false.

Int

Size of ItemSnapshotList including placeholders.

Public constructors

<init>

ItemSnapshotList(
    @IntRange(0) placeholdersBefore: Int,
    @IntRange(0) placeholdersAfter: Int,
    items: List<T>)

Snapshot of data being presented by a AsyncPagingDataDiffer or a PagingDataAdapter.

Public methods

get

fun get(index: Int): T?

Returns the item at index, where index includes the position of placeholders. If index points to the position of a placeholder, null is returned.

To get the size using an index excluding placeholders, use List.size on items directly.

Exceptions
IndexOutOfBoundsException if index < 0 or index > size.

Properties

items

val items: List<T>

The presented data, excluding placeholders.

placeholdersAfter

val placeholdersAfter: Int

Number of placeholders after the presented items, 0 if enablePlaceholders is false.

placeholdersBefore

val placeholdersBefore: Int

Number of placeholders before the presented items, 0 if enablePlaceholders is false.

size

val size: Int

Size of ItemSnapshotList including placeholders.

To get the size excluding placeholders, use List.size on items directly.

See Also