From 87bdf0d630761947f1922501b716c2a9ba0aae20 Mon Sep 17 00:00:00 2001 From: Fabian Kozynski Date: Mon, 1 Apr 2019 09:52:57 -0400 Subject: [PATCH] Remove allocation in onLayout The clipping rect was allocated in onLayout. After this change, the rect is allocated once and the bounds are reset. Test: manual Change-Id: I92dcca915fc244a3d418e98a456a0719407cdf57 --- .../src/com/android/systemui/qs/PagedTileLayout.java | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/packages/SystemUI/src/com/android/systemui/qs/PagedTileLayout.java b/packages/SystemUI/src/com/android/systemui/qs/PagedTileLayout.java index 76dfddb78c80f..bb159a9ba2e8f 100644 --- a/packages/SystemUI/src/com/android/systemui/qs/PagedTileLayout.java +++ b/packages/SystemUI/src/com/android/systemui/qs/PagedTileLayout.java @@ -62,6 +62,7 @@ public class PagedTileLayout extends ViewPager implements QSTileLayout { private int mLayoutOrientation; private int mLayoutDirection; private int mHorizontalClipBound; + private final Rect mClippingRect; public PagedTileLayout(Context context, AttributeSet attrs) { super(context, attrs); @@ -71,6 +72,7 @@ public class PagedTileLayout extends ViewPager implements QSTileLayout { setCurrentItem(0, false); mLayoutOrientation = getResources().getConfiguration().orientation; mLayoutDirection = getLayoutDirection(); + mClippingRect = new Rect(); } public void saveInstanceState(Bundle outState) { @@ -280,8 +282,8 @@ public class PagedTileLayout extends ViewPager implements QSTileLayout { @Override protected void onLayout(boolean changed, int l, int t, int r, int b) { super.onLayout(changed, l, t, r, b); - Rect clipBounds = new Rect(mHorizontalClipBound, 0, (r-l) - mHorizontalClipBound, b - t); - setClipBounds(clipBounds); + mClippingRect.set(mHorizontalClipBound, 0, (r - l) - mHorizontalClipBound, b - t); + setClipBounds(mClippingRect); } @Override