Skip to content

Commit

Permalink
Fix ScaleDrawable and CrossfadeDrawable not respecting tint states. (#…
Browse files Browse the repository at this point in the history
…2704)

* Fix ScaleDrawable and CrossfadeDrawable not respecting tint states.

* Remove debug invalidateSelf.

* Update API.
  • Loading branch information
colinrtwhite authored Nov 19, 2024
1 parent 908b99d commit ce00eab
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 5 deletions.
2 changes: 2 additions & 0 deletions coil-core/api/android/coil-core.api
Original file line number Diff line number Diff line change
Expand Up @@ -904,6 +904,7 @@ public final class coil3/size/ScaleDrawable : android/graphics/drawable/Drawable
public final fun getScale ()Lcoil3/size/Scale;
public fun invalidateDrawable (Landroid/graphics/drawable/Drawable;)V
public fun isRunning ()Z
public fun isStateful ()Z
public fun scheduleDrawable (Landroid/graphics/drawable/Drawable;Ljava/lang/Runnable;J)V
public fun setAlpha (I)V
public fun setColorFilter (Landroid/graphics/ColorFilter;)V
Expand Down Expand Up @@ -1049,6 +1050,7 @@ public final class coil3/transition/CrossfadeDrawable : android/graphics/drawabl
public final fun getStart ()Landroid/graphics/drawable/Drawable;
public fun invalidateDrawable (Landroid/graphics/drawable/Drawable;)V
public fun isRunning ()Z
public fun isStateful ()Z
public fun registerAnimationCallback (Landroidx/vectordrawable/graphics/drawable/Animatable2Compat$AnimationCallback;)V
public fun scheduleDrawable (Landroid/graphics/drawable/Drawable;Ljava/lang/Runnable;J)V
public fun setAlpha (I)V
Expand Down
4 changes: 3 additions & 1 deletion coil-core/src/androidMain/kotlin/coil3/size/ScaleDrawable.kt
Original file line number Diff line number Diff line change
Expand Up @@ -81,10 +81,12 @@ class ScaleDrawable @JvmOverloads constructor(
childScale = multiplier.toFloat()
}

override fun onLevelChange(level: Int) = child.setLevel(level)
override fun isStateful() = child.isStateful

override fun onStateChange(state: IntArray) = child.setState(state)

override fun onLevelChange(level: Int) = child.setLevel(level)

override fun getIntrinsicWidth() = child.intrinsicWidth

override fun getIntrinsicHeight() = child.intrinsicHeight
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -154,10 +154,8 @@ class CrossfadeDrawable @JvmOverloads constructor(
end?.let { updateBounds(it, bounds) }
}

override fun onLevelChange(level: Int): Boolean {
val startChanged = start?.setLevel(level) ?: false
val endChanged = end?.setLevel(level) ?: false
return startChanged || endChanged
override fun isStateful(): Boolean {
return (start?.isStateful ?: false) || (end?.isStateful ?: false)
}

override fun onStateChange(state: IntArray): Boolean {
Expand All @@ -166,6 +164,12 @@ class CrossfadeDrawable @JvmOverloads constructor(
return startChanged || endChanged
}

override fun onLevelChange(level: Int): Boolean {
val startChanged = start?.setLevel(level) ?: false
val endChanged = end?.setLevel(level) ?: false
return startChanged || endChanged
}

override fun getIntrinsicWidth() = intrinsicWidth

override fun getIntrinsicHeight() = intrinsicHeight
Expand Down

0 comments on commit ce00eab

Please sign in to comment.