Java 类android.util.SparseLongArray 实例源码

项目:sprockets-android    文件:SparseArrays.java   
private static <E> Object values(SparseArray<E> a, SparseBooleanArray b, SparseIntArray c,
                                 SparseLongArray d, LongSparseArray<E> e) {
    int size = size(a, b, c, d, e);
    ArrayList<E> vals = a != null || e != null ? new ArrayList<>(size) : null;
    boolean[] bools = b != null ? new boolean[size] : null;
    int[] ints = c != null ? new int[size] : null;
    long[] longs = d != null ? new long[size] : null;
    for (int i = 0; i < size; i++) {
        if (vals != null) {
            vals.add(a != null ? a.valueAt(i) : e.valueAt(i));
        } else if (bools != null) {
            bools[i] = b.valueAt(i);
        } else if (ints != null) {
            ints[i] = c.valueAt(i);
        } else if (longs != null) {
            longs[i] = d.valueAt(i);
        }
    }
    return vals != null ? vals : bools != null ? bools : ints != null ? ints : longs;
}
项目:codedemos    文件:EmptyUtil.java   
public static boolean isEmpty(Object obj) {
    if (obj == null) {
        return true;
    }
    if (obj instanceof String && obj.toString().length() == 0) {
        return true;
    }
    if (obj.getClass().isArray() && Array.getLength(obj) == 0) {
        return true;
    }
    if (obj instanceof Collection && ((Collection) obj).isEmpty()) {
        return true;
    }
    if (obj instanceof Map && ((Map) obj).isEmpty()) {
        return true;
    }
    if (obj instanceof SparseArray && ((SparseArray) obj).size() == 0) {
        return true;
    }
    if (obj instanceof SparseBooleanArray && ((SparseBooleanArray) obj).size() == 0) {
        return true;
    }
    if (obj instanceof SparseIntArray && ((SparseIntArray) obj).size() == 0) {
        return true;
    }
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR2) {
        if (obj instanceof SparseLongArray && ((SparseLongArray) obj).size() == 0) {
            return true;
        }
    }
    return false;
}
项目:Android-UtilCode    文件:EmptyUtils.java   
/**
 * 判断对象是否为空
 *
 * @param obj 对象
 * @return {@code true}: 为空<br>{@code false}: 不为空
 */
public static boolean isEmpty(Object obj) {
    if (obj == null) {
        return true;
    }
    if (obj instanceof String && obj.toString().length() == 0) {
        return true;
    }
    if (obj.getClass().isArray() && Array.getLength(obj) == 0) {
        return true;
    }
    if (obj instanceof Collection && ((Collection) obj).isEmpty()) {
        return true;
    }
    if (obj instanceof Map && ((Map) obj).isEmpty()) {
        return true;
    }
    if (obj instanceof SparseArray && ((SparseArray) obj).size() == 0) {
        return true;
    }
    if (obj instanceof SparseBooleanArray && ((SparseBooleanArray) obj).size() == 0) {
        return true;
    }
    if (obj instanceof SparseIntArray && ((SparseIntArray) obj).size() == 0) {
        return true;
    }
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR2) {
        if (obj instanceof SparseLongArray && ((SparseLongArray) obj).size() == 0) {
            return true;
        }
    }
    return false;
}
项目:Android-UtilCode    文件:EmptyUtilsTest.java   
@TargetApi(Build.VERSION_CODES.JELLY_BEAN_MR2)
@Test
public void isEmpty() throws Exception {
    String string = "";
    String string1 = " ";
    int[][] arr = new int[][]{};
    int[] arr1 = null;
    LinkedList<Integer> list = new LinkedList<>();
    HashMap<String,Integer> map = new HashMap<>();
    SparseArray<String> sa = new SparseArray<>();
    SparseBooleanArray sba = new SparseBooleanArray();
    SparseIntArray sia = new SparseIntArray();
    SparseLongArray sla = new SparseLongArray();

    assertThat(EmptyUtils.isEmpty(string)).isTrue();
    assertThat(EmptyUtils.isEmpty(string1)).isFalse();
    assertThat(EmptyUtils.isEmpty(arr)).isTrue();
    assertThat(EmptyUtils.isEmpty(arr1)).isTrue();
    assertThat(EmptyUtils.isEmpty(list)).isTrue();
    assertThat(EmptyUtils.isEmpty(map)).isTrue();
    assertThat(EmptyUtils.isEmpty(sa)).isTrue();
    assertThat(EmptyUtils.isEmpty(sba)).isTrue();
    assertThat(EmptyUtils.isEmpty(sia)).isTrue();
    assertThat(EmptyUtils.isEmpty(sla)).isTrue();

    assertThat(!EmptyUtils.isNotEmpty(string)).isTrue();
    assertThat(!EmptyUtils.isNotEmpty(string1)).isFalse();
    assertThat(!EmptyUtils.isNotEmpty(arr)).isTrue();
    assertThat(!EmptyUtils.isNotEmpty(arr1)).isTrue();
    assertThat(!EmptyUtils.isNotEmpty(list)).isTrue();
    assertThat(!EmptyUtils.isNotEmpty(map)).isTrue();
    assertThat(!EmptyUtils.isNotEmpty(sa)).isTrue();
    assertThat(!EmptyUtils.isNotEmpty(sba)).isTrue();
    assertThat(!EmptyUtils.isNotEmpty(sia)).isTrue();
    assertThat(!EmptyUtils.isNotEmpty(sla)).isTrue();
}
项目:AndroidUtilCode-master    文件:EmptyUtils.java   
/**
 * 判断对象是否为空
 *
 * @param obj 对象
 * @return {@code true}: 为空<br>{@code false}: 不为空
 */
