{% setvar book_path %}/reference/androidx/_book.yaml{% endsetvar %} {% include "_shared/_reference-head-tags.html" %}
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 @Nullable Integer |
Most recently accessed index in the list, including placeholders. |
final @NonNull PagingConfig |
|
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( |
Public methods |
|
---|---|
final @Nullable Value |
closestItemToPosition(int anchorPosition) Coerces |
final @Nullable PagingSource.LoadResult.Page<@NonNull Key, @NonNull Value> |
closestPageToPosition(int anchorPosition) Coerces an index in the list, including placeholders, to closest loaded page in |
boolean |
|
final @Nullable Value |
|
int |
hashCode() |
final boolean |
isEmpty() |
final @Nullable Value |
|
@NonNull String |
toString() |
@Nullable
public final @Nullable 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.
@NonNull
public final @NonNull PagingConfig config
PagingConfig
that was given when initializing the PagingData
stream.
@NonNull
public final @NonNull List<@NonNull PagingSource.LoadResult.Page<@NonNull Key, @NonNull Value>> pages
Loaded pages of data in the list.
@NonNull
public final <Key extends Object, Value extends Object> PagingState(
@NonNull List<@NonNull PagingSource.LoadResult.Page<@NonNull Key, @NonNull Value>> pages,
@Nullable Integer anchorPosition,
@NonNull PagingConfig config,
@IntRange int leadingPlaceholderCount
)
@Nullable
public final Value closestItemToPosition(int anchorPosition)
Coerces anchorPosition
to closest loaded value in pages
.
This function can be called with anchorPosition
to fetch the loaded item that is closest to the last accessed index in the list.
Parameters | |
---|---|
int anchorPosition |
Index in the list, including placeholders. |
Returns | |
---|---|
Value |
The closest loaded |
@Nullable
public 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
.
This function can be called with anchorPosition
to fetch the loaded page that is closest to the last accessed index in the list.
Parameters | |
---|---|
int anchorPosition |
Index in the list, including placeholders. |
Returns | |
---|---|
PagingSource.LoadResult.Page<@NonNull Key, @NonNull Value> |
The closest loaded |
@Nullable
public final Value firstItemOrNull()
Returns | |
---|---|
Value |
The first loaded item in the list or |
@NonNull
public final boolean isEmpty()
Returns | |
---|---|
boolean |
|
@Nullable
public final Value lastItemOrNull()
Returns | |
---|---|
Value |
The last loaded item in the list or |