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:
@@ -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);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user