mirror of
https://github.com/LawnchairLauncher/lawnchair.git
synced 2026-02-19 18:58:19 +00:00
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:
@@ -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