Search in sources :

Example 31 with SparseBooleanArray

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);
            }
        }
    }
}
Also used : SparseBooleanArray(android.util.SparseBooleanArray)

Example 32 with SparseBooleanArray

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();
            }
        }
    }
}
Also used : SparseBooleanArray(android.util.SparseBooleanArray) ArrayList(java.util.ArrayList) Paint(android.graphics.Paint)

Example 33 with SparseBooleanArray

use of android.util.SparseBooleanArray in project JamsMusicPlayer by psaravan.

the class DragSortListView method removeCheckState.

/**
     * Use this when an item has been deleted, to move the check state of all
     * following items up one step. If you have a choiceMode which is not none,
     * this method must be called when the order of items changes in an
     * underlying adapter which does not have stable IDs (see
     * {@link ListAdapter#hasStableIds()}). This is because without IDs, the
     * ListView has no way of knowing which items have moved where, and cannot
     * update the check state accordingly.
     * 
     * See also further comments on {@link #moveCheckState(int, int)}.
     * 
     * @param position
     */
public void removeCheckState(int position) {
    SparseBooleanArray cip = getCheckedItemPositions();
    if (cip.size() == 0)
        return;
    int[] runStart = new int[cip.size()];
    int[] runEnd = new int[cip.size()];
    int rangeStart = position;
    int rangeEnd = cip.keyAt(cip.size() - 1) + 1;
    int runCount = buildRunList(cip, rangeStart, rangeEnd, runStart, runEnd);
    for (int i = 0; i != runCount; i++) {
        if (!(runStart[i] == position || (runEnd[i] < runStart[i] && runEnd[i] > position))) {
            // Only set a new check mark in front of this run if it does
            // not contain the deleted position. If it does, we only need
            // to make it one check mark shorter at the end.
            setItemChecked(rotate(runStart[i], -1, rangeStart, rangeEnd), true);
        }
        setItemChecked(rotate(runEnd[i], -1, rangeStart, rangeEnd), false);
    }
}
Also used : SparseBooleanArray(android.util.SparseBooleanArray) Point(android.graphics.Point)

Example 34 with SparseBooleanArray

use of android.util.SparseBooleanArray in project cw-advandroid by commonsguy.

the class ActionModeDemo method performActions.

@SuppressWarnings("unchecked")
public boolean performActions(MenuItem item) {
    ArrayAdapter<String> adapter = (ArrayAdapter<String>) getListAdapter();
    SparseBooleanArray checked = getListView().getCheckedItemPositions();
    switch(item.getItemId()) {
        case R.id.cap:
            for (int i = 0; i < checked.size(); i++) {
                if (checked.valueAt(i)) {
                    int position = checked.keyAt(i);
                    String word = words.get(position);
                    word = word.toUpperCase();
                    adapter.remove(words.get(position));
                    adapter.insert(word, position);
                }
            }
            return (true);
        case R.id.remove:
            ArrayList<Integer> positions = new ArrayList<Integer>();
            for (int i = 0; i < checked.size(); i++) {
                if (checked.valueAt(i)) {
                    positions.add(checked.keyAt(i));
                }
            }
            Collections.sort(positions, Collections.reverseOrder());
            for (int position : positions) {
                adapter.remove(words.get(position));
            }
            getListView().clearChoices();
            return (true);
    }
    return (false);
}
Also used : SparseBooleanArray(android.util.SparseBooleanArray) ArrayList(java.util.ArrayList) ArrayAdapter(android.widget.ArrayAdapter)

Example 35 with SparseBooleanArray

use of android.util.SparseBooleanArray in project android-parcelable-intellij-plugin by mcharmas.

the class SparseParcelable method create.

public static SparseParcelable create() {
    SparseArray<String> sampleSparseArray = new SparseArray<String>(10);
    sampleSparseArray.put(10, "abcd");
    SparseBooleanArray sparseBooleanArray = new SparseBooleanArray();
    sparseBooleanArray.put(1, false);
    return new SparseParcelable(sampleSparseArray, sparseBooleanArray);
}
Also used : SparseArray(android.util.SparseArray) SparseBooleanArray(android.util.SparseBooleanArray)

Aggregations

SparseBooleanArray (android.util.SparseBooleanArray)235 Selection (com.android.documentsui.dirlist.MultiSelectManager.Selection)30 ArrayList (java.util.ArrayList)25 View (android.view.View)20 Point (android.graphics.Point)18 ViewGroup (android.view.ViewGroup)16 Paint (android.graphics.Paint)13 HashMap (java.util.HashMap)12 Map (java.util.Map)11 SparseArray (android.util.SparseArray)7 File (java.io.File)7 Pattern (java.util.regex.Pattern)7 Cursor (android.database.Cursor)6 SparseIntArray (android.util.SparseIntArray)6 ActionMenuChildView (com.actionbarsherlock.internal.view.menu.ActionMenuView.ActionMenuChildView)6 IndentingPrintWriter (com.android.internal.util.IndentingPrintWriter)6 Account (android.accounts.Account)5 NonNull (android.annotation.NonNull)5 ContentValues (android.content.ContentValues)5 SQLiteDatabase (android.database.sqlite.SQLiteDatabase)5