List of usage examples for android.util SparseArray size
public int size()
From source file:Main.java
public static <E> boolean isEmpty(SparseArray<E> array) { if (array == null || array.size() == 0) { return true; }//from w w w .j av a 2 s .co m return false; }
From source file:Main.java
private static void print(SparseArray<String> strs) { for (int i = 0; i < strs.size(); i++) { Log.i("XJ", "key = " + strs.keyAt(i) + ",value = " + strs.valueAt(i)); }/* ww w . j a v a2 s .c om*/ }
From source file:Main.java
public static void recycleBitmaps(SparseArray<Bitmap> bitmapSparseArray) { for (int i = 0; i < bitmapSparseArray.size(); i++) { Bitmap mBitmap = bitmapSparseArray.get(i); if (mBitmap != null) { mBitmap.recycle();//w w w . j a va 2 s .c om mBitmap = null; } } }
From source file:Main.java
private static void clearSparseArray(SparseArray<?> spArray) { if (spArray != null) { int size = spArray.size(); for (int i = 0; i < size; i++) { spArray.setValueAt(i, null); }// www .j a v a 2s. co m } }
From source file:Main.java
public static boolean isEmpty(SparseArray sparseArray) { return sparseArray == null || sparseArray.size() <= 0; }
From source file:Main.java
public static void scaleBitmaps(SparseArray<Bitmap> bitmapMap, float scale) { for (int i = 0; i < bitmapMap.size(); i++) { int key = bitmapMap.keyAt(i); Log.d("BitmapUtil", "scaleBitmaps: " + key); Bitmap bitmap = bitmapMap.get(key); bitmapMap.put(i, scaleBitmap(bitmap, scale)); }//from www .j a v a2s . c o m }
From source file:Main.java
public static float averageValueOfCompartments(SparseArray<ArrayList<Float>> compartments) { return sumCompartmentsValues(compartments) / compartments.size(); }
From source file:Main.java
public static float sumCompartmentsValues(SparseArray<ArrayList<Float>> compartments) { float sum = 0L; for (int i = 0; i < compartments.size(); i++) { for (int j = 0; j < compartments.get(i).size(); j++) { sum += compartments.get(i).get(j); }//from w w w . j a va2 s .c om } return sum; }
From source file:Main.java
public static int getSize(SparseArray<?> sparseArray) { if (sparseArray == null) { return 0; }//from ww w . j a va 2 s . c om return sparseArray.size(); }
From source file:Main.java
public static <C> List<C> asList(SparseArray<C> sparseArray) { if (sparseArray == null) return null; List<C> arrayList = new ArrayList<C>(sparseArray.size()); for (int i = 0; i < sparseArray.size(); i++) arrayList.add(sparseArray.valueAt(i)); return arrayList; }