ItemSnapshotList

public final class ItemSnapshotList<T extends Object>


Snapshot of data being presented by a androidx.pagingAsyncPagingDataDiffer or a PagingDataAdapter.

Summary

Public fields

final @NonNull List<@NonNull T>

The presented data, excluding placeholders.

final int

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

final int

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

int

Size of ItemSnapshotList including placeholders.

Public constructors

<T extends Object> ItemSnapshotList(
    @IntRange(from = 0) int placeholdersBefore,
    @IntRange(from = 0) int placeholdersAfter,
    @NonNull List<@NonNull T> items
)

Public methods

@Nullable T
get(int index)

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

Inherited methods

From class AbstractCollection
boolean
contains(@Nullable T element)
boolean
boolean
@NonNull String
From class AbstractList
boolean
int
int
indexOf(@Nullable T element)
@NonNull Iterator<@NonNull T>
int
lastIndexOf(@Nullable T element)
@NonNull ListIterator<@NonNull T>
@NonNull ListIterator<@NonNull T>
listIterator(int index)
@NonNull List<@NonNull T>
subList(int fromIndex, int toIndex)
From class Iterable
From class Collection

Public fields

items

@NonNull
public final @NonNull List<@NonNull T> items

The presented data, excluding placeholders.

placeholdersAfter

@NonNull
public final int placeholdersAfter

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

placeholdersBefore

@NonNull
public final int placeholdersBefore

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

size

@NonNull
public int size

Size of ItemSnapshotList including placeholders.

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

See also
items

Public constructors

ItemSnapshotList

@NonNull
public final <T extends Object> ItemSnapshotList(
    @IntRange(from = 0) int placeholdersBefore,
    @IntRange(from = 0) int placeholdersAfter,
    @NonNull List<@NonNull T> items
)

Public methods

get

@Nullable
public T get(int index)

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.

Throws
kotlin.IndexOutOfBoundsException

if index < 0 or indexsize.