public final class PagingState<Key extends Object, Value extends Object>

Snapshot state of Paging system including the loaded pages, the last accessed anchorPosition, and the config used.


Public fields

final Integer

Most recently accessed index in the list, including placeholders.

final @NonNull PagingConfig

PagingConfig that was given when initializing the PagingData stream.

final @NonNull List<@NonNull PagingSource.LoadResult.Page<@NonNull Key, @NonNull Value>>

Loaded pages of data in the list.

Public constructors

<Key extends Object, Value extends Object> PagingState(
    List<PagingSource.LoadResult.Page<Key, Value>> pages,
    Integer anchorPosition,
    PagingConfig config,
    @IntRange(from = 0) int leadingPlaceholderCount

Public methods

final Value
closestItemToPosition(int anchorPosition)

Coerces anchorPosition to closest loaded value in pages.

final PagingSource.LoadResult.Page<@NonNull Key, @NonNull Value>
closestPageToPosition(int anchorPosition)

Coerces an index in the list, including placeholders, to closest loaded page in pages.

equals(Object other)
final Value
final boolean
final Value
@NonNull String

Public fields


public final Integer anchorPosition

Most recently accessed index in the list, including placeholders.

null if no access in the PagingData has been made yet. E.g., if this snapshot was generated before or during the first load.


public final @NonNull PagingConfig config