am 309260ee: Merge "Don\'t notifyPageSwitchListener until page settles (issue 12069757)" into jb-ub-now-kermit
* commit '309260ee593aa3f209510ae6bf137f9b75e2498b': Don't notifyPageSwitchListener until page settles (issue 12069757)
This commit is contained in:
@@ -449,6 +449,10 @@ public abstract class PagedView extends ViewGroup implements ViewGroup.OnHierarc
|
||||
return new PageIndicator.PageMarkerResources();
|
||||
}
|
||||
|
||||
/**
|
||||
* Add a page change listener which will be called when a page is _finished_ listening.
|
||||
*
|
||||
*/
|
||||
public void setPageSwitchListener(PageSwitchListener pageSwitchListener) {
|
||||
mPageSwitchListener = pageSwitchListener;
|
||||
if (mPageSwitchListener != null) {
|
||||
@@ -523,6 +527,7 @@ public abstract class PagedView extends ViewGroup implements ViewGroup.OnHierarc
|
||||
*/
|
||||
void stopScrolling() {
|
||||
mCurrentPage = getNextPage();
|
||||
notifyPageSwitchListener();
|
||||
forceFinishScroller();
|
||||
}
|
||||
|
||||
@@ -572,11 +577,19 @@ public abstract class PagedView extends ViewGroup implements ViewGroup.OnHierarc
|
||||
return mRestorePage;
|
||||
}
|
||||
|
||||
/**
|
||||
* Should be called whenever the page changes. In the case of a scroll, we wait until the page
|
||||
* has settled.
|
||||
*/
|
||||
protected void notifyPageSwitchListener() {
|
||||
if (mPageSwitchListener != null) {
|
||||
mPageSwitchListener.onPageSwitch(getPageAt(mCurrentPage), mCurrentPage);
|
||||
mPageSwitchListener.onPageSwitch(getPageAt(getNextPage()), getNextPage());
|
||||
}
|
||||
|
||||
updatePageIndicator();
|
||||
}
|
||||
|
||||
private void updatePageIndicator() {
|
||||
// Update the page indicator (when we aren't reordering)
|
||||
if (mPageIndicator != null && !isReordering(false)) {
|
||||
mPageIndicator.setActiveMarker(getNextPage());
|
||||
@@ -2230,7 +2243,7 @@ public abstract class PagedView extends ViewGroup implements ViewGroup.OnHierarc
|
||||
|
||||
mScroller.startScroll(mUnboundedScrollX, 0, delta, 0, duration);
|
||||
|
||||
notifyPageSwitchListener();
|
||||
updatePageIndicator();
|
||||
|
||||
// Trigger a compute() to finish switching pages if necessary
|
||||
if (immediate) {
|
||||
|
||||
@@ -1200,7 +1200,7 @@ public class Workspace extends SmoothPagedView
|
||||
@Override
|
||||
protected void notifyPageSwitchListener() {
|
||||
super.notifyPageSwitchListener();
|
||||
Launcher.setScreen(mCurrentPage);
|
||||
Launcher.setScreen(getNextPage());
|
||||
|
||||
if (hasCustomContent() && getNextPage() == 0 && !mCustomContentShowing) {
|
||||
mCustomContentShowing = true;
|
||||
|
||||
Reference in New Issue
Block a user