{% setvar book_path %}/reference/kotlin/androidx/_book.yaml{% endsetvar %} {% include "_shared/_reference-head-tags.html" %}
class PagingState<Key : Any, Value : Any>
Snapshot state of Paging system including the loaded pages
, the last accessed anchorPosition
, and the config
used.
Public properties |
|
---|---|
Int? |
Most recently accessed index in the list, including placeholders. |
PagingConfig |
|
List<PagingSource.LoadResult.Page<Key, Value>> |
Loaded pages of data in the list. |
Public constructors |
|
---|---|
<Key : Any, Value : Any> PagingState( |
Public functions |
|
---|---|
Value? |
closestItemToPosition(anchorPosition: Int) Coerces |
PagingSource.LoadResult.Page<Key, Value>? |
closestPageToPosition(anchorPosition: Int) Coerces an index in the list, including placeholders, to closest loaded page in |
open operator Boolean |
|
Value? |
|
open Int |
hashCode() |
Boolean |
isEmpty() |
Value? |
|
open String |
toString() |
val anchorPosition: Int?
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.
val config: PagingConfig
PagingConfig
that was given when initializing the PagingData
stream.
<Key : Any, Value : Any> PagingState(
pages: List<PagingSource.LoadResult.Page<Key, Value>>,
anchorPosition: Int?,
config: PagingConfig,
@IntRange leadingPlaceholderCount: Int
)
fun closestItemToPosition(anchorPosition: Int): Value?
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 | |
---|---|
anchorPosition: Int |
Index in the list, including placeholders. |
Returns | |
---|---|
Value? |
The closest loaded |
fun closestPageToPosition(anchorPosition: Int): PagingSource.LoadResult.Page<Key, Value>?
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 | |
---|---|
anchorPosition: Int |
Index in the list, including placeholders. |
Returns | |
---|---|
PagingSource.LoadResult.Page<Key, Value>? |
The closest loaded |
fun firstItemOrNull(): Value?
Returns | |
---|---|
Value? |
The first loaded item in the list or |
fun isEmpty(): Boolean
Returns | |
---|---|
Boolean |
|
fun lastItemOrNull(): Value?
Returns | |
---|---|
Value? |
The last loaded item in the list or |