Mutate crossfade start/end drawables#572
Conversation
| * NOTE: The animation can only be executed once as the [start] drawable is dereferenced at the end of the transition. | ||
| * | ||
| * @param start The [Drawable] to crossfade from. | ||
| * @param start The [Drawable] to crossfade from. Will be mutated to prevent modifying alpha of original drawable |
There was a problem hiding this comment.
I don't think we need to mention mutation in the docs.
| class CrossfadeDrawable @JvmOverloads constructor( | ||
| private var start: Drawable?, | ||
| start: Drawable?, | ||
| private val end: Drawable?, |
There was a problem hiding this comment.
We should probably mutate end as well since it could be loaded from resources.
There was a problem hiding this comment.
Yep, didn't think about that! Since we can provide something like error placeholder. Tested it in sample, same bug
#571 (comment)
There was a problem hiding this comment.
Fixed. Not sure if tests are good enough, they are testing drawable changes, but with a bit of a hack - since percent of animation is tied to SystemClock and can't be influenced directly.
|
|
||
| this.start = start?.mutate() | ||
| start?.callback = this | ||
| end?.callback = this |
There was a problem hiding this comment.
Should this be this.start and this.end? drawable.mutate is supposed to return the same drawable, but there's nothing to prevent a bad drawable from returning a new drawable.
|
Thanks for finding + fixing this! |
dc45bb0 to
faff35d
Compare
…es (coil-kt#571) Remove mention of drawable mutation from CrossfadeDrawable doc (coil-kt#571)
faff35d to
fb0c458
Compare
* Add failing test for crossfade drawable alpha bug (coil-kt#571) * Change CrossfadeDrawable constructor to mutate start drawable (coil-kt#571) * Add test for both start/end drawables in CrossfadeDrawableTest (coil-kt#571) * Change CrossfadeDrawable constructor to mutate both start/end drawables (coil-kt#571) Remove mention of drawable mutation from CrossfadeDrawable doc (coil-kt#571)
* Add failing test for crossfade drawable alpha bug (#571) * Change CrossfadeDrawable constructor to mutate start drawable (#571) * Add test for both start/end drawables in CrossfadeDrawableTest (#571) * Change CrossfadeDrawable constructor to mutate both start/end drawables (#571) Remove mention of drawable mutation from CrossfadeDrawable doc (#571)
Fixes #571