List of usage examples for android.util SparseBooleanArray size
public int size()
From source file:Main.java
/** * Method to avoid a bug on pre ICS/*from w w w . j a v a2 s .c o m*/ * * @see https://code.google.com/p/android/issues/detail?id=27112 */ public static SparseBooleanArray copySparseBooleanArray(SparseBooleanArray sba) { SparseBooleanArray out = new SparseBooleanArray(sba.size()); for (int i = 0; i < sba.size(); i++) { out.append(sba.keyAt(i), sba.valueAt(i)); } return out; }
From source file:Main.java
public static Map<Integer, Boolean> toMap(SparseBooleanArray array) { Map<Integer, Boolean> map = Maps.newHashMap(); for (int i = 0; i < array.size(); i++) { map.put(array.keyAt(i), array.valueAt(i)); }/*from w w w .ja va 2s.c o m*/ return map; }
From source file:Main.java
public static Set<Integer> toSet(SparseBooleanArray array) { Set<Integer> trueSet = Sets.newHashSet(); for (int i = 0; i < array.size(); i++) { if (array.valueAt(i)) { int position = array.keyAt(i); trueSet.add(position);//www.j a v a 2 s . co m } } return trueSet; }
From source file:Main.java
/** * Convert SparseBooleanArray to the List which contains indexes whose values are true * @param sparseCheckedArray/*from w w w . j av a 2s .c o m*/ * @return */ public static List<Integer> convertToCheckedIndexList(SparseBooleanArray sparseCheckedArray) { List<Integer> checkList = new ArrayList<>(); for (int i = 0; i < sparseCheckedArray.size(); i++) { int index = sparseCheckedArray.keyAt(i); if (sparseCheckedArray.valueAt(i)) { checkList.add(index); } } return checkList; }
From source file:Main.java
public static List<Integer> getAbsListViewCheckedItemPositions(AbsListView absListView) { SparseBooleanArray checked = absListView.getCheckedItemPositions(); List<Integer> positions = new ArrayList<>(); int checkedSize = checked.size(); for (int i = 0; i < checkedSize; ++i) { if (checked.valueAt(i)) { positions.add(checked.keyAt(i)); }/*from w ww. j av a2s . c o m*/ } return positions; }
From source file:Main.java
public static SparseBooleanArray cloneSBArray(SparseBooleanArray arr) { try {//from www. j a v a2 s .c o m return arr.clone(); } catch (Exception e) { // Happens when using HC - should clone manually int size = arr.size(); SparseBooleanArray clone = new SparseBooleanArray(); for (int i = 0; i < size; i++) { if (arr.get(arr.keyAt(i))) { clone.put(arr.keyAt(i), true); } } return clone; } }
From source file:net.sf.sprockets.util.SparseArrays.java
/** * Get the keys of the SparseBooleanArray. *//*from w ww. j a v a 2 s . c om*/ public static int[] keys(SparseBooleanArray array) { int[] keys = new int[array.size()]; for (int i = 0; i < keys.length; i++) { keys[i] = array.keyAt(i); } return keys; }
From source file:net.sf.sprockets.util.SparseArrays.java
/** * Get the first key of the SparseBooleanArray which has the value. * * @return {@link Integer#MIN_VALUE} if the value is not found *//*ww w . j av a 2s . co m*/ private static int firstKey(SparseBooleanArray array, boolean value) { int size = array.size(); for (int i = 0; i < size; i++) { if (array.valueAt(i) == value) { return array.keyAt(i); } } return Integer.MIN_VALUE; }
From source file:net.sf.sprockets.util.SparseArrays.java
/** * Get the values of the SparseBooleanArray. *///from ww w .ja va 2 s .c o m public static boolean[] values(SparseBooleanArray array) { boolean[] vals = new boolean[array.size()]; for (int i = 0; i < vals.length; i++) { vals[i] = array.valueAt(i); } return vals; }
From source file:net.sf.sprockets.util.SparseArrays.java
/** * Get the keys of the SparseBooleanArray which have the value. *//*w w w. jav a 2 s.co m*/ private static int[] keys(SparseBooleanArray array, boolean value) { int size = array.size(); ArrayIntList keys = new ArrayIntList(size); for (int i = 0; i < size; i++) { if (array.valueAt(i) == value) { keys.add(array.keyAt(i)); } } return keys.toArray(); }