PagingState

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.

Summary

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.

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

Public fields

anchorPosition

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.

config

public final @NonNull PagingConfig config