am 1dd818db: am eed29a71: am 53d6cddb: Merge "Fix issue #22846750: Starting Screenie Now On Tap crashes USA Today" into mnc-dev
* commit '1dd818dbb2b008ccb7e7c118caa194802b1137af': Fix issue #22846750: Starting Screenie Now On Tap crashes USA Today
This commit is contained in:
@@ -43,6 +43,7 @@ import android.util.AttributeSet;
|
|||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
import android.util.Pools.SynchronizedPool;
|
import android.util.Pools.SynchronizedPool;
|
||||||
import android.util.SparseArray;
|
import android.util.SparseArray;
|
||||||
|
import android.util.SparseBooleanArray;
|
||||||
import android.view.accessibility.AccessibilityEvent;
|
import android.view.accessibility.AccessibilityEvent;
|
||||||
import android.view.accessibility.AccessibilityNodeInfo;
|
import android.view.accessibility.AccessibilityNodeInfo;
|
||||||
import android.view.animation.Animation;
|
import android.view.animation.Animation;
|
||||||
@@ -2902,13 +2903,58 @@ public abstract class ViewGroup extends View implements ViewParent, ViewManager
|
|||||||
final int childrenCount = getChildCount();
|
final int childrenCount = getChildCount();
|
||||||
if (childrenCount > 0) {
|
if (childrenCount > 0) {
|
||||||
structure.setChildCount(childrenCount);
|
structure.setChildCount(childrenCount);
|
||||||
final ArrayList<View> preorderedList = buildOrderedChildList();
|
ArrayList<View> preorderedList = buildOrderedChildList();
|
||||||
final boolean customOrder = preorderedList == null
|
boolean customOrder = preorderedList == null
|
||||||
&& isChildrenDrawingOrderEnabled();
|
&& isChildrenDrawingOrderEnabled();
|
||||||
final View[] children = mChildren;
|
final View[] children = mChildren;
|
||||||
for (int i=0; i<childrenCount; i++) {
|
for (int i=0; i<childrenCount; i++) {
|
||||||
final int childIndex = customOrder
|
int childIndex;
|
||||||
? getChildDrawingOrder(childrenCount, i) : i;
|
try {
|
||||||
|
childIndex = customOrder ? getChildDrawingOrder(childrenCount, i) : i;
|
||||||
|
} catch (IndexOutOfBoundsException e) {
|
||||||
|
childIndex = i;
|
||||||
|
if (mContext.getApplicationInfo().targetSdkVersion
|
||||||
|
< Build.VERSION_CODES.M) {
|
||||||
|
Log.w(TAG, "Bad getChildDrawingOrder while collecting assist @ "
|
||||||
|
+ i + " of " + childrenCount, e);
|
||||||
|
// At least one app is failing when we call getChildDrawingOrder
|
||||||
|
// at this point, so deal semi-gracefully with it by falling back
|
||||||
|
// on the basic order.
|
||||||
|
customOrder = false;
|
||||||
|
if (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<i; j++) {
|
||||||
|
permutation[j] = getChildDrawingOrder(childrenCount, j);
|
||||||
|
usedIndices.put(permutation[j], true);
|
||||||
|
}
|
||||||
|
// Fill in the remaining indices with indices that have not
|
||||||
|
// yet been used.
|
||||||
|
int nextIndex = 0;
|
||||||
|
for (int j=i; j<childrenCount; j++) {
|
||||||
|
while (usedIndices.get(nextIndex, false)) {
|
||||||
|
nextIndex++;
|
||||||
|
}
|
||||||
|
permutation[j] = nextIndex;
|
||||||
|
nextIndex++;
|
||||||
|
}
|
||||||
|
// Build the final view list.
|
||||||
|
preorderedList = new ArrayList<>(childrenCount);
|
||||||
|
for (int j=0; j<childrenCount; j++) {
|
||||||
|
preorderedList.add(children[permutation[j]]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
throw e;
|
||||||
|
}
|
||||||
|
}
|
||||||
final View child = (preorderedList == null)
|
final View child = (preorderedList == null)
|
||||||
? children[childIndex] : preorderedList.get(childIndex);
|
? children[childIndex] : preorderedList.get(childIndex);
|
||||||
ViewStructure cstructure = structure.newChild(i);
|
ViewStructure cstructure = structure.newChild(i);
|
||||||
|
|||||||
Reference in New Issue
Block a user