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);
}
}
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);
}
}
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;
}
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);
}
}
}
}
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));
}
Aggregations