LimitOffsetRxPagingSource
@RestrictTo([Scope.LIBRARY_GROUP]) abstract class LimitOffsetRxPagingSource<Value : Any> : RxPagingSource<Int, Value>
kotlin.Any | |||
↳ | androidx.paging.PagingSource<Key, Value> | ||
↳ | androidx.paging.rxjava2.RxPagingSource<kotlin.Int, Value> | ||
↳ | androidx.room.paging.rxjava2.LimitOffsetRxPagingSource |
Summary
Public constructors | |
---|---|
LimitOffsetRxPagingSource(supportSQLiteQuery: SupportSQLiteQuery, db: RoomDatabase, vararg tables: String) |
|
LimitOffsetRxPagingSource(sourceQuery: RoomSQLiteQuery, db: RoomDatabase, vararg tables: String) |
Public methods | |
---|---|
open Int? |
getRefreshKey(state: PagingState<Int, Value>) Provide a Key used for the initial load for the next PagingSource due to invalidation of this PagingSource. |
open Single<PagingSource.LoadResult<Int, Value>> |
loadSingle(params: PagingSource.LoadParams<Int>) Loading API for PagingSource. |
Protected methods | |
---|---|
abstract List<Value> |
convertRows(cursor: Cursor) |
Inherited functions | |
---|---|
Properties | |
---|---|
open Boolean |
|
Inherited properties | |
---|---|
Public constructors
LimitOffsetRxPagingSource
LimitOffsetRxPagingSource(
supportSQLiteQuery: SupportSQLiteQuery,
db: RoomDatabase,
vararg tables: String)
LimitOffsetRxPagingSource
LimitOffsetRxPagingSource(
sourceQuery: RoomSQLiteQuery,
db: RoomDatabase,
vararg tables: String)
Public methods
getRefreshKey
open fun getRefreshKey(state: PagingState<Int, Value>): Int?
Provide a Key used for the initial load for the next PagingSource due to invalidation of this PagingSource. The Key is provided to load via LoadParams.key.
The Key returned by this method should cause load to load enough items to fill the viewport around the last accessed position, allowing the next generation to transparently animate in. The last accessed position can be retrieved via state.anchorPosition, which is typically the top-most or bottom-most item in the viewport due to access being triggered by binding items as they scroll into view.
For example, if items are loaded based on integer position keys, you can return
( (state.anchorPosition ?: 0) - state.config.initialLoadSize / 2).coerceAtLeast(0)
.
Alternately, if items contain a key used to load, get the key from the item in the page at
index state.anchorPosition then try to center it based on
state.config.initialLoadSize
.
Parameters | |
---|---|
state: PagingState<Int, Value> | PagingState of the currently fetched data, which includes the most recently accessed position in the list via PagingState.anchorPosition. |
Return | |
---|---|
Key | passed to load after invalidation used for initial load of the next
generation. The Key returned by getRefreshKey should load pages centered around
user's current viewport. If the correct Key cannot be determined, null can be returned
to allow load decide what default key to use. |
loadSingle
open fun loadSingle(params: PagingSource.LoadParams<Int>): Single<PagingSource.LoadResult<Int, Value>>
Loading API for PagingSource.
Implement this method to trigger your async load (e.g. from database or network).
Protected methods
Properties
jumpingSupported
open val jumpingSupported: Boolean
true
if this PagingSource supports jumping, false
otherwise.
Override this to true
if pseudo-fast scrolling via jumps is supported.
A jump occurs when a RecyclerView
scrolls through a number of placeholders defined by
PagingConfig.jumpThreshold and triggers a load with LoadType.
PagingSources that support jumps should override getRefreshKey to return a Key that would load data fulfilling the viewport given a user's current PagingState.anchorPosition.
See Also