public static boolean isEmpty(Object obj) {
    if (obj == null) {
        return true;
    }
    if (obj instanceof String && obj.toString().length() == 0) {
        return true;
    }
    if (obj.getClass().isArray() && Array.getLength(obj) == 0) {
        return true;
    }
    if (obj instanceof Collection && ((Collection) obj).isEmpty()) {
        return true;
    }
    if (obj instanceof Map && ((Map) obj).isEmpty()) {
        return true;
    }
    if (obj instanceof SparseArray && ((SparseArray) obj).size() == 0) {
        return true;
    }
    if (obj instanceof SparseBooleanArray && ((SparseBooleanArray) obj).size() == 0) {
        return true;
    }
    if (obj instanceof SparseIntArray && ((SparseIntArray) obj).size() == 0) {
        return true;
    }
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR2) {
        if (obj instanceof SparseLongArray && ((SparseLongArray) obj).size() == 0) {
            return true;
        }
    }
    return false;
}
项目:AndroidUtilCode-master    文件:EmptyUtilsTest.java   
@TargetApi(Build.VERSION_CODES.JELLY_BEAN_MR2)
@Test
public void isEmpty() throws Exception {
    String string = "";
    String string1 = " ";
    int[][] arr = new int[][]{};
    int[] arr1 = null;
    LinkedList<Integer> list = new LinkedList<>();
    HashMap<String,Integer> map = new HashMap<>();
    SparseArray<String> sa = new SparseArray<>();
    SparseBooleanArray sba = new SparseBooleanArray();
    SparseIntArray sia = new SparseIntArray();
    SparseLongArray sla = new SparseLongArray();

    assertThat(EmptyUtils.isEmpty(string)).isTrue();
    assertThat(EmptyUtils.isEmpty(string1)).isFalse();
    assertThat(EmptyUtils.isEmpty(arr)).isTrue();
    assertThat(EmptyUtils.isEmpty(arr1)).isTrue();
    assertThat(EmptyUtils.isEmpty(list)).isTrue();
    assertThat(EmptyUtils.isEmpty(map)).isTrue();
    assertThat(EmptyUtils.isEmpty(sa)).isTrue();
    assertThat(EmptyUtils.isEmpty(sba)).isTrue();
    assertThat(EmptyUtils.isEmpty(sia)).isTrue();
    assertThat(EmptyUtils.isEmpty(sla)).isTrue();

    assertThat(!EmptyUtils.isNotEmpty(string)).isTrue();
    assertThat(!EmptyUtils.isNotEmpty(string1)).isFalse();
    assertThat(!EmptyUtils.isNotEmpty(arr)).isTrue();
    assertThat(!EmptyUtils.isNotEmpty(arr1)).isTrue();
    assertThat(!EmptyUtils.isNotEmpty(list)).isTrue();
    assertThat(!EmptyUtils.isNotEmpty(map)).isTrue();
    assertThat(!EmptyUtils.isNotEmpty(sa)).isTrue();
    assertThat(!EmptyUtils.isNotEmpty(sba)).isTrue();
    assertThat(!EmptyUtils.isNotEmpty(sia)).isTrue();
    assertThat(!EmptyUtils.isNotEmpty(sla)).isTrue();
}
项目:XFrame    文件:XEmptyUtils.java   
/**
 * 判断对象是否为null或长度数量为0
 *
 * @param obj 对象
 * @return {@code true}: 为空<br>{@code false}: 不为空
 */
public static boolean isEmpty(Object obj) {
    if (obj == null) {
        return true;
    }
    if (obj instanceof String && obj.toString().length() == 0) {
        return true;
    }
    if (obj.getClass().isArray() && Array.getLength(obj) == 0) {
        return true;
    }
    if (obj instanceof Collection && ((Collection) obj).isEmpty()) {
        return true;
    }
    if (obj instanceof Map && ((Map) obj).isEmpty()) {
        return true;
    }
    if (obj instanceof SparseArray && ((SparseArray) obj).size() == 0) {
        return true;
    }
    if (obj instanceof SparseBooleanArray && ((SparseBooleanArray) obj).size() == 0) {
        return true;
    }
    if (obj instanceof SparseIntArray && ((SparseIntArray) obj).size() == 0) {
        return true;
    }
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR2) {
        if (obj instanceof SparseLongArray && ((SparseLongArray) obj).size() == 0) {
            return true;
        }
    }
    return false;
}
项目:LJFramework    文件:EmptyUtils.java   
/**
 * 判断对象是否为空
 *
 * @param obj 对象
 * @return {@code true}: 为空<br>{@code false}: 不为空
 */
