Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix GenericViewTarget's protected methods being private. #1273

Merged
merged 2 commits into from
May 12, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions coil-base/api/coil-base.api
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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