From 11c7bc678b5dc37749c84e7aa00d6d00f4fc1b02 Mon Sep 17 00:00:00 2001 From: Rajeev Kumar Date: Thu, 15 Jun 2017 18:18:17 -0700 Subject: [PATCH] 1. Avoid object allocations during draw/layout operations (preallocate and reuse instead). 2. Prevent NPE in dereferencing mDragInfo. 3. Get rid of unused variable assignments. Change-Id: Ie74169795462d4dbdb61f84495ed1ec6ab2b0709 --- src/com/android/launcher3/Workspace.java | 34 +++--------------------- 1 file changed, 3 insertions(+), 31 deletions(-) diff --git a/src/com/android/launcher3/Workspace.java b/src/com/android/launcher3/Workspace.java index 3fe78757b0..b955fe1b5e 100644 --- a/src/com/android/launcher3/Workspace.java +++ b/src/com/android/launcher3/Workspace.java @@ -305,8 +305,6 @@ public class Workspace extends PagedView private boolean mForceDrawAdjacentPages = false; // Total over scrollX in the overlay direction. private float mOverlayTranslation; - private int mFirstPageScrollX; - private boolean mIgnoreQsbScroll; // Handles workspace state transitions private final WorkspaceStateTransitionAnimation mStateTransitionAnimation; @@ -1739,32 +1737,6 @@ public class Workspace extends PagedView mWallpaperOffset.jumpToFinal(); } super.onLayout(changed, left, top, right, bottom); - mFirstPageScrollX = getScrollForPage(0); - - final LayoutTransition transition = getLayoutTransition(); - // If the transition is running defer updating max scroll, as some empty pages could - // still be present, and a max scroll change could cause sudden jumps in scroll. - if (transition != null && transition.isRunning()) { - transition.addTransitionListener(new LayoutTransition.TransitionListener() { - - @Override - public void startTransition(LayoutTransition transition, ViewGroup container, - View view, int transitionType) { - mIgnoreQsbScroll = true; - } - - @Override - public void endTransition(LayoutTransition transition, ViewGroup container, - View view, int transitionType) { - // Wait until all transitions are complete. - if (!transition.isRunning()) { - mIgnoreQsbScroll = false; - transition.removeTransitionListener(this); - mFirstPageScrollX = getScrollForPage(0); - } - } - }); - } updatePageAlphaValues(); } @@ -3548,7 +3520,7 @@ public class Workspace extends PagedView } } if ((d.cancelled || (beingCalledAfterUninstall && !mUninstallSuccessful)) - && mDragInfo.cell != null) { + && mDragInfo != null && mDragInfo.cell != null) { mDragInfo.cell.setVisibility(VISIBLE); } mDragInfo = null; @@ -4121,8 +4093,8 @@ public class Workspace extends PagedView private boolean mRefreshPending; - public DeferredWidgetRefresh(ArrayList infos, - LauncherAppWidgetHost host) { + DeferredWidgetRefresh(ArrayList infos, + LauncherAppWidgetHost host) { mInfos = infos; mHost = host; mHandler = new Handler();