public static boolean isEmpty(Object obj) {
    if (obj == null) {
        return true;
    }
    if (obj instanceof String && obj.toString().length() == 0) {
        return true;
    }
    if (obj.getClass().isArray() && Array.getLength(obj) == 0) {
        return true;
    }
    if (obj instanceof Collection && ((Collection) obj).isEmpty()) {
        return true;
    }
    if (obj instanceof Map && ((Map) obj).isEmpty()) {
        return true;
    }
    if (obj instanceof SparseArray && ((SparseArray) obj).size() == 0) {
        return true;
    }
    if (obj instanceof SparseBooleanArray &&
            ((SparseBooleanArray) obj).size() == 0) {
        return true;
    }
    if (obj instanceof SparseIntArray &&
            ((SparseIntArray) obj).size() == 0) {
        return true;
    }
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR2) {
        if (obj instanceof SparseLongArray &&
                ((SparseLongArray) obj).size() == 0) {
            return true;
        }
    }
    return false;
}
项目:GankReader    文件:EmptyUtils.java   
/**
 * 判断对象是否为空
 *
 * @param obj 对象
 * @return {@code true}: 为空<br>{@code false}: 不为空
 */
public static boolean isEmpty(Object obj) {
    if (obj == null) {
        return true;
    }
    if (obj instanceof String && obj.toString().length() == 0) {
        return true;
    }
    if (obj.getClass().isArray() && Array.getLength(obj) == 0) {
        return true;
    }
    if (obj instanceof Collection && ((Collection) obj).isEmpty()) {
        return true;
    }
    if (obj instanceof Map && ((Map) obj).isEmpty()) {
        return true;
    }
    if (obj instanceof SparseArray && ((SparseArray) obj).size() == 0) {
        return true;
    }
    if (obj instanceof SparseBooleanArray && ((SparseBooleanArray) obj).size() == 0) {
        return true;
    }
    if (obj instanceof SparseIntArray && ((SparseIntArray) obj).size() == 0) {
        return true;
    }
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR2) {
        if (obj instanceof SparseLongArray && ((SparseLongArray) obj).size() == 0) {
            return true;
        }
    }
    return false;
}
项目:BaseCore    文件:EmptyUtils.java   
/**
 * 判断对象是否为空
 *
 * @param obj 对象
 * @return {@code true}: 为空<br>{@code false}: 不为空
 */
public static boolean isEmpty(Object obj) {
    if (obj == null) {
        return true;
    }
    if (obj instanceof String && obj.toString().length() == 0) {
        return true;
    }
    if (obj.getClass().isArray() && Array.getLength(obj) == 0) {
        return true;
    }
    if (obj instanceof Collection && ((Collection) obj).isEmpty()) {
        return true;
    }
    if (obj instanceof Map && ((Map) obj).isEmpty()) {
        return true;
    }
    if (obj instanceof SparseArray && ((SparseArray) obj).size() == 0) {
        return true;
    }
    if (obj instanceof SparseBooleanArray && ((SparseBooleanArray) obj).size() == 0) {
        return true;
    }
    if (obj instanceof SparseIntArray && ((SparseIntArray) obj).size() == 0) {
        return true;
    }
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR2) {
        if (obj instanceof SparseLongArray && ((SparseLongArray) obj).size() == 0) {
            return true;
        }
    }
    return false;
}
项目:RLibrary    文件:EmptyUtils.java   
/**
 * 判断对象是否为空
 *
 * @param obj 对象
 * @return {@code true}: 为空<br>{@code false}: 不为空
 */
public static boolean isEmpty(Object obj) {
    if (obj == null) {
        return true;
    }
    if (obj instanceof String && obj.toString().length() == 0) {
        return true;
    }
    if (obj.getClass().isArray() && Array.getLength(obj) == 0) {
        return true;
    }
    if (obj instanceof Collection && ((Collection) obj).isEmpty()) {
        return true;
    }
    if (obj instanceof Map && ((Map) obj).isEmpty()) {
        return true;
    }
    if (obj instanceof SparseArray && ((SparseArray) obj).size() == 0) {
        return true;
    }
    if (obj instanceof SparseBooleanArray && ((SparseBooleanArray) obj).size() == 0) {
        return true;
    }
    if (obj instanceof SparseIntArray && ((SparseIntArray) obj).size() == 0) {
        return true;
    }
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR2) {
        if (obj instanceof SparseLongArray && ((SparseLongArray) obj).size() == 0) {
            return true;
        }
    }
    return false;
}
项目:truth-android    文件:SparseLongArraySubject.java   
public static SubjectFactory<SparseLongArraySubject, SparseLongArray> type() {
  return new SubjectFactory<SparseLongArraySubject, SparseLongArray>() {
    @Override
    public SparseLongArraySubject getSubject(FailureStrategy fs, SparseLongArray that) {
      return new SparseLongArraySubject(fs, that);
    }
  };
}
项目:RxTools    文件:RxDataTool.java   
/**
 * 判断对象是否为空
 *
 * @param obj 对象
 * @return {@code true}: 为空<br>{@code false}: 不为空
 */
