本文整理汇总了Java中android.util.SparseArray.size方法的典型用法代码示例。如果您正苦于以下问题:Java SparseArray.size方法的具体用法?Java SparseArray.size怎么用?Java SparseArray.size使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类android.util.SparseArray
的用法示例。
在下文中一共展示了SparseArray.size方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: detectTextBlocks
import android.util.SparseArray; //导入方法依赖的package包/类
List<TextBlock> detectTextBlocks(UQI uqi) {
List<TextBlock> result = new ArrayList<>();
Bitmap bitmap = this.getBitmap(uqi);
if (bitmap == null) return result;
TextRecognizer textRecognizer = new TextRecognizer.Builder(uqi.getContext()).build();
if (!textRecognizer.isOperational()) {
Logging.warn("TextRecognizer is not operational");
textRecognizer.release();
return result;
}
Frame imageFrame = new Frame.Builder().setBitmap(bitmap).build();
SparseArray<TextBlock> textBlocks = textRecognizer.detect(imageFrame);
for (int i = 0; i < textBlocks.size(); i++) {
TextBlock textBlock = textBlocks.get(textBlocks.keyAt(i));
result.add(textBlock);
}
textRecognizer.release();
return result;
}
示例2: getNextFragmentRun
import android.util.SparseArray; //导入方法依赖的package包/类
/**
* Returns the {@link TrackBundle} whose fragment run has the earliest file position out of those
* yet to be consumed, or null if all have been consumed.
*/
private static TrackBundle getNextFragmentRun(SparseArray<TrackBundle> trackBundles) {
TrackBundle nextTrackBundle = null;
long nextTrackRunOffset = Long.MAX_VALUE;
int trackBundlesSize = trackBundles.size();
for (int i = 0; i < trackBundlesSize; i++) {
TrackBundle trackBundle = trackBundles.valueAt(i);
if (trackBundle.currentSampleIndex == trackBundle.fragment.length) {
// This track fragment contains no more runs in the next mdat box.
} else {
long trunOffset = trackBundle.fragment.dataPosition;
if (trunOffset < nextTrackRunOffset) {
nextTrackBundle = trackBundle;
nextTrackRunOffset = trunOffset;
}
}
}
return nextTrackBundle;
}
示例3: receiveDetections
import android.util.SparseArray; //导入方法依赖的package包/类
/**
* Called by the detector to deliver detection results.
* If your application called for it, this could be a place to check for
* equivalent detections by tracking TextBlocks that are similar in location and content from
* previous frames, or reduce noise by eliminating TextBlocks that have not persisted through
* multiple detections.
*/
@Override
public void receiveDetections(Detector.Detections<TextBlock> detections) {
mGraphicOverlay.clear();
SparseArray<TextBlock> items = detections.getDetectedItems();
for (int i = 0; i < items.size(); ++i) {
TextBlock item = items.valueAt(i);
if (item != null && item.getValue() != null) {
if (item.getValue().contains("INSTITUTO FEDERAL ELECTORAL")) {
documentIdentifier.setType(Constants.IFEB);
} else if (item.getValue().contains("INSTITUTO NACIONAL ELECTORAL")) {
Log.d("OcrDetectorProcessor", "INE E " + item.getValue());
documentIdentifier.setType(Constants.IFEE);
}
}
//OcrGraphic graphic = new OcrGraphic(mGraphicOverlay, item);
//mGraphicOverlay.add(graphic);
}
}
示例4: 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;
}
示例5: cleanHuaWeiNotifications
import android.util.SparseArray; //导入方法依赖的package包/类
@Override
public boolean cleanHuaWeiNotifications() {
Context context = DemoCache.getContext();
NotificationManager manager = (NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE);
if (manager != null) {
manager.cancelAll();
SparseArray<Notification> nos = DemoCache.getNotifications();
if (nos != null) {
int key = 0;
for (int i = 0; i < nos.size(); i++) {
key = nos.keyAt(i);
manager.notify(key, nos.get(key));
}
}
}
return true;
}
示例6: 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;
}
}
示例7: getActiveList
import android.util.SparseArray; //导入方法依赖的package包/类
@SuppressWarnings("unchecked")
private static List<Fragment> getActiveList(SparseArray<Fragment> active) {
if (active == null) {
return Collections.EMPTY_LIST;
}
final int count = active.size();
ArrayList<Fragment> fragments = new ArrayList<>(count);
for (int i = 0; i < count; i++) {
fragments.add(active.valueAt(i));
}
return fragments;
}
示例8: ensureFragmentsAreInitialized
import android.util.SparseArray; //导入方法依赖的package包/类
private void ensureFragmentsAreInitialized(SparseArray<Fragment> lastInFragments) {
int count = lastInFragments.size();
for (int i = 0; i < count; i++) {
Fragment fragment = (Fragment) lastInFragments.valueAt(i);
if (fragment.mState < 1) {
this.mManager.makeActive(fragment);
this.mManager.moveToState(fragment, 1, 0, 0, false);
}
}
}
示例9: 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);
}
示例10: getSortOrderEntries
import android.util.SparseArray; //导入方法依赖的package包/类
static protected CharSequence[] getSortOrderEntries(Context context, SparseArray<MoviesSortOrderEntry> indexer) {
List<CharSequence> entries = new ArrayList<>();
for (int index=0; index<indexer.size(); index++) {
entries.add(context.getResources().getString(indexer.get(index).mId));
}
return entries.toArray(new CharSequence[entries.size()]);
}
示例11: 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;
}
}
}
}
}
示例12: updateDialogsWithReadMessages
import android.util.SparseArray; //导入方法依赖的package包/类
public void updateDialogsWithReadMessages(final SparseArray<Long> inbox, final SparseArray<Long> outbox, boolean useQueue) {
if (inbox.size() == 0) {
return;
}
if (useQueue) {
storageQueue.postRunnable(new Runnable() {
@Override
public void run() {
updateDialogsWithReadMessagesInternal(null, inbox, outbox);
}
});
} else {
updateDialogsWithReadMessagesInternal(null, inbox, outbox);
}
}
示例13: resetPayloadReaders
import android.util.SparseArray; //导入方法依赖的package包/类
private void resetPayloadReaders() {
trackIds.clear();
tsPayloadReaders.clear();
SparseArray<TsPayloadReader> initialPayloadReaders =
payloadReaderFactory.createInitialPayloadReaders();
int initialPayloadReadersSize = initialPayloadReaders.size();
for (int i = 0; i < initialPayloadReadersSize; i++) {
tsPayloadReaders.put(initialPayloadReaders.keyAt(i), initialPayloadReaders.valueAt(i));
}
tsPayloadReaders.put(TS_PAT_PID, new SectionReader(new PatReader()));
id3Reader = null;
}
示例14: addViewsInSection
import android.util.SparseArray; //导入方法依赖的package包/类
private void addViewsInSection(SparseArray<View> items, LinearLayout parent, int itemWidth) {
for (int i = 0; i < items.size(); i++) {
View itemView = items.get(i);
setItemWidth(itemView, itemWidth);
parent.addView(itemView);
}
}
示例15: getSessionCount
import android.util.SparseArray; //导入方法依赖的package包/类
private static int getSessionCount(SparseArray<PackageInstallerSession> sessions,
int installerUid) {
int count = 0;
final int size = sessions.size();
for (int i = 0; i < size; i++) {
final PackageInstallerSession session = sessions.valueAt(i);
if (session.installerUid == installerUid) {
count++;
}
}
return count;
}