Skip to content

Commit 50ac6cb

Browse files
author
George Mount
committed
Clear preordered list after use.
Bug 17671834 Bug 17697944 Change-Id: I0ba46f32661869db0c925b00342211ea543e2f88
1 parent 39838b9 commit 50ac6cb

1 file changed

Lines changed: 13 additions & 5 deletions

File tree

core/java/android/view/GhostView.java

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -324,19 +324,27 @@ private static boolean isOnTop(View view, View comparedWith) {
324324
final ArrayList<View> preorderedList = parent.buildOrderedChildList();
325325
final boolean customOrder = preorderedList == null
326326
&& parent.isChildrenDrawingOrderEnabled();
327+
328+
// This default value shouldn't be used because both view and comparedWith
329+
// should be in the list. If there is an error, then just return an arbitrary
330+
// view is on top.
331+
boolean isOnTop = true;
327332
for (int i = 0; i < childrenCount; i++) {
328333
int childIndex = customOrder ? parent.getChildDrawingOrder(childrenCount, i) : i;
329334
final View child = (preorderedList == null)
330335
? parent.getChildAt(childIndex) : preorderedList.get(childIndex);
331336
if (child == view) {
332-
return false;
337+
isOnTop = false;
338+
break;
333339
} else if (child == comparedWith) {
334-
return true;
340+
isOnTop = true;
341+
break;
335342
}
336343
}
337344

338-
// Shouldn't get here. Neither of the children is in the parent.
339-
// Just return an arbitrary one.
340-
return true;
345+
if (preorderedList != null) {
346+
preorderedList.clear();
347+
}
348+
return isOnTop;
341349
}
342350
}

0 commit comments

Comments
 (0)