下面列出了怎么用com.bumptech.glide.load.ResourceDecoder的API类实例代码及写法,或者点击链接到github查看源代码。
public <Z> Resource<Z> load(Key key, ResourceDecoder<File, Z> decoder, int width, int height) {
File fromCache = diskCache.get(key);
if (fromCache == null) {
return null;
}
Resource<Z> result = null;
try {
result = decoder.decode(fromCache, width, height);
} catch (IOException e) {
if (Log.isLoggable(TAG, Log.DEBUG)) {
Log.d(TAG, "Exception decoding image from cache", e);
}
}
if (result == null) {
if (Log.isLoggable(TAG, Log.DEBUG)) {
Log.d(TAG, "Failed to decode image from cache or not present in cache");
}
diskCache.delete(key);
}
return result;
}
GifBitmapWrapperResourceDecoder(ResourceDecoder<ImageVideoWrapper, Bitmap> bitmapDecoder,
ResourceDecoder<InputStream, GifDrawable> gifDecoder, BitmapPool bitmapPool, ImageTypeParser parser,
BufferedStreamFactory streamFactory) {
this.bitmapDecoder = bitmapDecoder;
this.gifDecoder = gifDecoder;
this.bitmapPool = bitmapPool;
this.parser = parser;
this.streamFactory = streamFactory;
}
public EngineKey(String id, Key signature, int width, int height, ResourceDecoder cacheDecoder,
ResourceDecoder decoder, Transformation transformation, ResourceEncoder encoder,
ResourceTranscoder transcoder, Encoder sourceEncoder) {
this.id = id;
this.signature = signature;
this.width = width;
this.height = height;
this.cacheDecoder = cacheDecoder;
this.decoder = decoder;
this.transformation = transformation;
this.encoder = encoder;
this.transcoder = transcoder;
this.sourceEncoder = sourceEncoder;
}
@SuppressWarnings("rawtypes")
public EngineKey buildKey(String id, Key signature, int width, int height, ResourceDecoder cacheDecoder,
ResourceDecoder sourceDecoder, Transformation transformation, ResourceEncoder encoder,
ResourceTranscoder transcoder, Encoder sourceEncoder) {
return new EngineKey(id, signature, width, height, cacheDecoder, sourceDecoder, transformation, encoder,
transcoder, sourceEncoder);
}
/**
* {@inheritDoc}
*/
@Override
public ResourceDecoder<File, Z> getCacheDecoder() {
if (cacheDecoder != null) {
return cacheDecoder;
} else {
return parent.getCacheDecoder();
}
}
/**
* {@inheritDoc}
*/
@Override
public ResourceDecoder<T, Z> getSourceDecoder() {
if (sourceDecoder != null) {
return sourceDecoder;
} else {
return parent.getSourceDecoder();
}
}
public PaletteBitmapDecoder(
BitmapPool bitmapPool,
ResourceDecoder<InputStream, Bitmap> bitmapDecoder,
ResourceDecoder<InputStream, Palette> paletteDecoder) {
this.bitmapPool = bitmapPool;
this.paletteDecoder = paletteDecoder;
this.bitmapDecoder = bitmapDecoder;
}
@Override
public ResourceDecoder<File, GifDrawable> getCacheDecoder() {
return cacheDecoder;
}
@Override
public ResourceDecoder<InputStream, GifDrawable> getSourceDecoder() {
return decoder;
}
@Override
public ResourceDecoder<File, Bitmap> getCacheDecoder() {
return cacheDecoder;
}
@Override
public ResourceDecoder<InputStream, Bitmap> getSourceDecoder() {
return decoder;
}
@Override
public ResourceDecoder<File, Bitmap> getCacheDecoder() {
return cacheDecoder;
}
@Override
public ResourceDecoder<ParcelFileDescriptor, Bitmap> getSourceDecoder() {
return sourceDecoder;
}
public ImageVideoBitmapDecoder(ResourceDecoder<InputStream, Bitmap> streamDecoder,
ResourceDecoder<ParcelFileDescriptor, Bitmap> fileDescriptorDecoder) {
this.streamDecoder = streamDecoder;
this.fileDescriptorDecoder = fileDescriptorDecoder;
}
@Override
public ResourceDecoder<File, Bitmap> getCacheDecoder() {
return cacheDecoder;
}
@Override
public ResourceDecoder<ImageVideoWrapper, Bitmap> getSourceDecoder() {
return sourceDecoder;
}
public FileToStreamDecoder(ResourceDecoder<InputStream, T> streamDecoder) {
this(streamDecoder, DEFAULT_FILE_OPENER);
}
FileToStreamDecoder(ResourceDecoder<InputStream, T> streamDecoder, FileOpener fileOpener) {
this.streamDecoder = streamDecoder;
this.fileOpener = fileOpener;
}
@Override
public ResourceDecoder<File, File> getCacheDecoder() {
return cacheDecoder;
}
@Override
public ResourceDecoder<InputStream, File> getSourceDecoder() {
return ERROR_DECODER;
}
@Override
public ResourceDecoder<File, GifBitmapWrapper> getCacheDecoder() {
return cacheDecoder;
}
@Override
public ResourceDecoder<ImageVideoWrapper, GifBitmapWrapper> getSourceDecoder() {
return sourceDecoder;
}
public GifBitmapWrapperResourceDecoder(ResourceDecoder<ImageVideoWrapper, Bitmap> bitmapDecoder,
ResourceDecoder<InputStream, GifDrawable> gifDecoder, BitmapPool bitmapPool) {
this(bitmapDecoder, gifDecoder, bitmapPool, DEFAULT_PARSER, DEFAULT_STREAM_FACTORY);
}
public GifBitmapWrapperStreamResourceDecoder(
ResourceDecoder<ImageVideoWrapper, GifBitmapWrapper> gifBitmapDecoder) {
this.gifBitmapDecoder = gifBitmapDecoder;
}
@Override
public ResourceDecoder<File, Z> getCacheDecoder() {
return null;
}
@Override
public ResourceDecoder<T, Z> getSourceDecoder() {
return null;
}
/**
* {@inheritDoc}
*/
@Override
public ResourceDecoder<File, Z> getCacheDecoder() {
return dataLoadProvider.getCacheDecoder();
}
/**
* {@inheritDoc}
*/
@Override
public ResourceDecoder<T, Z> getSourceDecoder() {
return dataLoadProvider.getSourceDecoder();
}
public StreamAnimationDecoder(ResourceDecoder<ByteBuffer, Drawable> byteBufferDecoder) {
this.byteBufferDecoder = byteBufferDecoder;
}
public PaletteCacheDecoder(
ResourceDecoder<InputStream, Palette> paletteDecoder,
ResourceDecoder<InputStream, Bitmap> bitmapDecoder) {
this.paletteDecoder = paletteDecoder;
this.bitmapDecoder = bitmapDecoder;
}