|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object com.bumptech.glide.load.data.LocalUriFetcher<T>
T
- The type of data that will obtained for the given uri (For example, InputStream
or
ParcelFileDescriptor
.public abstract class LocalUriFetcher<T>
A DataFetcher that uses an ContentResolver
to load data from a Uri
pointing to a local resource.
Constructor Summary | |
---|---|
LocalUriFetcher(Context context,
Uri uri)
Opens an input stream for a uri pointing to a local asset. |
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. |
protected abstract void |
close(T data)
Closes the concrete data type if necessary. |
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. |
protected abstract T |
loadResource(Uri uri,
ContentResolver contentResolver)
Returns a concrete data type from the given Uri using the given
ContentResolver . |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public LocalUriFetcher(Context context, Uri uri)
context
- A context (this will be weakly referenced and the load will fail if the weak reference
is cleared before loadData(Priority)
} is called.uri
- A Uri pointing to a local asset. This load will fail if the uri isn't openable by
ContentResolver.openInputStream(android.net.Uri)
ContentResolver.openInputStream(android.net.Uri)
Method Detail |
---|
public final T loadData(Priority priority) throws Exception
DataFetcher
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.
loadData
in interface DataFetcher<T>
priority
- The priority with which the request should be completed.
Exception
where the data retuned will be cleaned up
public void cleanup()
DataFetcher
DataFetcher.loadData(Priority)
has been decoded by the
ResourceDecoder
.
Note - this method will be run on a background thread so blocking I/O is safe.
cleanup
in interface DataFetcher<T>
public void cancel()
DataFetcher
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.
cancel
in interface DataFetcher<T>
public String getId()
DataFetcher
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.
getId
in interface DataFetcher<T>
protected abstract T loadResource(Uri uri, ContentResolver contentResolver) throws FileNotFoundException
Uri
using the given
ContentResolver
.
FileNotFoundException
protected abstract void close(T data) throws IOException
Note - We can't rely on the closeable interface because it was added after our min API level. See issue #157.
data
- The data to close.
IOException
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |