public class Engine extends Object implements MemoryCache.ResourceRemovedListener
Modifier and Type | Class and Description |
---|---|
static class |
Engine.LoadStatus
Allows a request to indicate it no longer is interested in a given load.
|
Constructor and Description |
---|
Engine(MemoryCache memoryCache,
DiskCache.Factory diskCacheFactory,
ExecutorService diskCacheService,
ExecutorService sourceService) |
Modifier and Type | Method and Description |
---|---|
void |
clearDiskCache() |
<T,Z,R> Engine.LoadStatus |
load(Key signature,
int width,
int height,
DataFetcher<T> fetcher,
DataLoadProvider<T,Z> loadProvider,
Transformation<Z> transformation,
ResourceTranscoder<Z,R> transcoder,
Priority priority,
boolean isMemoryCacheable,
DiskCacheStrategy diskCacheStrategy,
ResourceCallback cb)
Starts a load for the given arguments.
|
void |
onEngineJobCancelled(com.bumptech.glide.load.engine.EngineJob engineJob,
Key key) |
void |
onEngineJobComplete(Key key,
com.bumptech.glide.load.engine.EngineResource<?> resource) |
void |
onResourceReleased(Key cacheKey,
com.bumptech.glide.load.engine.EngineResource resource) |
void |
onResourceRemoved(Resource<?> resource) |
void |
release(Resource resource) |
public Engine(MemoryCache memoryCache, DiskCache.Factory diskCacheFactory, ExecutorService diskCacheService, ExecutorService sourceService)
public <T,Z,R> Engine.LoadStatus load(Key signature, int width, int height, DataFetcher<T> fetcher, DataLoadProvider<T,Z> loadProvider, Transformation<Z> transformation, ResourceTranscoder<Z,R> transcoder, Priority priority, boolean isMemoryCacheable, DiskCacheStrategy diskCacheStrategy, ResourceCallback cb)
The flow for any request is as follows:
Active resources are those that have been provided to at least one request and have not yet been released. Once all consumers of a resource have released that resource, the resource then goes to cache. If the resource is ever returned to a new consumer from cache, it is re-added to the active resources. If the resource is evicted from the cache, its resources are recycled and re-used if possible and the resource is discarded. There is no strict requirement that consumers release their resources so active resources are held weakly.
T
- The type of data the resource will be decoded from.Z
- The type of the resource that will be decoded.R
- The type of the resource that will be transcoded from the decoded resource.signature
- A non-null unique key to be mixed into the cache key that identifies the version of the data to
be loaded.width
- The target width in pixels of the desired resource.height
- The target height in pixels of the desired resource.fetcher
- The fetcher to use to retrieve data not in the disk cache.loadProvider
- The load provider containing various encoders and decoders use to decode and encode data.transformation
- The transformation to use to transform the decoded resource.transcoder
- The transcoder to use to transcode the decoded and transformed resource.priority
- The priority with which the request should run.isMemoryCacheable
- True if the transcoded resource can be cached in memory.diskCacheStrategy
- The strategy to use that determines what type of data, if any,
will be cached in the local disk cache.cb
- The callback that will be called when the load completes.public void release(Resource resource)
public void onEngineJobComplete(Key key, com.bumptech.glide.load.engine.EngineResource<?> resource)
public void onEngineJobCancelled(com.bumptech.glide.load.engine.EngineJob engineJob, Key key)
public void onResourceRemoved(Resource<?> resource)
onResourceRemoved
in interface MemoryCache.ResourceRemovedListener
public void onResourceReleased(Key cacheKey, com.bumptech.glide.load.engine.EngineResource resource)
public void clearDiskCache()