diff options
author | Chet Haase <chet@google.com> | 2015-06-17 14:43:30 -0700 |
---|---|---|
committer | Chet Haase <chet@google.com> | 2015-06-17 15:28:25 -0700 |
commit | 8473f5a768a1eafda92c81d208c00db334dfa9d4 (patch) | |
tree | 454c616ce62d492596bf2ef10217f2c3a05d2344 /core | |
parent | 5c82d2cc17df9774e677f6bab9cb52659fc2b56d (diff) | |
download | frameworks_base-8473f5a768a1eafda92c81d208c00db334dfa9d4.zip frameworks_base-8473f5a768a1eafda92c81d208c00db334dfa9d4.tar.gz frameworks_base-8473f5a768a1eafda92c81d208c00db334dfa9d4.tar.bz2 |
ImageView updates cached drawable dimensions when drawable updates
Changes to drawable dimensions were not propagated to cached dimension
values in ImageView. Now this is done when the drawable is invalidated.
Issue #18798152 ImageView caches wrong value of mDrawableWidth and mDrawableHeight
Change-Id: I8da7d82b0543fa02d8ef3d896595bd0e5ea2a61e
Diffstat (limited to 'core')
-rw-r--r-- | core/java/android/widget/ImageView.java | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/core/java/android/widget/ImageView.java b/core/java/android/widget/ImageView.java index 6b28f89..e0b2395 100644 --- a/core/java/android/widget/ImageView.java +++ b/core/java/android/widget/ImageView.java @@ -216,7 +216,7 @@ public class ImageView extends View { protected boolean verifyDrawable(Drawable dr) { return mDrawable == dr || super.verifyDrawable(dr); } - + @Override public void jumpDrawablesToCurrentState() { super.jumpDrawablesToCurrentState(); @@ -226,6 +226,15 @@ public class ImageView extends View { @Override public void invalidateDrawable(Drawable dr) { if (dr == mDrawable) { + if (dr != null) { + // update cached drawable dimensions if they've changed + final int w = dr.getIntrinsicWidth(); + final int h = dr.getIntrinsicHeight(); + if (w != mDrawableWidth || h != mDrawableHeight) { + mDrawableWidth = w; + mDrawableHeight = h; + } + } /* we invalidate the whole view in this case because it's very * hard to know where the drawable actually is. This is made * complicated because of the offsets and transformations that |