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

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

Merge "Fixing AdapterViewAnimator crash when associated adapter is empty"

parents 128cecab 3042944c
Loading
Loading
Loading
Loading
+7 −2
Original line number Diff line number Diff line
@@ -324,7 +324,11 @@ public abstract class AdapterViewAnimator extends AdapterView<Adapter>
    }

    private int modulo(int pos, int size) {
        if (size > 0) {
            return (size + (pos % size)) % size;
        } else {
            return 0;
        }
    }

    /**
@@ -383,6 +387,8 @@ public abstract class AdapterViewAnimator extends AdapterView<Adapter>

    void showOnly(int childIndex, boolean animate, boolean onLayout) {
        if (mAdapter == null) return;
        final int adapterCount = mAdapter.getCount();
        if (adapterCount == 0) return;

        for (int i = 0; i < mPreviousViews.size(); i++) {
            View viewToRemove = mViewsMap.get(mPreviousViews.get(i)).view;
@@ -399,7 +405,6 @@ public abstract class AdapterViewAnimator extends AdapterView<Adapter>
            removeViewInLayout(viewToRemove);
        }
        mPreviousViews.clear();
        int adapterCount = mAdapter.getCount();
        int newWindowStartUnbounded = childIndex - mActiveOffset;
        int newWindowEndUnbounded = newWindowStartUnbounded + mNumActiveViews - 1;
        int newWindowStart = Math.max(0, newWindowStartUnbounded);
+3 −1
Original line number Diff line number Diff line
@@ -749,8 +749,10 @@ public class StackView extends AdapterViewAnimator {
        if (mAdapter != null && mWhichChild == -1) {
            mWhichChild = mAdapter.getCount() - 1;
        }
        if (mWhichChild >= 0) {
            setDisplayedChild(mWhichChild);
        }
    }

    LayoutParams createOrReuseLayoutParams(View v) {
        final ViewGroup.LayoutParams currentLp = v.getLayoutParams();