本文整理汇总了Java中android.util.SparseArray.keyAt方法的典型用法代码示例。如果您正苦于以下问题:Java SparseArray.keyAt方法的具体用法?Java SparseArray.keyAt怎么用?Java SparseArray.keyAt使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类android.util.SparseArray
的用法示例。
在下文中一共展示了SparseArray.keyAt方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: retrieveFromScrap
import android.util.SparseArray; //导入方法依赖的package包/类
static View retrieveFromScrap(SparseArray<View> scrapViews, int position) {
int size = scrapViews.size();
if (size > 0) {
// See if we still have a view for this position.
for (int i = 0; i < size; i++) {
int fromPosition = scrapViews.keyAt(i);
View view = scrapViews.get(fromPosition);
if (fromPosition == position) {
scrapViews.remove(fromPosition);
return view;
}
}
int index = size - 1;
View r = scrapViews.valueAt(index);
scrapViews.remove(scrapViews.keyAt(index));
return r;
} else {
return null;
}
}
示例2: getInbandTrackInfo
import android.util.SparseArray; //导入方法依赖的package包/类
private TrackInfo[] getInbandTrackInfo(String encoding) {
if (mInbandTracks == null) {
SparseArray<byte[]> trackSparse = new SparseArray<byte[]>();
if (!native_getTrackInfo(trackSparse)) {
return null;
}
int size = trackSparse.size();
mInbandTracks = new TrackInfo[size];
for (int i = 0; i < size; i++) {
SparseArray<MediaFormat> sparseArray = parseTrackInfo(trackSparse.valueAt(i), encoding);
TrackInfo trackInfo = new TrackInfo(trackSparse.keyAt(i), sparseArray);
mInbandTracks[i] = trackInfo;
}
}
return mInbandTracks;
}
示例3: getSectionForPosition
import android.util.SparseArray; //导入方法依赖的package包/类
public static int getSectionForPosition(int position, SparseArray<String> indexer, int fileListSize) {
// The Android documentation says that position might be out of range
if (position < 0) {
return 0;
}
if (position >= fileListSize) {
return indexer.size();
}
// Check if the position belongs to one of the first (sectionCount - 1) sections
int section = 0;
int sectionCount = indexer.size();
while (section < sectionCount - 1) {
if (position >= indexer.keyAt(section) && position < indexer.keyAt(section + 1)) {
return section;
}
section++;
}
// The position belongs to the last section
return sectionCount - 1;
}
示例4: retrieveFromScrap
import android.util.SparseArray; //导入方法依赖的package包/类
static View retrieveFromScrap(SparseArray<View> scrapViews, int position) {
int size = scrapViews.size();
if (size > 0) {
// See if we still have a view for this position.
for (int i = 0; i < size; i++) {
int fromPosition = scrapViews.keyAt(i);
View view = scrapViews.get(fromPosition);
if (fromPosition == position) {
scrapViews.remove(fromPosition);
return view;
}
}
int index = size - 1;
View r = scrapViews.valueAt(index);
scrapViews.remove(scrapViews.keyAt(index));
return r;
} else {
return null;
}
}
示例5: retrieveFromScrap
import android.util.SparseArray; //导入方法依赖的package包/类
static View retrieveFromScrap(SparseArray<View> scrapViews, int position) {
int size = scrapViews.size();
if (size > 0) {
// See if we still have a view for this position.
for (int i = 0; i < size; i++) {
int fromPosition = scrapViews.keyAt(i);
View view = scrapViews.get(fromPosition);
if (fromPosition == position) {
scrapViews.remove(fromPosition);
return view;
}
}
int index = size - 1;
View r = scrapViews.valueAt(index);
scrapViews.remove(scrapViews.keyAt(index));
return r;
} else {
return null;
}
}
示例6: retrieveFromScrap
import android.util.SparseArray; //导入方法依赖的package包/类
static View retrieveFromScrap(SparseArray<View> scrapViews, int position) {
int size = scrapViews.size();
if (size <= 0) {
return null;
}
for (int i = 0; i < size; i++) {
int fromPosition = scrapViews.keyAt(i);
View view = (View) scrapViews.get(fromPosition);
if (fromPosition == position) {
scrapViews.remove(fromPosition);
return view;
}
}
int index = size - 1;
View r = (View) scrapViews.valueAt(index);
scrapViews.remove(scrapViews.keyAt(index));
return r;
}
示例7: beginTransition
import android.util.SparseArray; //导入方法依赖的package包/类
private TransitionState beginTransition(SparseArray<Fragment> firstOutFragments, SparseArray<Fragment> lastInFragments, boolean isBack) {
int i;
ensureFragmentsAreInitialized(lastInFragments);
TransitionState state = new TransitionState();
state.nonExistentView = new View(this.mManager.mHost.getContext());
boolean anyTransitionStarted = false;
for (i = 0; i < firstOutFragments.size(); i++) {
if (configureTransitions(firstOutFragments.keyAt(i), state, isBack, firstOutFragments, lastInFragments)) {
anyTransitionStarted = true;
}
}
for (i = 0; i < lastInFragments.size(); i++) {
int containerId = lastInFragments.keyAt(i);
if (firstOutFragments.get(containerId) == null && configureTransitions(containerId, state, isBack, firstOutFragments, lastInFragments)) {
anyTransitionStarted = true;
}
}
if (anyTransitionStarted) {
return state;
}
return null;
}
示例8: addToHistogram
import android.util.SparseArray; //导入方法依赖的package包/类
private void addToHistogram(
SparseArray<Integer> histogram,
DiskStorage.DiskDumpInfoEntry entry) {
for (int i = 0; i < histogram.size(); i++) {
int key = histogram.keyAt(i);
if (entry.size / KB < key) {
histogram.put(key, histogram.get(key) + 1);
return;
}
}
// big
histogram.put((int) (entry.size / KB), 1);
}
示例9: printHistogram
import android.util.SparseArray; //导入方法依赖的package包/类
private void printHistogram(PrintStream writer, SparseArray<Integer> histogram) {
writer.println();
writer.println("File Size Counts:");
for (int i = 1; i < histogram.size(); i++) {
int lb = histogram.keyAt(i - 1);
int ub = histogram.keyAt(i);
writer.println(formatStrLocaleSafe("%4d-%4dK: %3d", lb, ub, histogram.get(ub)));
}
}
示例10: read
import android.util.SparseArray; //导入方法依赖的package包/类
@Override
public SparseArray<T> read(JsonReader jsonReader) throws IOException {
if (jsonReader.peek() == JsonToken.NULL) {
jsonReader.nextNull();
return null;
}
SparseArray<Object> temp = gson.fromJson(jsonReader, typeOfSparseArrayOfObject);
SparseArray<T> result = new SparseArray<>(temp.size());
int 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;
}
示例11: getPositionForSection
import android.util.SparseArray; //导入方法依赖的package包/类
public static int getPositionForSection(int sectionIndex, SparseArray<String> indexer, int fileListSize, String[] sections) {
// The Android documentation says that sectionIndex might be out of range
int size = indexer.size();
if (sectionIndex < 0) {
return 0;
}
if (sectionIndex >= size) {
return fileListSize;
}
String letter = sections[sectionIndex];
int index = indexer.indexOfValue(letter);
return indexer.keyAt(index);
}
示例12: didReceivedNotification
import android.util.SparseArray; //导入方法依赖的package包/类
@SuppressWarnings("unchecked")
@Override
public void didReceivedNotification(int id, Object... args) {
if (id == NotificationCenter.messagesDeleted) {
if (currentMessageObject == null) {
return;
}
int channelId = (Integer) args[1];
if (channelId != 0) {
return;
}
ArrayList<Integer> markAsDeletedMessages = (ArrayList<Integer>)args[0];
if (markAsDeletedMessages.contains(currentMessageObject.getId())) {
closePhoto();
}
} else if (id == NotificationCenter.didCreatedNewDeleteTask) {
if (currentMessageObject == null || secretDeleteTimer == null) {
return;
}
SparseArray<ArrayList<Integer>> mids = (SparseArray<ArrayList<Integer>>)args[0];
for(int i = 0; i < mids.size(); i++) {
int key = mids.keyAt(i);
ArrayList<Integer> arr = mids.get(key);
for (Integer mid : arr) {
if (currentMessageObject.getId() == mid) {
currentMessageObject.messageOwner.destroyTime = key;
secretDeleteTimer.invalidate();
return;
}
}
}
}
}
示例13: sortOrder2Item
import android.util.SparseArray; //导入方法依赖的package包/类
static protected int sortOrder2Item(String sortOrder, SparseArray<MoviesSortOrderEntry> indexer) {
int item = -1;
for (int i=0 ; i<indexer.size(); i++) {
if (indexer.get(i).mSortOrder.equals(sortOrder)) {
item = indexer.keyAt(i);
break;
}
}
return Math.max(item, 0);
}
示例14: selectOrDeselectBandTrack
import android.util.SparseArray; //导入方法依赖的package包/类
private void selectOrDeselectBandTrack(int index, boolean select) {
if (mOutOfBandTracks != null) {
SparseArray<MediaFormat> mediaSparse = mOutOfBandTracks.getTrackInfoArray();
int trackIndex = mediaSparse.keyAt(0);
MediaFormat mediaFormat = mediaSparse.valueAt(0);
if (index == trackIndex && select) {
addTimedTextSource(mediaFormat.getString(MediaFormat.KEY_PATH));
return;
}
}
selectOrDeselectTrack(index, select);
}
示例15: removeDuplicates
import android.util.SparseArray; //导入方法依赖的package包/类
/**
* Remove the duplicates from a list of note fields and tags
*
* @param fields List of fields to remove duplicates from
* @param tags List of tags to remove duplicates from
* @param modelId ID of model to search for duplicates on
*/
public void removeDuplicates(LinkedList<String[]> fields, LinkedList<Set<String>> tags, long modelId) {
// Build a list of the duplicate keys (first fields) and find all notes that have a match with each key
List<String> keys = new ArrayList<>(fields.size());
for (String[] f : fields) {
keys.add(f[0]);
}
SparseArray<List<NoteInfo>> duplicateNotes = getApi().findDuplicateNotes(modelId, keys);
// Do some sanity checks
if (tags.size() != fields.size()) {
throw new IllegalStateException("List of tags must be the same length as the list of fields");
}
if (duplicateNotes.size() == 0 || fields.size() == 0 || tags.size() == 0) {
return;
}
if (duplicateNotes.keyAt(duplicateNotes.size() - 1) >= fields.size()) {
throw new IllegalStateException("The array of duplicates goes outside the bounds of the original lists");
}
// Iterate through the fields and tags LinkedLists, removing those that had a duplicate
ListIterator<String[]> fieldIterator = fields.listIterator();
ListIterator<Set<String>> tagIterator = tags.listIterator();
int listIndex = -1;
for (int i = 0; i < duplicateNotes.size(); i++) {
int duplicateIndex = duplicateNotes.keyAt(i);
while (listIndex < duplicateIndex) {
fieldIterator.next();
tagIterator.next();
listIndex++;
}
fieldIterator.remove();
tagIterator.remove();
}
}