diff options
author | Winson Chung <winsonc@google.com> | 2013-07-12 21:50:55 +0000 |
---|---|---|
committer | Android (Google) Code Review <android-gerrit@google.com> | 2013-07-12 21:50:55 +0000 |
commit | 1ebead458549fadf353787105f15c02290cccee6 (patch) | |
tree | 72dd9b626a7de6ec3914a189a2efdf0ddef908b2 /src | |
parent | 7bac576622fc56c86c8937fd425e3a510c69f375 (diff) | |
parent | accfd5648ccb3a3248b422a8c1971b7de8d3207b (diff) | |
download | android_packages_apps_Trebuchet-1ebead458549fadf353787105f15c02290cccee6.tar.gz android_packages_apps_Trebuchet-1ebead458549fadf353787105f15c02290cccee6.tar.bz2 android_packages_apps_Trebuchet-1ebead458549fadf353787105f15c02290cccee6.zip |
Merge "Fix weird page jumps after dropping items" into jb-ub-gel-agar
Diffstat (limited to 'src')
-rw-r--r-- | src/com/android/launcher3/PagedView.java | 6 | ||||
-rw-r--r-- | src/com/android/launcher3/Workspace.java | 19 |
2 files changed, 20 insertions, 5 deletions
diff --git a/src/com/android/launcher3/PagedView.java b/src/com/android/launcher3/PagedView.java index cc9a07582..275195b71 100644 --- a/src/com/android/launcher3/PagedView.java +++ b/src/com/android/launcher3/PagedView.java @@ -652,7 +652,6 @@ public abstract class PagedView extends ViewGroup implements ViewGroup.OnHierarc // We measure the dimensions of the PagedView to be larger than the pages so that when we // zoom out (and scale down), the view is still contained in the parent - View parent = (View) getParent(); int widthMode = MeasureSpec.getMode(widthMeasureSpec); int widthSize = MeasureSpec.getSize(widthMeasureSpec); int heightMode = MeasureSpec.getMode(heightMeasureSpec); @@ -727,8 +726,9 @@ public abstract class PagedView extends ViewGroup implements ViewGroup.OnHierarc // ensure that the cache is filled with good values. invalidateCachedOffsets(); - if (mChildCountOnLastMeasure != getChildCount() && !mDeferringForDelete) { - setCurrentPage(mCurrentPage); + if (mScroller.isFinished() && mChildCountOnLastMeasure != getChildCount() && + !mDeferringForDelete) { + setCurrentPage(getNextPage()); } mChildCountOnLastMeasure = getChildCount(); diff --git a/src/com/android/launcher3/Workspace.java b/src/com/android/launcher3/Workspace.java index cd31722d7..2ab4bbd93 100644 --- a/src/com/android/launcher3/Workspace.java +++ b/src/com/android/launcher3/Workspace.java @@ -171,6 +171,8 @@ public class Workspace extends SmoothPagedView boolean mIsDragOccuring = false; boolean mChildrenLayersEnabled = true; + private boolean mStripScreensOnPageStopMoving = false; + /** Is the user is dragging an item near the edge of a page? */ private boolean mInScrollArea = false; @@ -582,6 +584,12 @@ public class Workspace extends SmoothPagedView } public void stripEmptyScreens() { + if (isPageMoving()) { + mStripScreensOnPageStopMoving = true; + return; + } + + int currentPage = getNextPage(); ArrayList<Long> removeScreens = new ArrayList<Long>(); for (Long id: mWorkspaceScreens.keySet()) { CellLayout cl = mWorkspaceScreens.get(id); @@ -595,17 +603,20 @@ public class Workspace extends SmoothPagedView CellLayout cl = mWorkspaceScreens.get(id); mWorkspaceScreens.remove(id); mScreenOrder.remove(id); - if (indexOfChild(cl) < mCurrentPage) { + if (indexOfChild(cl) < currentPage) { pageShift++; } removeView(cl); } - setCurrentPage(mCurrentPage - pageShift); if (!removeScreens.isEmpty()) { // Update the model if we have changed any screens mLauncher.getModel().updateWorkspaceScreenOrder(mLauncher, mScreenOrder); } + + if (pageShift >= 0) { + setCurrentPage(currentPage - pageShift); + } } // See implementation for parameter definition. @@ -901,6 +912,10 @@ public class Workspace extends SmoothPagedView mDelayedSnapToPageRunnable.run(); mDelayedSnapToPageRunnable = null; } + if (mStripScreensOnPageStopMoving) { + stripEmptyScreens(); + mStripScreensOnPageStopMoving = false; + } } @Override |