本文整理匯總了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;
}