public static boolean isEmpty(Object obj) {
    if (obj == null) {
        return true;
    }
    if (obj instanceof String && obj.toString().length() == 0) {
        return true;
    }
    if (obj.getClass().isArray() && Array.getLength(obj) == 0) {
        return true;
    }
    if (obj instanceof Collection && ((Collection) obj).isEmpty()) {
        return true;
    }
    if (obj instanceof Map && ((Map) obj).isEmpty()) {
        return true;
    }
    if (obj instanceof SparseArray && ((SparseArray) obj).size() == 0) {
        return true;
    }
    if (obj instanceof SparseBooleanArray && ((SparseBooleanArray) obj).size() == 0) {
        return true;
    }
    if (obj instanceof SparseIntArray && ((SparseIntArray) obj).size() == 0) {
        return true;
    }
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR2) {
        if (obj instanceof SparseLongArray && ((SparseLongArray) obj).size() == 0) {
            return true;
        }
    }
    return false;
}
项目:AndroidUtilLib    文件:SDObjectUtil.java   
/**
 * 判断对象是否为空
 *
 * @param obj 对象
 * @return {@code true}: 为空<br>{@code false}: 不为空
 */
public static boolean isEmpty(Object obj) {
    if (obj == null) {
        return true;
    }
    if (obj instanceof String && obj.toString().length() == 0) {
        return true;
    }
    if (obj.getClass().isArray() && Array.getLength(obj) == 0) {
        return true;
    }
    if (obj instanceof Collection && ((Collection) obj).isEmpty()) {
        return true;
    }
    if (obj instanceof Map && ((Map) obj).isEmpty()) {
        return true;
    }
    if (obj instanceof SparseArray && ((SparseArray) obj).size() == 0) {
        return true;
    }
    if (obj instanceof SparseBooleanArray && ((SparseBooleanArray) obj).size() == 0) {
        return true;
    }
    if (obj instanceof SparseIntArray && ((SparseIntArray) obj).size() == 0) {
        return true;
    }
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR2) {
        if (obj instanceof SparseLongArray && ((SparseLongArray) obj).size() == 0) {
            return true;
        }
    }
    return false;
}
项目:BaseLibrary    文件:CheckEmptyUtils.java   
/**
 * 判断对象是否为空
 *
 * @param obj 对象
 * @return {@code true}: 为空<br>{@code false}: 不为空
 */
public static boolean isEmpty(Object obj) {
    if (obj == null) {
        return true;
    }
    if (obj instanceof String && obj.toString().length() == 0) {
        return true;
    }
    if (obj.getClass().isArray() && Array.getLength(obj) == 0) {
        return true;
    }
    if (obj instanceof Collection && ((Collection) obj).isEmpty()) {
        return true;
    }
    if (obj instanceof Map && ((Map) obj).isEmpty()) {
        return true;
    }
    if (obj instanceof SparseArray && ((SparseArray) obj).size() == 0) {
        return true;
    }
    if (obj instanceof SparseBooleanArray && ((SparseBooleanArray) obj).size() == 0) {
        return true;
    }
    if (obj instanceof SparseIntArray && ((SparseIntArray) obj).size() == 0) {
        return true;
    }
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR2) {
        if (obj instanceof SparseLongArray && ((SparseLongArray) obj).size() == 0) {
            return true;
        }
    }
    return false;
}
项目:Bluemix-IoT-android-wear    文件:DeviceClient.java   
private DeviceClient(Context context) {
    this.context = context;

    googleApiClient = new GoogleApiClient.Builder(context).addApi(Wearable.API).build();

    executorService = Executors.newCachedThreadPool();
    lastSensorData = new SparseLongArray();
}
项目:sprockets-android    文件:SparseArrays.java   
private static Object keys(SparseArray<?> a, SparseBooleanArray b, SparseIntArray c,
                           SparseLongArray d, LongSparseArray<?> e) {
    int size = size(a, b, c, d, e);
    int[] ints = a != null || b != null || c != null || d != null ? new int[size] : null;
    long[] longs = e != null ? new long[size] : null;
    for (int i = 0; i < size; i++) {
        if (ints != null) {
            ints[i] = a != null ? a.keyAt(i)
                    : b != null ? b.keyAt(i) : c != null ? c.keyAt(i) : d.keyAt(i);
        } else if (longs != null) {
            longs[i] = e.keyAt(i);
        }
    }
    return ints != null ? ints : longs;
}
项目:SensorDashboard    文件:DeviceClient.java   
private DeviceClient(Context context) {
    this.context = context;

    googleApiClient = new GoogleApiClient.Builder(context).addApi(Wearable.API).build();

    executorService = Executors.newCachedThreadPool();
    lastSensorData = new SparseLongArray();
}
项目:robo-fashion    文件:SparseLongArrayIterableImpl.java   
public TranslatedSparseLongArrayIterableImpl(final SparseLongArrayIterableImpl wrapped,
        final FullIntTranslator keyTranslator, final FullLongTranslator valueTranslator) {

    super((SparseLongArray) null);

    mIterable = wrapped;
    mKeyTranslator = keyTranslator;
    mValueTranslator = valueTranslator;
}
项目:GitHub    文件:EmptyUtils.java   
/**
 * 判断对象是否为空
 *
 * @param obj 对象
 * @return {@code true}: 为空<br>{@code false}: 不为空
 */
