From 1ac653ffc6dcb62aff86b488810b4d83b4000852 Mon Sep 17 00:00:00 2001 From: Peter Abbondanzo Date: Thu, 17 Oct 2024 08:14:21 -0700 Subject: [PATCH] Avoid ClassCastExceptions in DefaultBitmapAnimationDrawableFactory Reviewed By: oprisnik Differential Revision: D64261390 fbshipit-source-id: 89dc9ede0eaebe8425da2d5951b465bfc8cfed66 --- .../factory/DefaultBitmapAnimationDrawableFactory.java | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/animated-base/src/main/java/com/facebook/fresco/animation/factory/DefaultBitmapAnimationDrawableFactory.java b/animated-base/src/main/java/com/facebook/fresco/animation/factory/DefaultBitmapAnimationDrawableFactory.java index 0509738c1e..7f37e91e57 100644 --- a/animated-base/src/main/java/com/facebook/fresco/animation/factory/DefaultBitmapAnimationDrawableFactory.java +++ b/animated-base/src/main/java/com/facebook/fresco/animation/factory/DefaultBitmapAnimationDrawableFactory.java @@ -118,7 +118,11 @@ public boolean supportsImageType(CloseableImage image) { } @Override + @Nullable public Drawable createDrawable(CloseableImage image) { + if (!supportsImageType(image)) { + return null; + } CloseableAnimatedImage closeable = ((CloseableAnimatedImage) image); AnimatedImage animatedImage = closeable.getImage(); AnimationBackend animationBackend = @@ -134,8 +138,12 @@ public Drawable createDrawable(CloseableImage image) { } @Override + @Nullable public Drawable createDrawable( Resources resources, CloseableImage closeableImage, ImageOptions imageOptions) { + if (!supportsImageType(closeableImage)) { + return null; + } CloseableAnimatedImage closeable = ((CloseableAnimatedImage) closeableImage); AnimatedImage animatedImage = closeable.getImage(); AnimationBackend animationBackend = null;