Search in sources :

Example 81 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 82 with SparseBooleanArray

use of android.util.SparseBooleanArray in project collect by opendatakit.

the class FormDownloadList method downloadSelectedFiles.

/**
 * starts the task to download the selected forms, also shows progress dialog
 */
@SuppressWarnings("unchecked")
private void downloadSelectedFiles() {
    int totalCount = 0;
    ArrayList<FormDetails> filesToDownload = new ArrayList<FormDetails>();
    SparseBooleanArray sba = listView.getCheckedItemPositions();
    for (int i = 0; i < listView.getCount(); i++) {
        if (sba.get(i, false)) {
            HashMap<String, String> item = (HashMap<String, String>) listView.getAdapter().getItem(i);
            filesToDownload.add(formNamesAndURLs.get(item.get(FORMDETAIL_KEY)));
        }
    }
    totalCount = filesToDownload.size();
    Collect.getInstance().getActivityLogger().logAction(this, "downloadSelectedFiles", Integer.toString(totalCount));
    if (totalCount > 0) {
        // show dialog box
        showDialog(PROGRESS_DIALOG);
        downloadFormsTask = new DownloadFormsTask();
        downloadFormsTask.setDownloaderListener(this);
        downloadFormsTask.execute(filesToDownload);
    } else {
        ToastUtils.showShortToast(R.string.noselect_error);
    }
}
Also used : FormDetails(org.odk.collect.android.logic.FormDetails) HashMap(java.util.HashMap) DownloadFormsTask(org.odk.collect.android.tasks.DownloadFormsTask) ArrayList(java.util.ArrayList) SparseBooleanArray(android.util.SparseBooleanArray)

Example 83 with SparseBooleanArray

use of android.util.SparseBooleanArray in project android_frameworks_base by crdroidandroid.

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

Example 84 with SparseBooleanArray

use of android.util.SparseBooleanArray in project android_frameworks_base by crdroidandroid.

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 85 with SparseBooleanArray

use of android.util.SparseBooleanArray in project android_frameworks_base by crdroidandroid.

the class MultiSelectManagerTest method testProvisionalSelection_Replace.

public void testProvisionalSelection_Replace() {
    Selection s = mManager.getSelection();
    SparseBooleanArray provisional = new SparseBooleanArray();
    provisional.append(1, true);
    provisional.append(2, true);
    s.setProvisionalSelection(getItemIds(provisional));
    provisional.clear();
    provisional.append(3, true);
    provisional.append(4, true);
    s.setProvisionalSelection(getItemIds(provisional));
    assertSelection(items.get(3), items.get(4));
}
Also used : Selection(com.android.documentsui.dirlist.MultiSelectManager.Selection) SparseBooleanArray(android.util.SparseBooleanArray)

Aggregations

SparseBooleanArray (android.util.SparseBooleanArray)283 ArrayList (java.util.ArrayList)43 View (android.view.View)32 Selection (com.android.documentsui.dirlist.MultiSelectManager.Selection)30 Point (android.graphics.Point)28 ViewGroup (android.view.ViewGroup)20 ListView (android.widget.ListView)15 HashMap (java.util.HashMap)15 Paint (android.graphics.Paint)13 Intent (android.content.Intent)11 Map (java.util.Map)11 File (java.io.File)10 SparseArray (android.util.SparseArray)8 SuppressLint (android.annotation.SuppressLint)7 SparseIntArray (android.util.SparseIntArray)7 AdapterView (android.widget.AdapterView)7 Cursor (android.database.Cursor)6 ActionMenuChildView (com.actionbarsherlock.internal.view.menu.ActionMenuView.ActionMenuChildView)6 IndentingPrintWriter (com.android.internal.util.IndentingPrintWriter)6 List (java.util.List)6