After going through all Glide documentation and StackOverflow questions and answers, I cannot find any information regarding applying resource decoder for a single Glide call in version 4.
In version Glide 3, we can do this:
Glide.with(imagePreview.context)
.load(mediaItem.path)
.asBitmap()
.decoder(decoderWithDownSampleAtMost(imagePreview.context))
.diskCacheStrategy(DiskCacheStrategy.NONE)
.skipMemoryCache(false)
.dontAnimate()
.into(target)
private fun decoderWithDownSampleAtMost(ctx: Context): GifBitmapWrapperResourceDecoder {
return GifBitmapWrapperResourceDecoder(
ImageVideoBitmapDecoder(StreamBitmapDecoder(Downsampler.AT_MOST,
Glide.get(ctx).bitmapPool,
DecodeFormat.DEFAULT),
FileDescriptorBitmapDecoder(ctx)),
GifResourceDecoder(ctx),
Glide.get(ctx).bitmapPool)
}
And in version 4, I know we can use AppGlideModule
for custom ResourceDecoder
@GlideModule
class MyAppGlideModule : AppGlideModule() {
override fun registerComponents(context: Context, glide: Glide, registry: Registry) {
registry.prepend(String::class.java, Bitmap::class.java, GalleryDecoder(context))
}
}
However, this applies to all Glide calls. How can I make ResourceDecoder
behave like v3: the ability to apply on individual call?
from Glide 4 - ResourceDecoder on specific call
No comments:
Post a Comment