use of android.util.SparseBooleanArray in project platform_frameworks_base by android.
the class Parcel method readSparseBooleanArray.
/**
* Read and return a new SparseBooleanArray object from the parcel at the current
* dataPosition(). Returns null if the previously written list object was
* null.
*/
public final SparseBooleanArray readSparseBooleanArray() {
int N = readInt();
if (N < 0) {
return null;
}
SparseBooleanArray sa = new SparseBooleanArray(N);
readSparseBooleanArrayInternal(sa, N);
return sa;
}
use of android.util.SparseBooleanArray in project platform_frameworks_base by android.
the class TableLayout method initTableLayout.
/**
* <p>Performs initialization common to prorgrammatic use and XML use of
* this widget.</p>
*/
private void initTableLayout() {
if (mCollapsedColumns == null) {
mCollapsedColumns = new SparseBooleanArray();
}
if (mStretchableColumns == null) {
mStretchableColumns = new SparseBooleanArray();
}
if (mShrinkableColumns == null) {
mShrinkableColumns = new SparseBooleanArray();
}
// TableLayouts are always in vertical orientation; keep this tracked
// for shared LinearLayout code.
setOrientation(VERTICAL);
mPassThroughListener = new PassThroughHierarchyChangeListener();
// make sure to call the parent class method to avoid potential
// infinite loops
super.setOnHierarchyChangeListener(mPassThroughListener);
mInitialized = true;
}
use of android.util.SparseBooleanArray in project platform_frameworks_base by android.
the class TableLayout method parseColumns.
/**
* <p>Parses a sequence of columns ids defined in a CharSequence with the
* following pattern (regex): \d+(\s*,\s*\d+)*</p>
*
* <p>Examples: "1" or "13, 7, 6" or "".</p>
*
* <p>The result of the parsing is stored in a sparse boolean array. The
* parsed column ids are used as the keys of the sparse array. The values
* are always true.</p>
*
* @param sequence a sequence of column ids, can be empty but not null
* @return a sparse array of boolean mapping column indexes to the columns
* collapse state
*/
private static SparseBooleanArray parseColumns(String sequence) {
SparseBooleanArray columns = new SparseBooleanArray();
Pattern pattern = Pattern.compile("\\s*,\\s*");
String[] columnDefs = pattern.split(sequence);
for (String columnIdentifier : columnDefs) {
try {
int columnIndex = Integer.parseInt(columnIdentifier);
// only valid, i.e. positive, columns indexes are handled
if (columnIndex >= 0) {
// putting true in this sparse array indicates that the
// column index was defined in the XML file
columns.put(columnIndex, true);
}
} catch (NumberFormatException e) {
// we just ignore columns that don't exist
}
}
return columns;
}
use of android.util.SparseBooleanArray in project platform_frameworks_base by android.
the class TableLayout method trackCollapsedColumns.
/**
* <p>Applies the columns collapse status to a new row added to this
* table. This method is invoked by PassThroughHierarchyChangeListener
* upon child insertion.</p>
*
* <p>This method only applies to {@link android.widget.TableRow}
* instances.</p>
*
* @param child the newly added child
*/
private void trackCollapsedColumns(View child) {
if (child instanceof TableRow) {
final TableRow row = (TableRow) child;
final SparseBooleanArray collapsedColumns = mCollapsedColumns;
final int count = collapsedColumns.size();
for (int i = 0; i < count; i++) {
int columnIndex = collapsedColumns.keyAt(i);
boolean isCollapsed = collapsedColumns.valueAt(i);
// visibility of the row's children
if (isCollapsed) {
row.setColumnCollapsed(columnIndex, isCollapsed);
}
}
}
}
use of android.util.SparseBooleanArray in project platform_frameworks_base by android.
the class ViewGroup method dispatchProvideStructure.
/**
* Dispatch creation of {@link ViewStructure} down the hierarchy. This implementation
* adds in all child views of the view group, in addition to calling the default View
* implementation.
*/
@Override
public void dispatchProvideStructure(ViewStructure structure) {
super.dispatchProvideStructure(structure);
if (!isAssistBlocked()) {
if (structure.getChildCount() == 0) {
final int childrenCount = getChildCount();
if (childrenCount > 0) {
structure.setChildCount(childrenCount);
ArrayList<View> preorderedList = buildOrderedChildList();
boolean customOrder = preorderedList == null && isChildrenDrawingOrderEnabled();
final View[] children = mChildren;
for (int i = 0; i < childrenCount; i++) {
int childIndex;
try {
childIndex = getAndVerifyPreorderedIndex(childrenCount, i, customOrder);
} 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 = getAndVerifyPreorderedView(preorderedList, children, childIndex);
final ViewStructure cstructure = structure.newChild(i);
child.dispatchProvideStructure(cstructure);
}
if (preorderedList != null)
preorderedList.clear();
}
}
}
}
Aggregations