diff --git a/vito/core-impl/src/main/java/com/facebook/fresco/vito/core/impl/KFrescoController.kt b/vito/core-impl/src/main/java/com/facebook/fresco/vito/core/impl/KFrescoController.kt index 285b0399ae..a90477aecf 100644 --- a/vito/core-impl/src/main/java/com/facebook/fresco/vito/core/impl/KFrescoController.kt +++ b/vito/core-impl/src/main/java/com/facebook/fresco/vito/core/impl/KFrescoController.kt @@ -69,6 +69,10 @@ class KFrescoController( drawableFactory?.createDrawable(r, a, b)?.let { createDrawableModel(it, b) } } } + ?: run { + FLog.e(TAG, "Could not create Drawable for CloseableImage: $b") + null + } } } diff --git a/vito/drawee-support/src/main/java/com/facebook/fresco/vito/draweesupport/DrawableFactoryWrapper.kt b/vito/drawee-support/src/main/java/com/facebook/fresco/vito/draweesupport/DrawableFactoryWrapper.kt index 55d665b710..de16c8947d 100644 --- a/vito/drawee-support/src/main/java/com/facebook/fresco/vito/draweesupport/DrawableFactoryWrapper.kt +++ b/vito/drawee-support/src/main/java/com/facebook/fresco/vito/draweesupport/DrawableFactoryWrapper.kt @@ -14,7 +14,7 @@ import com.facebook.fresco.vito.options.ImageOptionsDrawableFactory import com.facebook.imagepipeline.drawable.DrawableFactory import com.facebook.imagepipeline.image.CloseableImage -class DrawableFactoryWrapper(private val drawableFactory: DrawableFactory) : +class DrawableFactoryWrapper private constructor(private val drawableFactory: DrawableFactory) : ImageOptionsDrawableFactory { override fun createDrawable( resources: Resources, @@ -30,4 +30,15 @@ class DrawableFactoryWrapper(private val drawableFactory: DrawableFactory) : } else { null } + + companion object { + @JvmStatic + fun wrap(drawableFactory: DrawableFactory): ImageOptionsDrawableFactory { + return if (drawableFactory is ImageOptionsDrawableFactory) { + drawableFactory + } else { + DrawableFactoryWrapper(drawableFactory) + } + } + } } diff --git a/vito/provider/src/main/java/com/facebook/fresco/vito/provider/impl/DefaultFrescoVitoProvider.kt b/vito/provider/src/main/java/com/facebook/fresco/vito/provider/impl/DefaultFrescoVitoProvider.kt index c670ec61dd..3e259451d2 100644 --- a/vito/provider/src/main/java/com/facebook/fresco/vito/provider/impl/DefaultFrescoVitoProvider.kt +++ b/vito/provider/src/main/java/com/facebook/fresco/vito/provider/impl/DefaultFrescoVitoProvider.kt @@ -86,11 +86,8 @@ class DefaultFrescoVitoProvider( return if (animatedDrawableFactory == null) { bitmapFactory } else { - if (animatedDrawableFactory is ImageOptionsDrawableFactory) { - ArrayVitoDrawableFactory(bitmapFactory, animatedDrawableFactory) - } else { - ArrayVitoDrawableFactory(bitmapFactory, DrawableFactoryWrapper(animatedDrawableFactory)) - } + ArrayVitoDrawableFactory( + bitmapFactory, DrawableFactoryWrapper.wrap(animatedDrawableFactory)) } } } diff --git a/vito/provider/src/main/java/com/facebook/fresco/vito/provider/impl/kotlin/KFrescoVitoProvider.kt b/vito/provider/src/main/java/com/facebook/fresco/vito/provider/impl/kotlin/KFrescoVitoProvider.kt index b2127301ba..39e1fa47f6 100644 --- a/vito/provider/src/main/java/com/facebook/fresco/vito/provider/impl/kotlin/KFrescoVitoProvider.kt +++ b/vito/provider/src/main/java/com/facebook/fresco/vito/provider/impl/kotlin/KFrescoVitoProvider.kt @@ -62,8 +62,8 @@ class KFrescoVitoProvider( override fun getConfig(): FrescoVitoConfig = vitoConfig private fun getFactory(): ImageOptionsDrawableFactory? { - return ImagePipelineFactory.getInstance().getAnimatedDrawableFactory(null)?.let { - DrawableFactoryWrapper(it) - } + return ImagePipelineFactory.getInstance() + .getAnimatedDrawableFactory(null) + ?.let(DrawableFactoryWrapper::wrap) } }