public static boolean isEmpty(final Object obj) {
    if (obj == null) {
        return true;
    }
    if (obj instanceof String && obj.toString().length() == 0) {
        return true;
    }
    if (obj.getClass().isArray() && Array.getLength(obj) == 0) {
        return true;
    }
    if (obj instanceof Collection && ((Collection) obj).isEmpty()) {
        return true;
    }
    if (obj instanceof Map && ((Map) obj).isEmpty()) {
        return true;
    }
    if (obj instanceof SimpleArrayMap && ((SimpleArrayMap) obj).isEmpty()) {
        return true;
    }
    if (obj instanceof SparseArray && ((SparseArray) obj).size() == 0) {
        return true;
    }
    if (obj instanceof SparseBooleanArray && ((SparseBooleanArray) obj).size() == 0) {
        return true;
    }
    if (obj instanceof SparseIntArray && ((SparseIntArray) obj).size() == 0) {
        return true;
    }
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR2) {
        if (obj instanceof SparseLongArray && ((SparseLongArray) obj).size() == 0) {
            return true;
        }
    }
    if (obj instanceof LongSparseArray && ((LongSparseArray) obj).size() == 0) {
        return true;
    }
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) {
        if (obj instanceof android.util.LongSparseArray && ((android.util.LongSparseArray) obj).size() == 0) {
            return true;
        }
    }
    return false;
}
项目:GitHub    文件:EmptyUtilsTest.java   
@TargetApi(Build.VERSION_CODES.JELLY_BEAN_MR2)
@Test
public void isEmpty() throws Exception {
    String string = "";
    String string1 = " ";
    int[][] arr = new int[][]{};
    int[] arr1 = null;
    LinkedList<Integer> list = new LinkedList<>();
    HashMap<String, Integer> map = new HashMap<>();
    SimpleArrayMap<String, Integer> sam = new SimpleArrayMap<>();
    SparseArray<String> sa = new SparseArray<>();
    SparseBooleanArray sba = new SparseBooleanArray();
    SparseIntArray sia = new SparseIntArray();
    SparseLongArray sla = new SparseLongArray();
    LongSparseArray<String> lsa = new LongSparseArray<>();
    android.util.LongSparseArray<String> lsaV4 = new android.util.LongSparseArray<>();

    assertTrue(EmptyUtils.isEmpty(string));
    assertFalse(EmptyUtils.isEmpty(string1));
    assertTrue(EmptyUtils.isEmpty(arr));
    assertTrue(EmptyUtils.isEmpty(arr1));
    assertTrue(EmptyUtils.isEmpty(list));
    assertTrue(EmptyUtils.isEmpty(map));
    assertTrue(EmptyUtils.isEmpty(sam));
    assertTrue(EmptyUtils.isEmpty(sa));
    assertTrue(EmptyUtils.isEmpty(sba));
    assertTrue(EmptyUtils.isEmpty(sia));
    assertTrue(EmptyUtils.isEmpty(sla));
    assertTrue(EmptyUtils.isEmpty(lsa));
    assertTrue(EmptyUtils.isEmpty(lsaV4));

    assertTrue(!EmptyUtils.isNotEmpty(string));
    assertFalse(!EmptyUtils.isNotEmpty(string1));
    assertTrue(!EmptyUtils.isNotEmpty(arr));
    assertTrue(!EmptyUtils.isNotEmpty(arr1));
    assertTrue(!EmptyUtils.isNotEmpty(list));
    assertTrue(!EmptyUtils.isNotEmpty(map));
    assertTrue(!EmptyUtils.isNotEmpty(sam));
    assertTrue(!EmptyUtils.isNotEmpty(sa));
    assertTrue(!EmptyUtils.isNotEmpty(sba));
    assertTrue(!EmptyUtils.isNotEmpty(sia));
    assertTrue(!EmptyUtils.isNotEmpty(sla));
    assertTrue(!EmptyUtils.isNotEmpty(lsa));
    assertTrue(!EmptyUtils.isNotEmpty(lsaV4));
}
项目:HeadlineNews    文件:EmptyUtils.java   
/**
 * 判断对象是否为空
 *
 * @param obj 对象
 * @return {@code true}: 为空<br>{@code false}: 不为空
 */
