Android 12 Developer Preview is here! Try it out, and give us your feedback!

PagingData

class PagingData<T : Any>
kotlin.Any
   ↳ androidx.paging.PagingData

Container for Paged data from a single generation of loads.

Each refresh of data (generally either pushed by local storage, or pulled from the network) will have a separate corresponding PagingData.

Summary

Companion functions
PagingData<T>

Create a PagingData that immediately displays an empty list of items when submitted to AsyncPagingDataAdapter.

PagingData<T>
from(data: List<T>)

Create a PagingData that immediately displays a static list of items when submitted to AsyncPagingDataAdapter.

Extension functions
From androidx.paging
PagingData<T>
PagingData<T>.filter(predicate: suspend (T) -> Boolean)

Returns a PagingData containing only elements matching the given predicate

PagingData<T>
PagingData<T>.filter(executor: Executor, predicate: (T) -> Boolean)

Returns a PagingData containing only elements matching the given predicate.

PagingData<T>
PagingData<T>.filterAsync(predicate: AsyncFunction<T, Boolean>, executor: Executor)

Returns a PagingData containing only elements matching the given predicate.

PagingData<R>
PagingData<T>.flatMap(transform: suspend (T) -> Iterable<R>)

Returns a PagingData of all elements returned from applying the given transform to each element, as it is loaded.

PagingData<R>
PagingData<T>.flatMap(executor: Executor, transform: (T) -> Iterable<R>)

Returns a PagingData of all elements returned from applying the given transform to each element, as it is loaded.

PagingData<R>
PagingData<T>.flatMapAsync(transform: AsyncFunction<T, Iterable<R>>, executor: Executor)

Returns a PagingData of all elements returned from applying the given transform to each element, as it is loaded.

PagingData<T>
PagingData<T>.insertFooterItem(terminalSeparatorType: TerminalSeparatorType = FULLY_COMPLETE, item: T)

Returns a PagingData containing each original element, with the passed footer item added to the end of the list.

PagingData<T>
PagingData<T>.insertHeaderItem(terminalSeparatorType: TerminalSeparatorType = FULLY_COMPLETE, item: T)

Returns a PagingData containing each original element, with the passed header item added to the start of the list.

PagingData<R>
PagingData<T>.insertSeparators(terminalSeparatorType: TerminalSeparatorType = FULLY_COMPLETE, generator: suspend (T?, T?) -> R?)

Returns a PagingData containing each original element, with an optional separator generated by generator, given the elements before and after (or null, in boundary conditions).

PagingData<R>
PagingData<T>.insertSeparators(terminalSeparatorType: TerminalSeparatorType = FULLY_COMPLETE,