NetworkPagingSource

class NetworkPagingSource<T : Any, R : Any>(    offsetPageKey: Int,     mapper: PagingMapper<T, R>,     call: suspend (page: Int) -> Call<T>) : PagingSource<Int, R>

Author

skydoves (Jaewoong Eum)

Since

1.0.0

NetworkPagingSource is a implementation of PagingSource that was designed to load pages of data for an instance of PagingData and to be combined with Pager. You return NetworkPagingSource for your Retrofit service method by adding PagingCallAdapterFactory to your Retrofit.Builder.

If you want to return NetworkPagingSource, you must use the PagingKeyConfig and PagingKey to your method and parameter for providing proper paging configurations to the adapter factory.

PagingData queries data from its NetworkPagingSource in response, which came from the network response as the user scrolls in a RecyclerView. To control how and when a PagingData queries data from its PagingSource, see PagingConfig, which defines behavior such as PagingConfig.pageSize and PagingConfig.prefetchDistance.

Basically, the default page key starts from the offsetPageKey that will be decided by the call value of the parameter, which is annotated with PagingKey.

Constructors

Link copied to clipboard
fun <T : Any, R : Any> NetworkPagingSource(    offsetPageKey: Int,     mapper: PagingMapper<T, R>,     call: suspend (page: Int) -> Call<T>)

Inherited properties

Link copied to clipboard
val invalid: Boolean
Link copied to clipboard
open val jumpingSupported: Boolean
Link copied to clipboard
open val keyReuseSupported: Boolean

Functions

Link copied to clipboard
open override fun getRefreshKey(state: PagingState<Int, R>): Int?
Link copied to clipboard
open suspend override fun load(params: PagingSource.LoadParams<Int>): PagingSource.LoadResult<Int, R>

Inherited functions

Link copied to clipboard
fun invalidate()
Link copied to clipboard
fun registerInvalidatedCallback(onInvalidatedCallback: () -> Unit)
Link copied to clipboard
fun unregisterInvalidatedCallback(onInvalidatedCallback: () -> Unit)