public static boolean isEmpty(final Object obj) {
    if (obj == null) {
        return true;
    }
    if (obj instanceof String && obj.toString().length() == 0) {
        return true;
    }
    if (obj.getClass().isArray() && Array.getLength(obj) == 0) {
        return true;
    }
    if (obj instanceof Collection && ((Collection) obj).isEmpty()) {
        return true;
    }
    if (obj instanceof Map && ((Map) obj).isEmpty()) {
        return true;
    }
    if (obj instanceof SimpleArrayMap && ((SimpleArrayMap) obj).isEmpty()) {
        return true;
    }
    if (obj instanceof SparseArray && ((SparseArray) obj).size() == 0) {
        return true;
    }
    if (obj instanceof SparseBooleanArray && ((SparseBooleanArray) obj).size() == 0) {
        return true;
    }
    if (obj instanceof SparseIntArray && ((SparseIntArray) obj).size() == 0) {
        return true;
    }
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR2) {
        if (obj instanceof SparseLongArray && ((SparseLongArray) obj).size() == 0) {
            return true;
        }
    }
    if (obj instanceof LongSparseArray && ((LongSparseArray) obj).size() == 0) {
        return true;
    }
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) {
        if (obj instanceof android.util.LongSparseArray && ((android.util.LongSparseArray) obj).size() == 0) {
            return true;
        }
    }
    return false;
}
项目:AndroidUtilCode    文件:ObjectUtils.java   
/**
 * 判断对象是否为空
 *
 * @param obj 对象
 * @return {@code true}: 为空<br>{@code false}: 不为空
 */
public static boolean isEmpty(final Object obj) {
    if (obj == null) {
        return true;
    }
    if (obj instanceof CharSequence && obj.toString().length() == 0) {
        return true;
    }
    if (obj.getClass().isArray() && Array.getLength(obj) == 0) {
        return true;
    }
    if (obj instanceof Collection && ((Collection) obj).isEmpty()) {
        return true;
    }
    if (obj instanceof Map && ((Map) obj).isEmpty()) {
        return true;
    }
    if (obj instanceof SimpleArrayMap && ((SimpleArrayMap) obj).isEmpty()) {
        return true;
    }
    if (obj instanceof SparseArray && ((SparseArray) obj).size() == 0) {
        return true;
    }
    if (obj instanceof SparseBooleanArray && ((SparseBooleanArray) obj).size() == 0) {
        return true;
    }
    if (obj instanceof SparseIntArray && ((SparseIntArray) obj).size() == 0) {
        return true;
    }
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR2) {
        if (obj instanceof SparseLongArray && ((SparseLongArray) obj).size() == 0) {
            return true;
        }
    }
    if (obj instanceof LongSparseArray && ((LongSparseArray) obj).size() == 0) {
        return true;
    }
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) {
        if (obj instanceof android.util.LongSparseArray
                && ((android.util.LongSparseArray) obj).size() == 0) {
            return true;
        }
    }
    return false;
}
项目:AndroidUtilCode    文件:ObjectUtilsTest.java   
@Test
public void isEmpty() throws Exception {
    StringBuilder sb = new StringBuilder("");
    StringBuilder sb1 = new StringBuilder(" ");
    String string = "";
    String string1 = " ";
    int[][] arr = new int[][]{};
    LinkedList<Integer> list = new LinkedList<>();
    HashMap<String, Integer> map = new HashMap<>();
    SimpleArrayMap<String, Integer> sam = new SimpleArrayMap<>();
    SparseArray<String> sa = new SparseArray<>();
    SparseBooleanArray sba = new SparseBooleanArray();
    SparseIntArray sia = new SparseIntArray();
    SparseLongArray sla = new SparseLongArray();
    LongSparseArray<String> lsa = new LongSparseArray<>();
    android.util.LongSparseArray<String> lsaV4 = new android.util.LongSparseArray<>();

    assertTrue(ObjectUtils.isEmpty(sb));
    assertFalse(ObjectUtils.isEmpty(sb1));
    assertTrue(ObjectUtils.isEmpty(string));
    assertFalse(ObjectUtils.isEmpty(string1));
    assertTrue(ObjectUtils.isEmpty(arr));
    assertTrue(ObjectUtils.isEmpty(list));
    assertTrue(ObjectUtils.isEmpty(map));
    assertTrue(ObjectUtils.isEmpty(sam));
    assertTrue(ObjectUtils.isEmpty(sa));
    assertTrue(ObjectUtils.isEmpty(sba));
    assertTrue(ObjectUtils.isEmpty(sia));
    assertTrue(ObjectUtils.isEmpty(sla));
    assertTrue(ObjectUtils.isEmpty(lsa));
    assertTrue(ObjectUtils.isEmpty(lsaV4));

    assertTrue(!ObjectUtils.isNotEmpty(sb));
    assertFalse(!ObjectUtils.isNotEmpty(sb1));
    assertTrue(!ObjectUtils.isNotEmpty(string));
    assertFalse(!ObjectUtils.isNotEmpty(string1));
    assertTrue(!ObjectUtils.isNotEmpty(arr));
    assertTrue(!ObjectUtils.isNotEmpty(list));
    assertTrue(!ObjectUtils.isNotEmpty(map));
    assertTrue(!ObjectUtils.isNotEmpty(sam));
    assertTrue(!ObjectUtils.isNotEmpty(sa));
    assertTrue(!ObjectUtils.isNotEmpty(sba));
    assertTrue(!ObjectUtils.isNotEmpty(sia));
    assertTrue(!ObjectUtils.isNotEmpty(sla));
    assertTrue(!ObjectUtils.isNotEmpty(lsa));
    assertTrue(!ObjectUtils.isNotEmpty(lsaV4));
}
项目:truth-android    文件:SparseLongArraySubject.java   
protected SparseLongArraySubject(FailureStrategy failureStrategy, SparseLongArray subject) {
  super(failureStrategy, subject);
}
项目:sprockets-android    文件:SparseArrays.java   
/**
 * Get the keys of the SparseLongArray.
 */
