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
This commit is contained in:
Adam Powell
2012-08-09 15:08:33 -07:00
parent 2c02933b13
commit f96ce02613

View File

@@ -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);