本文整理汇总了Java中android.util.LongSparseArray.keyAt方法的典型用法代码示例。如果您正苦于以下问题:Java LongSparseArray.keyAt方法的具体用法?Java LongSparseArray.keyAt怎么用?Java LongSparseArray.keyAt使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类android.util.LongSparseArray
的用法示例。
在下文中一共展示了LongSparseArray.keyAt方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getCheckedItemIds
import android.util.LongSparseArray; //导入方法依赖的package包/类
/**
* 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} and the adapter
* has stable IDs. ({@link ListAdapter#hasStableIds()} == {@code true})
*
* @return A new array which contains the id of each checked item in the
* list.
*/
public long[] getCheckedItemIds() {
if (mChoiceMode == AbsListView.CHOICE_MODE_NONE
|| mCheckedIdStates == null || mAdapter == null) {
return new long[0];
}
final LongSparseArray<Integer> idStates = mCheckedIdStates;
final int count = idStates.size();
final long[] ids = new long[count];
for (int i = 0; i < count; i++) {
ids[i] = idStates.keyAt(i);
}
return ids;
}
示例2: read
import android.util.LongSparseArray; //导入方法依赖的package包/类
@Override
public LongSparseArray<T> read(JsonReader jsonReader) throws IOException {
if (jsonReader.peek() == JsonToken.NULL) {
jsonReader.nextNull();
return null;
}
LongSparseArray<Object> temp = gson.fromJson(jsonReader, typeOfLongSparseArrayOfObject);
LongSparseArray<T> result = new LongSparseArray<>(temp.size());
long key;
JsonElement tElement;
for (int i = 0, size = temp.size(); i < size; ++i) {
key = temp.keyAt(i);
tElement = gson.toJsonTree(temp.get(key));
result.put(key, (T) JSONUtils.jsonToSimpleObject(tElement.toString(), typeOfT));
}
return result;
}
示例3: getCheckedItemIds
import android.util.LongSparseArray; //导入方法依赖的package包/类
/**
* Returns the set of checked items ids. The result is only valid if the
* choice mode has not been set to {@link AbsListView#CHOICE_MODE_NONE} and the adapter
* has stable IDs. ({@link ListAdapter#hasStableIds()} == {@code true})
*
* @return A new array which contains the id of each checked item in the
* list.
*/
public long[] getCheckedItemIds() {
if (mChoiceMode == AbsListView.CHOICE_MODE_NONE || mCheckedIdStates == null) {
return new long[0];
}
final LongSparseArray<Integer> idStates = mCheckedIdStates;
final int count = idStates.size();
final long[] ids = new long[count];
for (int i = 0; i < count; i++) {
ids[i] = idStates.keyAt(i);
}
return ids;
}
示例4: CcDrawableCache
import android.util.LongSparseArray; //导入方法依赖的package包/类
public CcDrawableCache(Context context, LongSparseArray<Drawable.ConstantState> cache) {
mResources = context.getApplicationContext().getResources();
mPackageName = context.getApplicationContext().getPackageName();
if (cache != null) {
mCheckDependenciesKeys = new HashSet<>(cache.size());
int N = cache.size();
for (int i = 0; i < N; i++) {
long key = cache.keyAt(i);
mCheckDependenciesKeys.add(key);
put(key, cache.valueAt(i));
}
} else {
mCheckDependenciesKeys = new HashSet<>(0);
}
}
示例5: CcColorCache
import android.util.LongSparseArray; //导入方法依赖的package包/类
public CcColorCache(Context context, LongSparseArray cache) {
mResources = context.getApplicationContext().getResources();
mPackageName = context.getApplicationContext().getPackageName();
if (cache != null) {
mCheckDependenciesKeys = new HashSet<>(cache.size());
int N = cache.size();
for (int i = 0; i < N; i++) {
long key = cache.keyAt(i);
mCheckDependenciesKeys.add(key);
put(key, cache.valueAt(i));
}
} else {
mCheckDependenciesKeys = new HashSet<>(0);
}
}
示例6: getCheckedItemIds
import android.util.LongSparseArray; //导入方法依赖的package包/类
/**
* 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} and the adapter
* has stable IDs. ({@link ListAdapter#hasStableIds()} == {@code true})
*
* @return A new array which contains the id of each checked item in the
* list.
*/
public long[] getCheckedItemIds() {
if (mChoiceMode.compareTo(ChoiceMode.NONE) == 0 ||
mCheckedIdStates == null || mAdapter == null) {
return new long[0];
}
final LongSparseArray<Integer> idStates = mCheckedIdStates;
final int count = idStates.size();
final long[] ids = new long[count];
for (int i = 0; i < count; i++) {
ids[i] = idStates.keyAt(i);
}
return ids;
}
示例7: keys
import android.util.LongSparseArray; //导入方法依赖的package包/类
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;
}