Then in ResourceDecoderRegistry.java, getResourceClasses method
@NonNull
@SuppressWarnings("unchecked")
public synchronized <T, R> List<Class<R>> getResourceClasses(
@NonNull Class<T> dataClass, @NonNull Class<R> resourceClass) {
List<Class<R>> result = new ArrayList<>();
for (String bucket : bucketPriorityList) {
List<Entry<?, ?>> entries = decoders.get(bucket);
if (entries == null) {
continue;
}
for (Entry<?, ?> entry : entries) {
if (entry.handles(dataClass, resourceClass)
&& !result.contains((Class<R>) entry.resourceClass)) {
result.add((Class<R>) entry.resourceClass);
}
}
}
return result;
}
it's make the result list first is Bitmap.class.
Register.java#getDecodePaths in this code the registeredResourceClasses's first item is Bitmap.class; decoderRegistry.getDecoders("byteBuffer", Bitmap.class) is return value will container "Downsampler" decoder
Downsampler will intercept gif pass to gifdrawable。 Downsampler's handles() always return true.
public boolean handles(@SuppressWarnings("unused") ByteBuffer byteBuffer) {
// We expect downsampler to handle any available type Android supports.
return true;
}
So if you prepend Bitmap.class Resources, your gif format will be not work.
How to remove Downsampler or move it to the behind make gif work ?
I found after add "avif-integration", GIFs can't be played.
Debugging the code revealed that the GIF is no longer a GifDrawable but instead a BitmapDrawable.
avif prepend Bitmap.class to resource class by this code
Then in ResourceDecoderRegistry.java, getResourceClasses method
it's make the result list first is Bitmap.class.
Register.java#getDecodePaths in this code the registeredResourceClasses's first item is Bitmap.class; decoderRegistry.getDecoders("byteBuffer", Bitmap.class) is return value will container "Downsampler" decoder
Downsampler will intercept gif pass to gifdrawable。 Downsampler's handles() always return true.
So if you prepend Bitmap.class Resources, your gif format will be not work.
How to remove Downsampler or move it to the behind make gif work ?