LoaderManager.LoaderCallbacks

public interface LoaderManager.LoaderCallbacks<D>


Callback interface for a client to interact with the manager.

Summary

Public methods

abstract @NonNull Loader<D>

Instantiate and return a new Loader for the given ID.

abstract void
@MainThread
onLoadFinished(@NonNull Loader<D> loader, D data)

Called when a previously created loader has finished its load.

abstract void

Called when a previously created loader is being reset, and thus making its data unavailable.

Public methods

onCreateLoader

Added in 1.0.0
@MainThread
abstract @NonNull Loader<D> onCreateLoader(int id, @Nullable Bundle args)

Instantiate and return a new Loader for the given ID.

This will always be called from the process's main thread.

Parameters
int id

The ID whose loader is to be created.

@Nullable Bundle args

Any arguments supplied by the caller.

Returns
@NonNull Loader<D>

Return a new Loader instance that is ready to start loading.

onLoadFinished

Added in 1.0.0
@MainThread
abstract void onLoadFinished(@NonNull Loader<D> loader, D data)

Called when a previously created loader has finished its load. Note that normally an application is not allowed to commit fragment transactions while in this call, since it can happen after an activity's state is saved. See FragmentManager.openTransaction() for further discussion on this.

This function is guaranteed to be called prior to the release of the last data that was supplied for this Loader. At this point you should remove all use of the old data (since it will be released soon), but should not do your own release of the data since its Loader owns it and will take care of that. The Loader will take care of management of its data so you don't have to. In particular:

This will always be called from the process's main thread.

Parameters
@NonNull Loader<D> loader

The Loader that has finished.

D data

The data generated by the Loader.

onLoaderReset

Added in 1.0.0
@MainThread
abstract void onLoaderReset(@NonNull Loader<D> loader)

Called when a previously created loader is being reset, and thus making its data unavailable. The application should at this point remove any references it has to the Loader's data.

This will always be called from the process's main thread.

Parameters
@NonNull Loader<D> loader

The Loader that is being reset.