PagingDataTransforms

public final class PagingDataTransforms


Summary

Public constructors

Public methods

static final @NonNull PagingData<@NonNull T>
<T extends Object> PagingDataTransforms.filter(
    PagingData<T> receiver,
    Executor executor,
    Function1<T, Boolean> predicate
)

Returns a PagingData containing only elements matching the given predicate.

static final @NonNull PagingData<@NonNull R>
<T extends Object, R extends Object> PagingDataTransforms.flatMap(
    PagingData<T> receiver,
    Executor executor,
    Function1<T, Iterable<R>> transform
)

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

static final @NonNull PagingData<@NonNull T>
<T extends Object> PagingDataTransforms.insertFooterItem(
    PagingData<T> receiver,
    TerminalSeparatorType terminalSeparatorType,
    T item
)

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

static final @NonNull PagingData<@NonNull T>
<T extends Object> PagingDataTransforms.insertHeaderItem(
    PagingData<T> receiver,
    TerminalSeparatorType terminalSeparatorType,
    T item
)

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

static final @NonNull PagingData<@NonNull R>
<R extends Object, T extends R> PagingDataTransforms.insertSeparators(
    PagingData<T> receiver,
    TerminalSeparatorType terminalSeparatorType,
    Executor executor,
    Function2<T, T, R> generator
)

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).

static final @NonNull PagingData<@NonNull R>
<T extends Object, R extends Object> PagingDataTransforms.map(
    PagingData<T> receiver,
    Executor executor,
    Function1<T, R> transform
)

Returns a PagingData containing the result of applying the given transform to each element, as it is loaded.

Public constructors

PagingDataTransforms

public final PagingDataTransforms()

Public methods

PagingDataTransforms.filter

public static final @NonNull PagingData<@NonNull T> <T extends Object> PagingDataTransforms.filter(
    PagingData<T> receiver,
    Executor executor,
    Function1<T, Boolean> predicate
)

Returns a PagingData containing only elements matching the given predicate.

PagingDataTransforms.flatMap

public static final @NonNull PagingData<@NonNull R> <T extends Object, R extends Object> PagingDataTransforms.flatMap(
    PagingData<T> receiver,
    Executor executor,
    Function1<T, Iterable<R>> transform
)

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

PagingDataTransforms.insertFooterItem

public static final @NonNull PagingData<@NonNull T> <T extends Object> PagingDataTransforms.insertFooterItem(
    PagingData<T> receiver,
    TerminalSeparatorType terminalSeparatorType,
    T item
)

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

The footer item is added to a loaded page which marks the end of the data stream in the LoadType.APPEND direction, either by returning null in PagingSource.LoadResult.Page.nextKey. It will be removed if the last page in the list is dropped, which can happen in the case of loaded pages exceeding PagedList.Config.maxSize.

Note: This operation is not idempotent, calling it multiple times will continually add more footers to the end of the list, which can be useful if multiple footer items are required.

Parameters
TerminalSeparatorType terminalSeparatorType

TerminalSeparatorType used to configure when the header and footer are added.

T item

The footer to add to the end of the list once it is fully loaded in the LoadType.APPEND direction.

See also
insertHeaderItem

PagingDataTransforms.insertHeaderItem

public static final @NonNull PagingData<@NonNull T> <T extends Object> PagingDataTransforms.insertHeaderItem(
    PagingData<T> receiver,
    TerminalSeparatorType terminalSeparatorType,
    T item
)

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

The header item is added to a loaded page whi