|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
T
- The type of data to be loaded (InputStream, byte[], File etc).public interface DataFetcher<T>
An interface for lazily retrieving data that can be used to load a resource. A new instance is created per
resource load by ModelLoader
. loadData(Priority)
may or may not be
called for any given load depending on whether or not the corresponding resource is cached. Cancel also may or may
not be called. If loadData(Priority)
is called, then so cleanup()
will be called.
Method Summary | |
---|---|
void |
cancel()
A method that will be called when a load is no longer relevant and has been cancelled. |
void |
cleanup()
Cleanup or recycle any resources used by this data fetcher. |
String |
getId()
Returns a string uniquely identifying the data that this fetcher will fetch including the specific size. |
T |
loadData(Priority priority)
Asynchronously fetch data from which a resource can be decoded. |
Method Detail |
---|
T loadData(Priority priority) throws Exception
ExecutorService
that may have more than one background thread.
This method will only be called when the corresponding resource is not in the cache.
Note - this method will be run on a background thread so blocking I/O is safe.
priority
- The priority with which the request should be completed.
Exception
where the data retuned will be cleaned up
void cleanup()
loadData(Priority)
has been decoded by the
ResourceDecoder
.
Note - this method will be run on a background thread so blocking I/O is safe.
String getId()
A hash of the bytes of the data that will be fetched is the ideal id but since that is in many cases impractical, urls, file paths, and uris are normally sufficient.
Note - this method will be run on the main thread so it should not perform blocking operations and should finish quickly.
void cancel()
The best way to use this method is to cancel any loads that have not yet started, but allow those that are in process to finish since its we typically will want to display the same resource in a different view in the near future.
Note - this method will be run on the main thread so it should not perform blocking operations and should finish quickly.
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |