diff --git a/core/java/android/view/ViewGroup.java b/core/java/android/view/ViewGroup.java index fab81a424f761..52d6cbec4abb3 100644 --- a/core/java/android/view/ViewGroup.java +++ b/core/java/android/view/ViewGroup.java @@ -43,6 +43,7 @@ import android.util.AttributeSet; import android.util.Log; import android.util.Pools.SynchronizedPool; import android.util.SparseArray; +import android.util.SparseBooleanArray; import android.view.accessibility.AccessibilityEvent; import android.view.accessibility.AccessibilityNodeInfo; import android.view.animation.Animation; @@ -2902,13 +2903,58 @@ public abstract class ViewGroup extends View implements ViewParent, ViewManager final int childrenCount = getChildCount(); if (childrenCount > 0) { structure.setChildCount(childrenCount); - final ArrayList preorderedList = buildOrderedChildList(); - final boolean customOrder = preorderedList == null + ArrayList preorderedList = buildOrderedChildList(); + boolean customOrder = preorderedList == null && isChildrenDrawingOrderEnabled(); final View[] children = mChildren; for (int i=0; i 0) { + // If we failed at the first index, there really isn't + // anything to do -- we will just proceed with the simple + // sequence order. + // Otherwise, we failed in the middle, so need to come up + // with an order for the remaining indices and use that. + // Failed at the first one, easy peasy. + int[] permutation = new int[childrenCount]; + SparseBooleanArray usedIndices = new SparseBooleanArray(); + // Go back and collected the indices we have done so far. + for (int j=0; j(childrenCount); + for (int j=0; j