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/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() } 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: