diff options
author | Alan Viverette <alanv@google.com> | 2014-10-29 17:26:37 -0700 |
---|---|---|
committer | Alan Viverette <alanv@google.com> | 2014-10-29 17:26:37 -0700 |
commit | d739d7bd8aa4dc9f12968f21a8faa3544215092b (patch) | |
tree | 2b90dd128be1cae2cefc80dfad69686f2f67f67a | |
parent | 720a5c51beb5beab442832ea8d169aa5b4edb43f (diff) | |
download | frameworks_base-d739d7bd8aa4dc9f12968f21a8faa3544215092b.zip frameworks_base-d739d7bd8aa4dc9f12968f21a8faa3544215092b.tar.gz frameworks_base-d739d7bd8aa4dc9f12968f21a8faa3544215092b.tar.bz2 |
Ensure ImageView.setImageResource() always resolves Drawable
Fixes no-op on method call after configuration change at the expense
of removing a micro-optimization that wasn't really needed.
BUG: 18178233
Change-Id: I36eccf91b138e4bed34be96d9b87200edeb66938
-rw-r--r-- | core/java/android/widget/ImageView.java | 22 |
1 files changed, 11 insertions, 11 deletions
diff --git a/core/java/android/widget/ImageView.java b/core/java/android/widget/ImageView.java index 1ac4dd8..c68bfca 100644 --- a/core/java/android/widget/ImageView.java +++ b/core/java/android/widget/ImageView.java @@ -386,21 +386,21 @@ public class ImageView extends View { */ @android.view.RemotableViewMethod public void setImageResource(int resId) { - if (mUri != null || mResource != resId) { - final int oldWidth = mDrawableWidth; - final int oldHeight = mDrawableHeight; + // The resource configuration may have changed, so we should always + // try to load the resource even if the resId hasn't changed. + final int oldWidth = mDrawableWidth; + final int oldHeight = mDrawableHeight; - updateDrawable(null); - mResource = resId; - mUri = null; + updateDrawable(null); + mResource = resId; + mUri = null; - resolveUri(); + resolveUri(); - if (oldWidth != mDrawableWidth || oldHeight != mDrawableHeight) { - requestLayout(); - } - invalidate(); + if (oldWidth != mDrawableWidth || oldHeight != mDrawableHeight) { + requestLayout(); } + invalidate(); } /** |