com.bumptech.glide.load.engine
Class Engine
java.lang.Object
com.bumptech.glide.load.engine.Engine
- All Implemented Interfaces:
- MemoryCache.ResourceRemovedListener
public class Engine
- extends Object
- implements MemoryCache.ResourceRemovedListener
Responsible for starting loads and managing active and cached resources.
Nested Class Summary |
static class |
Engine.LoadStatus
Allows a request to indicate it no longer is interested in a given load. |
Method Summary |
|
load(int width,
int height,
ResourceDecoder<File,Z> cacheDecoder,
DataFetcher<T> fetcher,
Encoder<T> sourceEncoder,
ResourceDecoder<T,Z> decoder,
Transformation<Z> transformation,
ResourceEncoder<Z> encoder,
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,
EngineResource<?> resource)
|
void |
onResourceReleased(Key cacheKey,
EngineResource resource)
|
void |
onResourceRemoved(EngineResource resource)
|
void |
release(Resource resource)
|
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Engine
public Engine(MemoryCache memoryCache,
DiskCache diskCache,
ExecutorService resizeService,
ExecutorService diskCacheService)
load
public <T,Z,R> Engine.LoadStatus load(int width,
int height,
ResourceDecoder<File,Z> cacheDecoder,
DataFetcher<T> fetcher,
Encoder<T> sourceEncoder,
ResourceDecoder<T,Z> decoder,
Transformation<Z> transformation,
ResourceEncoder<Z> encoder,
ResourceTranscoder<Z,R> transcoder,
Priority priority,
boolean isMemoryCacheable,
DiskCacheStrategy diskCacheStrategy,
ResourceCallback cb)
- Starts a load for the given arguments. Must be called on the main thread.
The flow for any request is as follows:
- Check the memory cache and provide the cached resource if present
- Check the current set of actively used resources and return the active resource if present
- Check the current set of in progress loads and add the cb to the in progress load if present
- Start a new load
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.
- Type Parameters:
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.- Parameters:
width
- The target width of the retrieved resource.height
- The target height of the retrieved resource.cacheDecoder
- The decoder to use to decode data already in the disk cache.fetcher
- The fetcher to use to retrieve data not in the disk cache.sourceEncoder
- The encoder to use to encode any retrieved data directly to cache.decoder
- The decoder to use to decode any retrieved data not in cache.transformation
- The transformation to use to transform the decoded resource.encoder
- The encoder to to use to write the decoded and transformed resource to the disk cache.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.
release
public void release(Resource resource)
onEngineJobComplete
public void onEngineJobComplete(Key key,
EngineResource<?> resource)
onEngineJobCancelled
public void onEngineJobCancelled(com.bumptech.glide.load.engine.EngineJob engineJob,
Key key)
onResourceRemoved
public void onResourceRemoved(EngineResource resource)
- Specified by:
onResourceRemoved
in interface MemoryCache.ResourceRemovedListener
onResourceReleased
public void onResourceReleased(Key cacheKey,
EngineResource resource)