Loader

public class Loader
extends Object

java.lang.Object
   ↳ androidx.loader.content.Loader<D>


Static library support version of the framework's Loader. Used to write apps that run on platforms prior to Android 3.0. When running on Android 3.0 or above, this implementation is still used; it does not try to switch to the framework's implementation. See the framework SDK documentation for a class overview.

Summary

Nested classes

class Loader.ForceLoadContentObserver

An implementation of a ContentObserver that takes care of connecting it to the Loader to have the loader re-load its data when the observer is told it has changed. 

interface Loader.OnLoadCanceledListener<D>

Interface that is implemented to discover when a Loader has been canceled before it finished loading its data. 

interface Loader.OnLoadCompleteListener<D>

Interface that is implemented to discover when a Loader has finished loading its data. 

Public constructors

Loader(Context context)

Stores away the application context associated with context.

Public methods

void abandon()

This function will normally be called for you automatically by LoaderManager when restarting a Loader.

boolean cancelLoad()

Attempt to cancel the current load task.

void commitContentChanged()

Commit that you have actually fully processed a content change that was returned by takeContentChanged().

String dataToString(D data)

For debugging, converts an instance of the Loader's data class to a string that can be printed.

void deliverCancellation()

Informs the registered Loader.OnLoadCanceledListener that the load has been canceled.

void deliverResult(D data)

Sends the result of the load to the registered listener.

void dump(String prefix, FileDescriptor fd, PrintWriter writer, String[] args)

This method is deprecated. Consider using LoaderManager.enableDebugLogging(boolean) to understand the series of operations performed by LoaderManager.

void forceLoad()

Force an asynchronous load.

Context getContext()
int getId()
boolean isAbandoned()

Return whether this loader has been abandoned.

boolean isReset()

Return whether this load has been reset.

boolean isStarted()

Return whether this load has been started.

void onContentChanged()

Called when Loader.ForceLoadContentObserver detects a change.

void registerListener(int id, OnLoadCompleteListener<D> listener)

Registers a class that will receive callbacks when a load is complete.

void registerOnLoadCanceledListener(OnLoadCanceledListener<D> listener)

Registers a listener that will receive callbacks when a load is canceled.

void reset()

This function will normally be called for you automatically by LoaderManager when destroying a Loader.

void rollbackContentChanged()

Report that you have abandoned the processing of a content change that was returned by takeContentChanged() and would like to rollback to the state where there is again a pending content change.

final void startLoading()

This function will normally be called for you automatically by LoaderManager when the associated fragment/activity is being started.

void stopLoading()

This function will normally be called for you automatically by LoaderManager when the associated fragment/activity is being stopped.

boolean takeContentChanged()

Take the current flag indicating whether the loader's content had changed while it was stopped.

String toString()
void unregisterListener(OnLoadCompleteListener<D> listener)

Remove a listener that was previously added with registerListener(int, Loader.OnLoadCompleteListener).

void unregisterOnLoadCanceledListener(OnLoadCanceledListener<D> listener)

Unregisters a listener that was previously added with registerOnLoadCanceledListener(Loader.OnLoadCanceledListener).