public static int[] keys(SparseLongArray array) {
    return (int[]) keys(null, null, null, array, null);
}
项目:sprockets-android    文件:SparseArrays.java   
/**
 * Get the values of the SparseLongArray.
 */
public static long[] values(SparseLongArray array) {
    return (long[]) values(null, null, null, array, null);
}
项目:sprockets-android    文件:SparseArrays.java   
private static int size(SparseArray<?> a, SparseBooleanArray b, SparseIntArray c,
                        SparseLongArray d, LongSparseArray<?> e) {
    return a != null ? a.size()
            : b != null ? b.size() : c != null ? c.size() : d != null ? d.size() : e.size();
}
项目:robo-fashion    文件:SparseLongArrayIterableImpl.java   
@Override
public boolean isEqualTo(final SparseLongArray array) {

    int count = 0;

    for (final SparseLongArrayEntry entry : this) {

        final long value = array.get(entry.getKey());

        if (entry.getValue() != value) {

            return false;
        }

        ++count;
    }

    return (count == array.size());
}
项目:robo-fashion    文件:SparseLongArrayTest.java   
public void testEquals() {

        if (VERSION.SDK_INT < VERSION_CODES.JELLY_BEAN_MR2) {

            return;
        }

        final SparseLongArray array = new SparseLongArray();

        for (int i = 0; i < 5; i++) {

            array.append(i, i);
        }

        assertThat(SparseCollections.iterate(mArray)
                                    .isStrictlyEqualTo(SparseCollections.iterate(array))).isTrue();
        assertThat(SparseCollections.iterate(array)
                                    .isStrictlyEqualTo(SparseCollections.iterate(mArray))).isTrue();
        assertThat(SparseCollections.iterate(array)
                                    .only()
                                    .key(2)
                                    .remove()
                                    .isStrictlyEqualTo(
                                            SparseCollections.iterate(mArray))).isFalse();
        assertThat(SparseCollections.iterate(mArray)
                                    .isStrictlyEqualTo(SparseCollections.iterate(array))).isFalse();

        final SparseLongArray sparseArray = SparseCollections.iterate(mArray).toSparseArray();
        assertThat(SparseCollections.iterate(mArray).isEqualTo(mArray)).isTrue();
        assertThat(SparseCollections.iterate(mArray).only().first(2).isEqualTo(mArray)).isFalse();
        assertThat(SparseCollections.iterate(mArray).isEqualTo(sparseArray)).isTrue();
        assertThat(
                SparseCollections.iterate(mArray).only().first(2).isEqualTo(sparseArray)).isFalse();

        final ArrayList<IntSparseLongEntry> list =
                SparseCollections.iterate(mArray).toImmutableList();
        assertThat(SparseCollections.iterate(mArray).isEqualTo(list)).isTrue();
        assertThat(SparseCollections.iterate(mArray).only().first(2).isEqualTo(list)).isFalse();

        final ArrayList<ParcelableIntSparseLongEntry> parcelableList =
                SparseCollections.iterate(mArray).toParcelableList();
        assertThat(SparseCollections.iterate(mArray).isEqualTo(parcelableList)).isTrue();
        assertThat(SparseCollections.iterate(mArray)
                                    .only()
                                    .first(2)
                                    .isEqualTo(parcelableList)).isFalse();

        final Map<Integer, Long> map = SparseCollections.iterate(mArray).toMap();
        assertThat(SparseCollections.iterate(mArray).isEqualTo(map)).isTrue();
        assertThat(SparseCollections.iterate(mArray).only().first(2).isEqualTo(map)).isFalse();

        final SortedMap<Integer, Long> sortedMap = SparseCollections.iterate(mArray).toSortedMap();
        assertThat(SparseCollections.iterate(mArray).isEqualTo(sortedMap)).isTrue();
        assertThat(
                SparseCollections.iterate(mArray).only().first(2).isEqualTo(sortedMap)).isFalse();

        mArray.append(7, 7L);
        assertThat(SparseCollections.iterate(mArray).isEqualTo(sparseArray)).isFalse();
        assertThat(SparseCollections.iterate(mArray).but().last(1).isEqualTo(sparseArray)).isTrue();
        assertThat(SparseCollections.iterate(mArray).isEqualTo(list)).isFalse();
        assertThat(SparseCollections.iterate(mArray).but().last(1).isEqualTo(list)).isTrue();
        assertThat(SparseCollections.iterate(mArray).isEqualTo(parcelableList)).isFalse();
        assertThat(
                SparseCollections.iterate(mArray).but().last(1).isEqualTo(parcelableList)).isTrue();
        assertThat(SparseCollections.iterate(mArray).isEqualTo(map)).isFalse();
        assertThat(SparseCollections.iterate(mArray).but().last(1).isEqualTo(map)).isTrue();
        assertThat(SparseCollections.iterate(mArray).isEqualTo(sortedMap)).isFalse();
        assertThat(SparseCollections.iterate(mArray).but().last(1).isEqualTo(sortedMap)).isTrue();
    }
