Skip to content

Commit

Permalink
Fix GenericViewTarget's protected methods being private. (#1273)
Browse files Browse the repository at this point in the history
* Fix GenericViewTarget's protected methods being private.

* Update API.
  • Loading branch information
colinrtwhite committed May 12, 2022
1 parent 1f1772f commit 92a6137
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 3 deletions.
2 changes: 2 additions & 0 deletions coil-base/api/coil-base.api
Expand Up @@ -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 {
Expand Down
4 changes: 2 additions & 2 deletions coil-base/src/main/java/coil/target/GenericViewTarget.kt
Expand Up @@ -41,14 +41,14 @@ abstract class GenericViewTarget<T : View> : ViewTarget<T>, 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()
}
Expand Down
2 changes: 1 addition & 1 deletion docs/transitions.md
Expand Up @@ -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:

Expand Down

0 comments on commit 92a6137

Please sign in to comment.