Fixing issue where the page was reset to 0 on rotation.
- We needed to defer setting the restore page until the first onLayout Change-Id: I6b7b4c0a6401ab6ab2caaea0dac0a7261ff831e8
This commit is contained in:
1 parent
bffe745b1e
commit
8c87cd83e0
2 files changed
+16
-2
No files matched your search
@@ -990,7 +990,7 @@ public class Launcher extends Activity
|
||||
|
||||
int currentScreen = savedState.getInt(RUNTIME_STATE_CURRENT_SCREEN, -1);
|
||||
if (currentScreen > -1) {
|
||||
mWorkspace.setCurrentPage(currentScreen);
|
||||
mWorkspace.setRestorePage(currentScreen);
|
||||
}
|
||||
|
||||
final long pendingAddContainer = savedState.getLong(RUNTIME_STATE_PENDING_ADD_CONTAINER, -1);
|
||||
|
||||
@@ -104,6 +104,7 @@ public abstract class PagedView extends ViewGroup implements ViewGroup.OnHierarc
|
||||
protected boolean mFirstLayout = true;
|
||||
|
||||
protected int mCurrentPage;
|
||||
protected int mRestorePage = -1;
|
||||
protected int mChildCountOnLastLayout;
|
||||
|
||||
protected int mNextPage = INVALID_PAGE;
|
||||
@@ -506,6 +507,14 @@ public abstract class PagedView extends ViewGroup implements ViewGroup.OnHierarc
|
||||
invalidate();
|
||||
}
|
||||
|
||||
/**
|
||||
* The restore page will be set in place of the current page at the next (likely first)
|
||||
* layout.
|
||||
*/
|
||||
void setRestorePage(int restorePage) {
|
||||
mRestorePage = restorePage;
|
||||
}
|
||||
|
||||
protected void notifyPageSwitchListener() {
|
||||
if (mPageSwitchListener != null) {
|
||||
mPageSwitchListener.onPageSwitch(getPageAt(mCurrentPage), mCurrentPage);
|
||||
@@ -870,7 +879,12 @@ public abstract class PagedView extends ViewGroup implements ViewGroup.OnHierarc
|
||||
|
||||
if (mScroller.isFinished() && mChildCountOnLastLayout != getChildCount() &&
|
||||
!mDeferringForDelete) {
|
||||
setCurrentPage(getNextPage());
|
||||
if (mRestorePage > -1) {
|
||||
setCurrentPage(mRestorePage);
|
||||
mRestorePage = -1;
|
||||
} else {
|
||||
setCurrentPage(getNextPage());
|
||||
}
|
||||
}
|
||||
mChildCountOnLastLayout = getChildCount();
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user