From 30e305c3c9daf1103a72f0d62b0adf89629753be Mon Sep 17 00:00:00 2001 From: Colin White Date: Thu, 12 May 2022 19:13:14 -0400 Subject: [PATCH 1/2] Fix GenericViewTarget's protected methods being private. --- coil-base/src/main/java/coil/target/GenericViewTarget.kt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/coil-base/src/main/java/coil/target/GenericViewTarget.kt b/coil-base/src/main/java/coil/target/GenericViewTarget.kt index ef2954a45c..bd795f85f1 100644 --- a/coil-base/src/main/java/coil/target/GenericViewTarget.kt +++ b/coil-base/src/main/java/coil/target/GenericViewTarget.kt @@ -41,14 +41,14 @@ abstract class GenericViewTarget : ViewTarget, TransitionTarget, De } /** Replace the [ImageView]'s current drawable with [drawable]. */ - private fun updateDrawable(drawable: Drawable?) { + protected fun updateDrawable(drawable: Drawable?) { (this.drawable as? Animatable)?.stop() this.drawable = drawable updateAnimation() } /** Start/stop the current [Drawable]'s animation based on the current lifecycle state. */ - private fun updateAnimation() { + protected fun updateAnimation() { val animatable = drawable as? Animatable ?: return if (isStarted) animatable.start() else animatable.stop() } From a34133745a0783ef87bcf55f96afb43fc25fe08e Mon Sep 17 00:00:00 2001 From: Colin White Date: Thu, 12 May 2022 19:15:20 -0400 Subject: [PATCH 2/2] Update API. --- coil-base/api/coil-base.api | 2 ++ docs/transitions.md | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/coil-base/api/coil-base.api b/coil-base/api/coil-base.api index c36adaa074..4c83ba68d6 100644 --- a/coil-base/api/coil-base.api +++ b/coil-base/api/coil-base.api @@ -844,6 +844,8 @@ public abstract class coil/target/GenericViewTarget : androidx/lifecycle/Default public fun onStop (Landroidx/lifecycle/LifecycleOwner;)V public fun onSuccess (Landroid/graphics/drawable/Drawable;)V public abstract fun setDrawable (Landroid/graphics/drawable/Drawable;)V + protected final fun updateAnimation ()V + protected final fun updateDrawable (Landroid/graphics/drawable/Drawable;)V } public class coil/target/ImageViewTarget : coil/target/GenericViewTarget { diff --git a/docs/transitions.md b/docs/transitions.md index 362278fe95..9ff93f6d39 100644 --- a/docs/transitions.md +++ b/docs/transitions.md @@ -2,7 +2,7 @@ Transitions allow you to animate setting the result of an image request on a `Target`. -Both `ImageLoader` and `ImageRequest` builders accept a `Transition.Factory`. Transitions allow you to control how the sucess/error drawable is set on the `Target`. This allows you to animate the target's view or wrap the input drawable. +Both `ImageLoader` and `ImageRequest` builders accept a `Transition.Factory`. Transitions allow you to control how the success/error drawable is set on the `Target`. This allows you to animate the target's view or wrap the input drawable. By default, Coil comes packaged with 2 transitions: