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.

Inherited extension functions
From androidx.compose.ui.util.kotlin.collections.List
Boolean
List<T>.fastAll(predicate: (T) -> Boolean)

Returns true if all elements match the given predicate.

Boolean
List<T>.fastAny(predicate: (T) -> Boolean)

Returns true if at least one element matches the given predicate.

T?
List<T>.fastFirstOrNull(predicate: (T) -> Boolean)

Returns the first value that predicate returns true for or null if nothing matches.

Unit
List<T>.fastForEach(action: (T) -> Unit)

Iterates through a List using the index and calls action for each item.

Unit
List<T>.fastForEachIndexed(action: (Int, T) -> Unit)

Iterates through a List using the index and calls action for each item.

List<R>
List<T>.fastMap(transform: (T) -> R)

Returns a list containing the results of applying the given transform function to each element in the original collection.

C
List<T>.fastMapTo(destination: C, transform: (T) -> R)

Applies the given transform function to each element of the original collection and appends the results to the given destination.

T?
List<T>.fastMaxBy(selector: (T) -> R)

Returns the first element yielding the largest value of the given function or null if there are no elements.

Int
List<T>.fastSumBy(selector: (T) -> Int)

Returns the sum of all values produced by selector function applied to each element in the list.

From androidx.compose.runtime.kotlin.collections.Collection
SnapshotStateList<T>

Create an instance of MutableList from a collection that is observerable and can be snapshot.

From androidx.compose.runtime.kotlin.collections.Iterable
SnapshotStateMap<K, V>

Create an instance of MutableMap<K, V> from a collection of pairs that is observable and can be snapshot.

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