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

Commit 545f2507 authored by Fabian Kozynski's avatar Fabian Kozynski
Browse files

Add try/catch to prevent NPE in PagedTileLayout

This catches the NPE. Still haven't found what actually causes it.

Test: monkey tested in the bug
Fixes: 149979063

Change-Id: Idf73909e6f3c456616433d5278e2061431e0e840
parent 5ef61d2f
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();