LoaderErrorThrowerpublic final class Loader extends Object implements LoaderErrorThrower
Loader.Loadables.| Modifier and Type | Class | Description |
|---|---|---|
static interface |
Loader.Callback<T extends Loader.Loadable> |
A callback to be notified of
Loader events. |
static interface |
Loader.Loadable |
An object that can be loaded using a
Loader. |
static class |
Loader.LoadErrorAction |
Action that can be taken in response to
Loader.Callback.onLoadError(Loadable, long, long,
IOException, int). |
static interface |
Loader.ReleaseCallback |
A callback to be notified when a
Loader has finished being released. |
static class |
Loader.UnexpectedLoaderException |
Thrown when an unexpected exception or error is encountered during loading.
|
LoaderErrorThrower.Dummy| Modifier and Type | Field | Description |
|---|---|---|
static Loader.LoadErrorAction |
DONT_RETRY |
Discards the failed
Loader.Loadable and ignores any errors that have occurred. |
static Loader.LoadErrorAction |
DONT_RETRY_FATAL |
Discards the failed
Loader.Loadable. |
static Loader.LoadErrorAction |
RETRY |
Retries the load using the default delay.
|
static Loader.LoadErrorAction |
RETRY_RESET_ERROR_COUNT |
Retries the load using the default delay and resets the error count.
|
| Modifier and Type | Method | Description |
|---|---|---|
void |
cancelLoading() |
Cancels the current load.
|
void |
clearFatalError() |
Clears any stored fatal error.
|
static Loader.LoadErrorAction |
createRetryAction(boolean resetErrorCount,
long retryDelayMillis) |
Creates a
Loader.LoadErrorAction for retrying with the given parameters. |
boolean |
hasFatalError() |
Whether the last call to
startLoading(T, com.google.android.exoplayer2.upstream.Loader.Callback<T>, int) resulted in a fatal error. |
boolean |
isLoading() |
Returns whether the loader is currently loading.
|
void |
maybeThrowError() |
Throws a fatal error, or a non-fatal error if loading is currently backed off and the current
Loader.Loadable has incurred a number of errors greater than the Loaders default
minimum number of retries. |
void |
maybeThrowError(int minRetryCount) |
Throws a fatal error, or a non-fatal error if loading is currently backed off and the current
Loader.Loadable has incurred a number of errors greater than the specified minimum number
of retries. |
void |
release() |
Releases the loader.
|
void |
release(Loader.ReleaseCallback callback) |
Releases the loader.
|
<T extends Loader.Loadable> |
startLoading(T loadable,
Loader.Callback<T> callback,
int defaultMinRetryCount) |
Starts loading a
Loader.Loadable. |
public static final Loader.LoadErrorAction RETRY
public static final Loader.LoadErrorAction RETRY_RESET_ERROR_COUNT
public static final Loader.LoadErrorAction DONT_RETRY
Loader.Loadable and ignores any errors that have occurred.public static final Loader.LoadErrorAction DONT_RETRY_FATAL
Loader.Loadable. The next call to maybeThrowError() will throw
the last load error.public Loader(String threadName)
threadName - A name for the loader's thread.public static Loader.LoadErrorAction createRetryAction(boolean resetErrorCount, long retryDelayMillis)
Loader.LoadErrorAction for retrying with the given parameters.resetErrorCount - Whether the previous error count should be set to zero.retryDelayMillis - The number of milliseconds to wait before retrying.Loader.LoadErrorAction for retrying with the given parameters.public boolean hasFatalError()
startLoading(T, com.google.android.exoplayer2.upstream.Loader.Callback<T>, int) resulted in a fatal error. Calling maybeThrowError() will throw the fatal error.public void clearFatalError()
public <T extends Loader.Loadable> long startLoading(T loadable, Loader.Callback<T> callback, int defaultMinRetryCount)
Loader.Loadable.
The calling thread must be a Looper thread, which is the thread on which the Loader.Callback will be called.
T - The type of the loadable.loadable - The Loader.Loadable to load.callback - A callback to be called when the load ends.defaultMinRetryCount - The minimum number of times the load must be retried before maybeThrowError() will propagate an error.SystemClock.elapsedRealtime() when the load started.IllegalStateException - If the calling thread does not have an associated Looper.public boolean isLoading()
public void cancelLoading()
IllegalStateException - If the loader is not currently loading.public void release()
public void release(@Nullable
Loader.ReleaseCallback callback)
callback - An optional callback to be called on the loading thread once the loader has
been released.public void maybeThrowError()
throws IOException
LoaderErrorThrowerLoader.Loadable has incurred a number of errors greater than the Loaders default
minimum number of retries. Else does nothing.maybeThrowError in interface LoaderErrorThrowerIOException - The error.public void maybeThrowError(int minRetryCount)
throws IOException
LoaderErrorThrowerLoader.Loadable has incurred a number of errors greater than the specified minimum number
of retries. Else does nothing.maybeThrowError in interface LoaderErrorThrowerminRetryCount - A minimum retry count that must be exceeded for a non-fatal error to be
thrown. Should be non-negative.IOException - The error.