本文整理汇总了Java中android.util.SparseArray.indexOfKey方法的典型用法代码示例。如果您正苦于以下问题:Java SparseArray.indexOfKey方法的具体用法?Java SparseArray.indexOfKey怎么用?Java SparseArray.indexOfKey使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类android.util.SparseArray
的用法示例。
在下文中一共展示了SparseArray.indexOfKey方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: floorIndex
import android.util.SparseArray; //导入方法依赖的package包/类
private static int floorIndex(SparseArray<?> sparseArray, int key) {
int index = sparseArray.indexOfKey(key);
if (index < 0) {
index = ~index - 1;
}
return index;
}
示例2: updateTabEntriesFromMetadata
import android.util.SparseArray; //导入方法依赖的package包/类
/**
* Update tab entries based on metadata.
* @param metadataBytes Metadata from last time Chrome was alive.
* @param entryMap Map to fill with {@link DocumentTabModel.Entry}s about Tabs.
* @param recentlyClosedTabIdList List to fill with IDs of recently closed tabs.
*/
private void updateTabEntriesFromMetadata(byte[] metadataBytes, SparseArray<Entry> entryMap,
List<Integer> recentlyClosedTabIdList) {
if (metadataBytes != null) {
DocumentList list = null;
try {
list = MessageNano.mergeFrom(new DocumentList(), metadataBytes);
} catch (IOException e) {
Log.e(TAG, "I/O exception", e);
}
if (list == null) return;
for (int i = 0; i < list.entries.length; i++) {
DocumentEntry savedEntry = list.entries[i];
int tabId = savedEntry.tabId;
// If the tab ID isn't in the list, it must have been closed after Chrome died.
if (entryMap.indexOfKey(tabId) < 0) {
recentlyClosedTabIdList.add(tabId);
continue;
}
// Restore information about the Tab.
entryMap.get(tabId).canGoBack = savedEntry.canGoBack;
}
}
}