summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorAdam Cohen <adamcohen@google.com>2013-06-11 15:45:31 -0700
committerAdam Cohen <adamcohen@google.com>2013-06-11 15:48:38 -0700
commite61a9a2cd4af5d1f345c6396d3013fea0aa1c767 (patch)
tree64405b81efd809166cce99cc9f931a7b0b8829a9 /src
parentefe354b8779211b34e274a6109406d4cd01cfcef (diff)
downloadandroid_packages_apps_Trebuchet-e61a9a2cd4af5d1f345c6396d3013fea0aa1c767.tar.gz
android_packages_apps_Trebuchet-e61a9a2cd4af5d1f345c6396d3013fea0aa1c767.tar.bz2
android_packages_apps_Trebuchet-e61a9a2cd4af5d1f345c6396d3013fea0aa1c767.zip
Fix issue with setting the current page immediately after a page is added
Change-Id: Ia9ddc42896b47b10bb98ed6bd6cece1b033207c1
Diffstat (limited to 'src')
-rw-r--r--src/com/android/launcher3/Launcher.java11
-rw-r--r--src/com/android/launcher3/PagedView.java9
2 files changed, 11 insertions, 9 deletions
diff --git a/src/com/android/launcher3/Launcher.java b/src/com/android/launcher3/Launcher.java
index 8e8e6ed72..32aed80ac 100644
--- a/src/com/android/launcher3/Launcher.java
+++ b/src/com/android/launcher3/Launcher.java
@@ -844,14 +844,9 @@ public class Launcher extends Activity
mWorkspace.addView(customScreen, 0);
- // We don't want to change the current or the default screen
- mWorkspace.post(new Runnable() {
- @Override
- public void run() {
- mWorkspace.incrementDefaultScreen();
- mWorkspace.setCurrentPage(mWorkspace.getCurrentPage() + 1);
- }
- });
+ // Ensure that the current page and default page are maintained.
+ mWorkspace.incrementDefaultScreen();
+ mWorkspace.setCurrentPage(mWorkspace.getCurrentPage() + 1);
}
@Override
diff --git a/src/com/android/launcher3/PagedView.java b/src/com/android/launcher3/PagedView.java
index 8716a33be..abf8bbd14 100644
--- a/src/com/android/launcher3/PagedView.java
+++ b/src/com/android/launcher3/PagedView.java
@@ -89,6 +89,8 @@ public abstract class PagedView extends ViewGroup implements ViewGroup.OnHierarc
protected boolean mFirstLayout = true;
protected int mCurrentPage;
+ protected int mChildCountOnLastMeasure;
+
protected int mNextPage = INVALID_PAGE;
protected int mMaxScrollX;
protected Scroller mScroller;
@@ -347,7 +349,7 @@ public abstract class PagedView extends ViewGroup implements ViewGroup.OnHierarc
return;
}
-
+ mForceScreenScrolled = true;
mCurrentPage = Math.max(0, Math.min(currentPage, getPageCount() - 1));
updateCurrentPageScroll();
updateScrollingIndicator();
@@ -564,6 +566,11 @@ public abstract class PagedView extends ViewGroup implements ViewGroup.OnHierarc
// ensure that the cache is filled with good values.
invalidateCachedOffsets();
+ if (mChildCountOnLastMeasure != getChildCount()) {
+ setCurrentPage(mCurrentPage);
+ }
+ mChildCountOnLastMeasure = getChildCount();
+
if (childCount > 0) {
if (DEBUG) Log.d(TAG, "getRelativeChildOffset(): " + getMeasuredWidth() + ", "
+ getChildWidth(0));