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

Commit 48c22c84 authored by Michael Jurka's avatar Michael Jurka Committed by Android (Google) Code Review
Browse files

Merge "Adding debugging code for bug where recycled views still had parent" into jb-dev

parents 45973d6d b2a5d9e5
Loading
Loading
Loading
Loading
+15 −0
Original line number Diff line number Diff line
@@ -83,6 +83,12 @@ public class RecentsHorizontalScrollView extends HorizontalScrollView
        setLayoutTransition(null);

        mLinearLayout.removeAllViews();
        for (int i = 0; i < mRecycledViews.size(); i++) {
            View child = mRecycledViews.get(i);
            if (child.getParent() != null) {
                throw new RuntimeException("Recycled child has a parent");
            }
        }
        for (int i = 0; i < mAdapter.getCount(); i++) {
            View old = null;
            if (mRecycledViews.size() != 0) {
@@ -183,6 +189,9 @@ public class RecentsHorizontalScrollView extends HorizontalScrollView
    public void onChildDismissed(View v) {
        mRecycledViews.add(v);
        mLinearLayout.removeView(v);
        if (v.getParent() != null) {
            throw new RuntimeException("Recycled child has parent");
        }
        mCallback.handleSwipe(v);
        // Restore the alpha/translation parameters to what they were before swiping
        // (for when these items are recycled)
@@ -354,9 +363,15 @@ public class RecentsHorizontalScrollView extends HorizontalScrollView
        mNumItemsInOneScreenful =
                (int) FloatMath.ceil(dm.widthPixels / (float) child.getMeasuredWidth());
        mRecycledViews.add(child);
        if (child.getParent() != null) {
            throw new RuntimeException("First recycled child has parent");
        }

        for (int i = 0; i < mNumItemsInOneScreenful - 1; i++) {
            mRecycledViews.add(mAdapter.createView(mLinearLayout));
            if (mRecycledViews.get(mRecycledViews.size() - 1).getParent() != null) {
                throw new RuntimeException("Recycled child has parent");
            }
        }
    }

+15 −0
Original line number Diff line number Diff line
@@ -84,6 +84,12 @@ public class RecentsVerticalScrollView extends ScrollView
        setLayoutTransition(null);

        mLinearLayout.removeAllViews();
        for (int i = 0; i < mRecycledViews.size(); i++) {
            View child = mRecycledViews.get(i);
            if (child.getParent() != null) {
                throw new RuntimeException("Recycled child has parent");
            }
        }
        // Once we can clear the data associated with individual item views,
        // we can get rid of the removeAllViews() and the code below will
        // recycle them.
@@ -190,6 +196,9 @@ public class RecentsVerticalScrollView extends ScrollView
    public void onChildDismissed(View v) {
        mRecycledViews.add(v);
        mLinearLayout.removeView(v);
        if (v.getParent() != null) {
            throw new RuntimeException("Recycled child has parent");
        }
        mCallback.handleSwipe(v);
        // Restore the alpha/translation parameters to what they were before swiping
        // (for when these items are recycled)
@@ -363,9 +372,15 @@ public class RecentsVerticalScrollView extends ScrollView
        mNumItemsInOneScreenful =
                (int) FloatMath.ceil(dm.heightPixels / (float) child.getMeasuredHeight());
        mRecycledViews.add(child);
        if (child.getParent() != null) {
            throw new RuntimeException("First recycled child has parent");
        }

        for (int i = 0; i < mNumItemsInOneScreenful - 1; i++) {
            mRecycledViews.add(mAdapter.createView(mLinearLayout));
            if (mRecycledViews.get(mRecycledViews.size() - 1).getParent() != null) {
                throw new RuntimeException("Recycled child has parent");
            }
        }
    }