Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 309260ee authored by Adam Cohen's avatar Adam Cohen Committed by Android (Google) Code Review
Browse files

Merge "Don't notifyPageSwitchListener until page settles (issue 12069757)" into jb-ub-now-kermit

parents 31ff527a 674531f2
Loading
Loading
Loading
Loading
+15 −2
Original line number Diff line number Diff line
@@ -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) {
+1 −1
Original line number Diff line number Diff line
@@ -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;