ListenableFutureRemoteMediator
@ExperimentalPagingApi
public abstract class ListenableFutureRemoteMediator<Key extends Object, Value extends Object> extends RemoteMediator
ListenableFuture-based compatibility wrapper around RemoteMediator's suspending APIs.
Summary
Public constructors |
|---|
<Key extends Object, Value extends Object> ListenableFutureRemoteMediator() |
Public methods |
|
|---|---|
final @NonNull RemoteMediator.InitializeAction |
|
@NonNull ListenableFuture<@NonNull RemoteMediator.InitializeAction> |
Callback fired during initialization of a |
final @NonNull RemoteMediator.MediatorResult |
|
abstract @NonNull ListenableFuture<@NonNull RemoteMediator.MediatorResult> |
loadFuture(Implement this method to load additional remote data, which will then be stored for the |
Public constructors
ListenableFutureRemoteMediator
public <Key extends Object, Value extends Object> ListenableFutureRemoteMediator()
Public methods
initializeFuture
public @NonNull ListenableFuture<@NonNull RemoteMediator.InitializeAction> initializeFuture()
Callback fired during initialization of a PagingData stream, before initial load.
This function runs to completion before any loading is performed.
| Returns | |
|---|---|
@NonNull ListenableFuture<@NonNull RemoteMediator.InitializeAction> |
InitializeAction indicating the action to take after initialization: * |
load
public final @NonNull RemoteMediator.MediatorResult load(
@NonNull LoadType loadType,
@NonNull PagingState<@NonNull Key, @NonNull Value> state
)
loadFuture
public abstract @NonNull ListenableFuture<@NonNull RemoteMediator.MediatorResult> loadFuture(
@NonNull LoadType loadType,
@NonNull PagingState<@NonNull Key, @NonNull Value> state
)
Implement this method to load additional remote data, which will then be stored for the PagingSource to access. These loads take one of two forms: * type == LoadType.PREPEND / LoadType.APPEND The PagingSource has loaded a 'boundary' page, with a null adjacent key. This means this method should load additional remote data to append / prepend as appropriate, and store it locally.
-
type ==
LoadType.REFRESHThe app (orinitialize) has requested a remote refresh of data. This means the method should generally load remote data, and replace all local data.
The runtime of this method defines loading state behavior in boundary conditions, which affects e.g., LoadState callbacks registered to androidx.paging.PagingDataAdapter.
NOTE: A PagingSource.load request which is fulfilled by a page that hits a boundary condition in either direction will trigger this callback with LoadType.PREPEND or LoadType.APPEND or both. LoadType.REFRESH occurs as a result of initialize.
| Parameters | |
|---|---|
@NonNull LoadType loadType |
|
@NonNull PagingState<@NonNull Key, @NonNull Value> state |
A copy of the state including the list of pages currently held in memory of the currently presented |
| Returns | |
|---|---|
@NonNull ListenableFuture<@NonNull RemoteMediator.MediatorResult> |
MediatorResult signifying what |