public final class Loader extends Object
Loader.Loadable
s.Modifier and Type | Class and Description |
---|---|
static interface |
Loader.Callback
Interface definition for a callback to be notified of
Loader events. |
static interface |
Loader.Loadable
Interface definition of an object that can be loaded using a
Loader . |
static class |
Loader.UnexpectedLoaderException
Thrown when an unexpected exception is encountered during loading.
|
Modifier and Type | Method and Description |
---|---|
void |
cancelLoading()
Cancels the current load.
|
boolean |
isLoading()
Whether the
Loader is currently loading a Loader.Loadable . |
void |
release()
Releases the
Loader . |
void |
release(Runnable postLoadAction)
Releases the
Loader , running postLoadAction on its thread. |
void |
startLoading(Loader.Loadable loadable,
Loader.Callback callback)
Invokes
startLoading(Looper, Loadable, Callback) , using the Looper
associated with the calling thread. |
void |
startLoading(Looper looper,
Loader.Loadable loadable,
Loader.Callback callback)
Start loading a
Loader.Loadable . |
public Loader(String threadName)
threadName
- A name for the loader's thread.public void startLoading(Loader.Loadable loadable, Loader.Callback callback)
startLoading(Looper, Loadable, Callback)
, using the Looper
associated with the calling thread.loadable
- The Loader.Loadable
to load.callback
- A callback to invoke when the load ends.IllegalStateException
- If the calling thread does not have an associated Looper
.public void startLoading(Looper looper, Loader.Loadable loadable, Loader.Callback callback)
Loader.Loadable
.
A Loader
instance can only load one Loader.Loadable
at a time, and so this method
must not be called when another load is in progress.
looper
- The looper of the thread on which the callback should be invoked.loadable
- The Loader.Loadable
to load.callback
- A callback to invoke when the load ends.public boolean isLoading()
Loader
is currently loading a Loader.Loadable
.Loader
is currently loading a Loader.Loadable
.public void cancelLoading()
This method should only be called when a load is in progress.
public void release()
public void release(Runnable postLoadAction)
Loader
, running postLoadAction
on its thread.
This method should be called when the Loader
is no longer required.
postLoadAction
- A Runnable
to run on the loader's thread when
Loader.Loadable.load()
is no longer running.