Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit f96ce026 authored by Adam Powell's avatar Adam Powell
Browse files

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
parent 2c02933b
Loading
Loading
Loading
Loading
+18 −4
Original line number Diff line number Diff line
@@ -342,8 +342,15 @@ public class ImageView extends View {
            updateDrawable(null);
            mResource = resId;
            mUri = null;

            final int oldWidth = mDrawableWidth;
            final int oldHeight = mDrawableHeight;

            resolveUri();

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

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