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

Commit cb263b93 authored by TreeHugger Robot's avatar TreeHugger Robot Committed by Automerger Merge Worker
Browse files

Merge "Add try/catch to prevent NPE in PagedTileLayout" into rvc-dev am: 1daf6ea6 am: 435f387c

Change-Id: I71151337a07a05fe4aab857469d2add9bb46744a
parents f6fd74b6 435f387c
Loading
Loading
Loading
Loading
+21 −3
Original line number Diff line number Diff line
@@ -151,6 +151,27 @@ public class PagedTileLayout extends ViewPager implements QSTileLayout {
        }
    }

    @Override
    public void fakeDragBy(float xOffset) {
        try {
            super.fakeDragBy(xOffset);
            // Keep on drawing until the animation has finished.
            postInvalidateOnAnimation();
        } catch (NullPointerException e) {
            Log.e(TAG, "FakeDragBy called before begin", e);
            // If we were trying to fake drag, it means we just added a new tile to the last
            // page, so animate there.
            final int lastPageNumber = mPages.size() - 1;
            post(() -> {
                setCurrentItem(lastPageNumber, true);
                if (mBounceAnimatorSet != null) {
                    mBounceAnimatorSet.start();
                }
                setOffscreenPageLimit(1);
            });
        }
    }

    @Override
    public void computeScroll() {
        if (!mScroller.isFinished() && mScroller.computeScrollOffset()) {
@@ -158,9 +179,6 @@ public class PagedTileLayout extends ViewPager implements QSTileLayout {
                beginFakeDrag();
            }
            fakeDragBy(getScrollX() - mScroller.getCurrX());
            // Keep on drawing until the animation has finished.
            postInvalidateOnAnimation();
            return;
        } else if (isFakeDragging()) {
            endFakeDrag();
            mBounceAnimatorSet.start();