Skip to content

Commit b2a5d9e

Browse files
committed
Adding debugging code for bug where recycled views still had parent
Bug: 6499508 Change-Id: Iaf95ee6a0836c5f1e863d6a5b969e032d36a2b27
1 parent c3a5cf9 commit b2a5d9e

File tree

2 files changed

+30
-0
lines changed

2 files changed

+30
-0
lines changed

packages/SystemUI/src/com/android/systemui/recent/RecentsHorizontalScrollView.java

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,12 @@ private void update() {
8383
setLayoutTransition(null);
8484

8585
mLinearLayout.removeAllViews();
86+
for (int i = 0; i < mRecycledViews.size(); i++) {
87+
View child = mRecycledViews.get(i);
88+
if (child.getParent() != null) {
89+
throw new RuntimeException("Recycled child has a parent");
90+
}
91+
}
8692
for (int i = 0; i < mAdapter.getCount(); i++) {
8793
View old = null;
8894
if (mRecycledViews.size() != 0) {
@@ -183,6 +189,9 @@ public void dismissChild(View v) {
183189
public void onChildDismissed(View v) {
184190
mRecycledViews.add(v);
185191
mLinearLayout.removeView(v);
192+
if (v.getParent() != null) {
193+
throw new RuntimeException("Recycled child has parent");
194+
}
186195
mCallback.handleSwipe(v);
187196
// Restore the alpha/translation parameters to what they were before swiping
188197
// (for when these items are recycled)
@@ -354,9 +363,15 @@ public void onInvalidated() {
354363
mNumItemsInOneScreenful =
355364
(int) FloatMath.ceil(dm.widthPixels / (float) child.getMeasuredWidth());
356365
mRecycledViews.add(child);
366+
if (child.getParent() != null) {
367+
throw new RuntimeException("First recycled child has parent");
368+
}
357369

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

packages/SystemUI/src/com/android/systemui/recent/RecentsVerticalScrollView.java

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,12 @@ private void update() {
8484
setLayoutTransition(null);
8585

8686
mLinearLayout.removeAllViews();
87+
for (int i = 0; i < mRecycledViews.size(); i++) {
88+
View child = mRecycledViews.get(i);
89+
if (child.getParent() != null) {
90+
throw new RuntimeException("Recycled child has parent");
91+
}
92+
}
8793
// Once we can clear the data associated with individual item views,
8894
// we can get rid of the removeAllViews() and the code below will
8995
// recycle them.
@@ -190,6 +196,9 @@ public void dismissChild(View v) {
190196
public void onChildDismissed(View v) {
191197
mRecycledViews.add(v);
192198
mLinearLayout.removeView(v);
199+
if (v.getParent() != null) {
200+
throw new RuntimeException("Recycled child has parent");
201+
}
193202
mCallback.handleSwipe(v);
194203
// Restore the alpha/translation parameters to what they were before swiping
195204
// (for when these items are recycled)
@@ -363,9 +372,15 @@ public void onInvalidated() {
363372
mNumItemsInOneScreenful =
364373
(int) FloatMath.ceil(dm.heightPixels / (float) child.getMeasuredHeight());
365374
mRecycledViews.add(child);
375+
if (child.getParent() != null) {
376+
throw new RuntimeException("First recycled child has parent");
377+
}
366378

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

0 commit comments

Comments
 (0)