Saving AllApps page when rotating screen, fixing customization rotate flash.
Change-Id: Idc4b919fa34413578fc07be263aadffb062f6115
diff --git a/src/com/android/launcher2/PagedView.java b/src/com/android/launcher2/PagedView.java
index 8483f95..68833f9 100644
--- a/src/com/android/launcher2/PagedView.java
+++ b/src/com/android/launcher2/PagedView.java
@@ -73,6 +73,7 @@
protected int mCurrentPage;
protected int mNextPage = INVALID_PAGE;
+ protected int mRestorePage = -1;
protected int mMaxScrollX;
protected Scroller mScroller;
private VelocityTracker mVelocityTracker;
@@ -279,9 +280,8 @@
mCurrentPage = Math.max(0, Math.min(currentPage, getPageCount() - 1));
updateCurrentPageScroll();
-
- invalidate();
notifyPageSwitchListener();
+ invalidate();
}
protected void notifyPageSwitchListener() {
@@ -1219,22 +1219,6 @@
invalidate();
}
- @Override
- protected Parcelable onSaveInstanceState() {
- final SavedState state = new SavedState(super.onSaveInstanceState());
- state.currentPage = mCurrentPage;
- return state;
- }
-
- @Override
- protected void onRestoreInstanceState(Parcelable state) {
- SavedState savedState = (SavedState) state;
- super.onRestoreInstanceState(savedState.getSuperState());
- if (savedState.currentPage != -1) {
- mCurrentPage = savedState.currentPage;
- }
- }
-
public void scrollLeft() {
if (mScroller.isFinished()) {
if (mCurrentPage > 0) snapToPage(mCurrentPage - 1);
@@ -1417,6 +1401,10 @@
}
}
+ public void setRestorePage(int restorePage) {
+ mRestorePage = restorePage;
+ }
+
/**
* This method is called ONLY to synchronize the number of pages that the paged view has.
* To actually fill the pages with information, implement syncPageItems() below. It is
@@ -1443,6 +1431,12 @@
mDirtyPageContent.add(true);
}
+ // Use the restore page if necessary
+ if (mRestorePage > -1) {
+ mCurrentPage = mRestorePage;
+ mRestorePage = -1;
+ }
+
// Load any pages that are necessary for the current window of views
loadAssociatedPages(mCurrentPage);
mDirtyPageAlpha = true;