You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I tried to add the second (null) line above to make sure I clear any accidental color filters, but it still shows up, I took a dump (Java heap ;) and checked:
correctly forces a mutate on the original's drawable and detaches the state from preview's.
original.setColorFilter(null) was not enough because ImageView does a noop if the color filter is the same: remember ImageView(original).mColorFilter == null.
I call get() on my DrawableResource, which, the first time it's called, returns the original Drawable
I call mutate on the original Drawable which creates a new state, but returns the original Drawable.
I call setColorFilter on the original Drawable which sets the color filter of the paint belonging to the state of the original drawable.
I call get() on my DrawableResource a second time, which creates a new Drawable using newDrawable(). The new drawable however, still points to the original Drawable's state.
I draw my new drawable and the image is drawn with the color filter I set on the original drawable.
This could only happen if you set the color filter in between the first load completing and the second load completing and the first load completed without any other calls to get() which may be subject to a race.
I believe the solution is going to be always calling newDrawable() on get() so we always return a pristine unmodified Drawable. We could also mutate the state on newDrawable, but that isn't in line with what BitmapDrawable does.
I have two
ImageView
s: original and preview. I load the sameUri
into both using the same method:It always loads the images correctly, but sometimes (I hate this word in IT) the color filter I set shows up on both images:
I tried to add the second (
null
) line above to make sure I clear any accidental color filters, but it still shows up, I took a dump (Java heap ;) and checked:The problem is the
state
line.Everything else looks normal and not shared (bounds, callback, ...)
The text was updated successfully, but these errors were encountered: