diff options
author | Adam Powell <adamp@google.com> | 2012-08-09 15:08:33 -0700 |
---|---|---|
committer | Adam Powell <adamp@google.com> | 2012-08-09 15:09:53 -0700 |
commit | f96ce0261326d1637e0111eaddde725ed94f2163 (patch) | |
tree | e70b0264e711304783ca347a95d2debf4e94ac4d /core/java/android | |
parent | 2c02933b13b426637808d3d4fd57aea1ff11011a (diff) | |
download | frameworks_base-f96ce0261326d1637e0111eaddde725ed94f2163.zip frameworks_base-f96ce0261326d1637e0111eaddde725ed94f2163.tar.gz frameworks_base-f96ce0261326d1637e0111eaddde725ed94f2163.tar.bz2 |
Some simple skip-layout optimizations for ImageView
Mirror the optimization from setImageDrawable into setImageResource
and setImageURI where we won't requestLayout() if the drawable's size
didn't change.
Bug 6359116
Change-Id: Iaae2100f3bddb2737628e31483b471c9e22d945f
Diffstat (limited to 'core/java/android')
-rw-r--r-- | core/java/android/widget/ImageView.java | 22 |
1 files changed, 18 insertions, 4 deletions
diff --git a/core/java/android/widget/ImageView.java b/core/java/android/widget/ImageView.java index f259597..87396fb 100644 --- a/core/java/android/widget/ImageView.java +++ b/core/java/android/widget/ImageView.java @@ -342,8 +342,15 @@ public class ImageView extends View { updateDrawable(null); mResource = resId; mUri = null; + + final int oldWidth = mDrawableWidth; + final int oldHeight = mDrawableHeight; + resolveUri(); - requestLayout(); + + if (oldWidth != mDrawableWidth || oldHeight != mDrawableHeight) { + requestLayout(); + } invalidate(); } } @@ -367,8 +374,15 @@ public class ImageView extends View { updateDrawable(null); mResource = 0; mUri = uri; + + final int oldWidth = mDrawableWidth; + final int oldHeight = mDrawableHeight; + resolveUri(); - requestLayout(); + + if (oldWidth != mDrawableWidth || oldHeight != mDrawableHeight) { + requestLayout(); + } invalidate(); } } @@ -383,8 +397,8 @@ public class ImageView extends View { mResource = 0; mUri = null; - int oldWidth = mDrawableWidth; - int oldHeight = mDrawableHeight; + final int oldWidth = mDrawableWidth; + final int oldHeight = mDrawableHeight; updateDrawable(drawable); |