diff options
author | Sunny Goyal <sunnygoyal@google.com> | 2019-01-09 11:20:29 -0800 |
---|---|---|
committer | Sunny Goyal <sunnygoyal@google.com> | 2019-01-09 16:43:00 -0800 |
commit | 8304c3207754c10d2a4182b00e5f16956ae1022e (patch) | |
tree | 14195c80a16b96000ca5bc8476941514124ce821 /quickstep | |
parent | 55a32272be2e2369ec25bdca3ef0e5724430b9c5 (diff) | |
download | android_packages_apps_Trebuchet-8304c3207754c10d2a4182b00e5f16956ae1022e.tar.gz android_packages_apps_Trebuchet-8304c3207754c10d2a4182b00e5f16956ae1022e.tar.bz2 android_packages_apps_Trebuchet-8304c3207754c10d2a4182b00e5f16956ae1022e.zip |
Reusing LayoutListener instead of creating a new one everytime
Bug: 122345781
Change-Id: Ica43849030afb497b0444e9ce474e7c3bdb9ee73
Diffstat (limited to 'quickstep')
3 files changed, 32 insertions, 3 deletions
diff --git a/quickstep/src/com/android/quickstep/ActivityControlHelper.java b/quickstep/src/com/android/quickstep/ActivityControlHelper.java index 20aabae40..82930839d 100644 --- a/quickstep/src/com/android/quickstep/ActivityControlHelper.java +++ b/quickstep/src/com/android/quickstep/ActivityControlHelper.java @@ -154,7 +154,7 @@ public interface ActivityControlHelper<T extends BaseDraggingActivity> { @Override public LayoutListener createLayoutListener(Launcher activity) { - return new LauncherLayoutListener(activity); + return LauncherLayoutListener.resetAndGet(activity); } @Override diff --git a/quickstep/src/com/android/quickstep/views/LauncherLayoutListener.java b/quickstep/src/com/android/quickstep/views/LauncherLayoutListener.java index bcd3aee90..e684889eb 100644 --- a/quickstep/src/com/android/quickstep/views/LauncherLayoutListener.java +++ b/quickstep/src/com/android/quickstep/views/LauncherLayoutListener.java @@ -40,17 +40,35 @@ import com.android.quickstep.WindowTransformSwipeHandler; public class LauncherLayoutListener extends AbstractFloatingView implements Insettable, LayoutListener { + public static LauncherLayoutListener resetAndGet(Launcher launcher) { + LauncherRecentsView lrv = launcher.getOverviewPanel(); + LauncherLayoutListener listener = lrv.mLauncherLayoutListener; + if (listener.isOpen()) { + listener.close(false); + } + listener.setHandler(null); + return listener; + } + private final Launcher mLauncher; private final Paint mPaint = new Paint(); private WindowTransformSwipeHandler mHandler; private RectF mCurrentRect; private float mCornerRadius; - public LauncherLayoutListener(Launcher launcher) { + private boolean mWillNotDraw; + + /** + * package private + */ + LauncherLayoutListener(Launcher launcher) { super(launcher, null); mLauncher = launcher; mPaint.setXfermode(new PorterDuffXfermode(PorterDuff.Mode.CLEAR)); setLayoutParams(new FrameLayout.LayoutParams(MATCH_PARENT, MATCH_PARENT)); + + mWillNotDraw = willNotDraw(); + super.setWillNotDraw(false); } @Override @@ -69,6 +87,12 @@ public class LauncherLayoutListener extends AbstractFloatingView } @Override + public void setWillNotDraw(boolean willNotDraw) { + // Prevent super call as that causes additional relayout. + mWillNotDraw = willNotDraw; + } + + @Override public void setHandler(WindowTransformSwipeHandler handler) { mHandler = handler; } @@ -125,6 +149,8 @@ public class LauncherLayoutListener extends AbstractFloatingView @Override protected void onDraw(Canvas canvas) { - canvas.drawRoundRect(mCurrentRect, mCornerRadius, mCornerRadius, mPaint); + if (!mWillNotDraw) { + canvas.drawRoundRect(mCurrentRect, mCornerRadius, mCornerRadius, mPaint); + } } } diff --git a/quickstep/src/com/android/quickstep/views/LauncherRecentsView.java b/quickstep/src/com/android/quickstep/views/LauncherRecentsView.java index 6396d1a09..7389d65a6 100644 --- a/quickstep/src/com/android/quickstep/views/LauncherRecentsView.java +++ b/quickstep/src/com/android/quickstep/views/LauncherRecentsView.java @@ -35,6 +35,7 @@ import android.view.View; import android.view.ViewDebug; import com.android.launcher3.AbstractFloatingView; +import com.android.launcher3.BaseActivity; import com.android.launcher3.DeviceProfile; import com.android.launcher3.Launcher; import com.android.launcher3.LauncherState; @@ -70,6 +71,7 @@ public class LauncherRecentsView extends RecentsView<Launcher> { private float mTranslationYFactor; private final TransformParams mTransformParams = new TransformParams(); + final LauncherLayoutListener mLauncherLayoutListener; public LauncherRecentsView(Context context) { this(context, null); @@ -82,6 +84,7 @@ public class LauncherRecentsView extends RecentsView<Launcher> { public LauncherRecentsView(Context context, AttributeSet attrs, int defStyleAttr) { super(context, attrs, defStyleAttr); setContentAlpha(0); + mLauncherLayoutListener = new LauncherLayoutListener(BaseActivity.fromContext(context)); } @Override |