T
- The type of manifest.public class ManifestFetcher<T> extends Object implements Loader.Callback
Client code is responsible for ensuring that only one load is taking place at any one time. Typical usage of this class is as follows:
singleLoad(Looper, ManifestCallback)
and
waiting for the callback to be invoked.requestRefresh()
on the
loader whenever a refresh is required.Modifier and Type | Class and Description |
---|---|
static interface |
ManifestFetcher.EventListener
Interface definition for a callback to be notified of
ManifestFetcher events. |
static interface |
ManifestFetcher.ManifestCallback<T>
Callback for the result of a single load.
|
static class |
ManifestFetcher.ManifestIOException
Thrown when an error occurs trying to fetch a manifest.
|
static interface |
ManifestFetcher.RedirectingManifest
Interface for manifests that are able to specify that subsequent loads should use a different
URI.
|
Constructor and Description |
---|
ManifestFetcher(String manifestUri,
UriDataSource uriDataSource,
UriLoadable.Parser<T> parser) |
ManifestFetcher(String manifestUri,
UriDataSource uriDataSource,
UriLoadable.Parser<T> parser,
Handler eventHandler,
ManifestFetcher.EventListener eventListener) |
Modifier and Type | Method and Description |
---|---|
void |
disable()
Disables refresh functionality.
|
void |
enable()
Enables refresh functionality.
|
T |
getManifest()
Gets a
Pair containing the most recently loaded manifest together with the timestamp
at which the load completed. |
long |
getManifestLoadCompleteTimestamp()
Gets the value of
SystemClock.elapsedRealtime() when the last load completed. |
long |
getManifestLoadStartTimestamp()
Gets the value of
SystemClock.elapsedRealtime() when the last completed load started. |
void |
maybeThrowError()
Throws the error that affected the most recent attempt to load the manifest.
|
void |
onLoadCanceled(Loader.Loadable loadable)
Invoked when loading has been canceled.
|
void |
onLoadCompleted(Loader.Loadable loadable)
Invoked when the data source has been fully loaded.
|
void |
onLoadError(Loader.Loadable loadable,
IOException exception)
Invoked when the data source is stopped due to an error.
|
void |
requestRefresh()
Should be invoked repeatedly by callers who require an updated manifest.
|
void |
singleLoad(Looper callbackLooper,
ManifestFetcher.ManifestCallback<T> callback)
Performs a single manifest load.
|
void |
updateManifestUri(String manifestUri)
Updates the manifest location.
|
public ManifestFetcher(String manifestUri, UriDataSource uriDataSource, UriLoadable.Parser<T> parser)
manifestUri
- The manifest location.uriDataSource
- The UriDataSource
to use when loading the manifest.parser
- A parser to parse the loaded manifest data.public ManifestFetcher(String manifestUri, UriDataSource uriDataSource, UriLoadable.Parser<T> parser, Handler eventHandler, ManifestFetcher.EventListener eventListener)
manifestUri
- The manifest location.uriDataSource
- The UriDataSource
to use when loading the manifest.parser
- A parser to parse the loaded manifest data.eventHandler
- A handler to use when delivering events to eventListener
. May be
null if delivery of events is not required.eventListener
- A listener of events. May be null if delivery of events is not required.public void updateManifestUri(String manifestUri)
manifestUri
- The manifest location.public void singleLoad(Looper callbackLooper, ManifestFetcher.ManifestCallback<T> callback)
callbackLooper
- The looper associated with the thread on which the callback should be
invoked.callback
- The callback to receive the result.public T getManifest()
Pair
containing the most recently loaded manifest together with the timestamp
at which the load completed.public long getManifestLoadStartTimestamp()
SystemClock.elapsedRealtime()
when the last completed load started.SystemClock.elapsedRealtime()
when the last completed load
started.public long getManifestLoadCompleteTimestamp()
SystemClock.elapsedRealtime()
when the last load completed.SystemClock.elapsedRealtime()
when the last load completed.public void maybeThrowError() throws ManifestFetcher.ManifestIOException
ManifestFetcher.ManifestIOException
- The error that affected the most recent attempt to load the
manifest.public void enable()
public void disable()
public void requestRefresh()
public void onLoadCompleted(Loader.Loadable loadable)
Loader.Callback
onLoadCompleted
in interface Loader.Callback
loadable
- The loadable whose load has completed.public void onLoadCanceled(Loader.Loadable loadable)
Loader.Callback
onLoadCanceled
in interface Loader.Callback
loadable
- The loadable whose load has been canceled.public void onLoadError(Loader.Loadable loadable, IOException exception)
Loader.Callback
onLoadError
in interface Loader.Callback
loadable
- The loadable whose load has failed.