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) {
*/
void stopScrolling() {
mCurrentPage = getNextPage();
+ notifyPageSwitchListener();
forceFinishScroller();
}
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());
mScroller.startScroll(mUnboundedScrollX, 0, delta, 0, duration);
- notifyPageSwitchListener();
+ updatePageIndicator();
// Trigger a compute() to finish switching pages if necessary
if (immediate) {
@Override
protected void notifyPageSwitchListener() {
super.notifyPageSwitchListener();
- Launcher.setScreen(mCurrentPage);
+ Launcher.setScreen(getNextPage());
if (hasCustomContent() && getNextPage() == 0 && !mCustomContentShowing) {
mCustomContentShowing = true;