List of usage examples for android.util SparseBooleanArray valueAt
public boolean valueAt(int index)
0...size()-1
, returns the value from the index
th key-value mapping that this SparseBooleanArray stores. From source file:com.huewu.pla.lib.internal.PLAListView.java
/** * Returns the set of checked items ids. The result is only valid if the * choice mode has not been set to {@link #CHOICE_MODE_NONE}. * /*from www .j a v a 2s . c o m*/ * @return A new array which contains the id of each checked item in the * list. * * @deprecated Use {@link #getCheckedItemIds()} instead. */ @Deprecated public long[] getCheckItemIds() { // Use new behavior that correctly handles stable ID mapping. if (mAdapter != null && mAdapter.hasStableIds()) return getCheckedItemIds(); // Old behavior was buggy, but would sort of work for adapters without // stable IDs. // Fall back to it to support legacy apps. if (mChoiceMode != CHOICE_MODE_NONE && mCheckStates != null && mAdapter != null) { final SparseBooleanArray states = mCheckStates; final int count = states.size(); final long[] ids = new long[count]; final ListAdapter adapter = mAdapter; int checkedCount = 0; for (int i = 0; i < count; i++) { if (states.valueAt(i)) { ids[checkedCount++] = adapter.getItemId(states.keyAt(i)); } } // Trim array if needed. mCheckStates may contain false values // resulting in checkedCount being smaller than count. if (checkedCount == count) return ids; else { final long[] result = new long[checkedCount]; System.arraycopy(ids, 0, result, 0, checkedCount); return result; } } return new long[0]; }
From source file:com.appunite.list.HorizontalListView.java
/** * Returns the set of checked items ids. The result is only valid if the * choice mode has not been set to {@link #CHOICE_MODE_NONE}. * /*ww w . j a va 2 s .co m*/ * @return A new array which contains the id of each checked item in the * list. * * @deprecated Use {@link #getCheckedItemIds()} instead. */ @Deprecated public long[] getCheckItemIds() { // Use new behavior that correctly handles stable ID mapping. if (mAdapter != null && mAdapter.hasStableIds()) { return getCheckedItemIds(); } // Old behavior was buggy, but would sort of work for adapters without stable IDs. // Fall back to it to support legacy apps. if (mChoiceMode != CHOICE_MODE_NONE && mCheckStates != null && mAdapter != null) { final SparseBooleanArray states = mCheckStates; final int count = states.size(); final long[] ids = new long[count]; final ListAdapter adapter = mAdapter; int checkedCount = 0; for (int i = 0; i < count; i++) { if (states.valueAt(i)) { ids[checkedCount++] = adapter.getItemId(states.keyAt(i)); } } // Trim array if needed. mCheckStates may contain false values // resulting in checkedCount being smaller than count. if (checkedCount == count) { return ids; } else { final long[] result = new long[checkedCount]; System.arraycopy(ids, 0, result, 0, checkedCount); return result; } } return new long[0]; }