项目:robo-fashion    文件:SparseLongArrayTest.java   
@Override
protected void setUp() throws Exception {

    super.setUp();

    if (VERSION.SDK_INT < VERSION_CODES.JELLY_BEAN_MR2) {

        return;
    }

    final SparseLongArray array = new SparseLongArray();

    for (int i = 0; i < 5; i++) {

        array.append(i, i);
    }

    mArray = array;
}
项目:assertj-android    文件:SparseLongArrayAssert.java   
public SparseLongArrayAssert(SparseLongArray actual) {
  super(actual, SparseLongArrayAssert.class);
}
项目:robo-fashion    文件:SparseLongArrayIterableImpl.java   
@Override
public SparseLongArrayIterable appendTo(final SparseLongArray other) {

    for (final SparseLongArrayEntry entry : this) {

        other.append(entry.getKey(), entry.getValue());
    }

    return this;
}
项目:robo-fashion    文件:SparseLongArrayIterableImpl.java   
@Override
public SparseLongArrayIterable putInto(final SparseLongArray other) {

    for (final SparseLongArrayEntry entry : this) {

        other.put(entry.getKey(), entry.getValue());
    }

    return this;
}
项目:robo-fashion    文件:SparseLongArrayIterableImpl.java   
@Override
public SparseLongArrayIterable replaceValues(final LongTranslator translator) {

    final SparseLongArray array = mArray;

    for (final SparseLongArrayEntry entry : this) {

        array.append(entry.getKey(), translator.translate(entry.getValue()));
    }

    return this;
}
项目:robo-fashion    文件:SparseLongArrayIterableImpl.java   
@Override
public SparseLongArray toSparseArray() {

    final SparseLongArray array = new SparseLongArray();

    for (final SparseLongArrayEntry entry : this) {

        array.append(entry.getKey(), entry.getValue());
    }

    return array;
}
项目:robo-fashion    文件:SparseCollections.java   
/**
 * Wraps the specified {@link android.util.SparseLongArray} into an iterable.
 *
 * @param sparseArray the sparse array to wrap.
 * @return the iterable instance.
 */
public static SparseLongArrayIterable iterate(final SparseLongArray sparseArray) {

    return AndroidIterableFactory.create(sparseArray);
}
项目:robo-fashion    文件:SparseLongArrayIterator.java   
public SparseLongArrayIterator(final SparseLongArray array) {

        super(array.size());

        mSparseArray = array;
    }
项目:robo-fashion    文件:SparseLongArrayIterableImpl.java   
public SparseLongArrayIterableImpl(final SparseLongArray array) {

        mArray = array;
    }
项目:robo-fashion    文件:AndroidIterableFactory.java   
/**
 * Wraps the specified {@link android.util.SparseLongArray} into an iterable.
 *
 * @param sparseArray the sparse array to wrap.
 * @return the iterable instance.
 */
public static SparseLongArrayIterable create(final SparseLongArray sparseArray) {

    return new SparseLongArrayIterableImpl(sparseArray);
}