本文整理汇总了Java中android.util.SparseArray.valueAt方法的典型用法代码示例。如果您正苦于以下问题:Java SparseArray.valueAt方法的具体用法?Java SparseArray.valueAt怎么用?Java SparseArray.valueAt使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类android.util.SparseArray
的用法示例。
在下文中一共展示了SparseArray.valueAt方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: 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) {
final String wort = item.getValue();
if(wort.length() > 1 && Character.isUpperCase(wort.charAt(0)) && wort.matches("[A-Za-z-]+") && wort.charAt(wort.length() - 1) != '-') {
Log.d("OCR", "Name detected: " + wort);
// Show AccountDetailActivity
new Thread(new Runnable() {
@Override
public void run() {
DownloadIntentService.startService(context, OcrCaptureActivity.DOWNLOAD_REQUEST_CODE, wort);
}
}).start();
} else {
Log.d("OcrDetectorProcessor", "Text detected! " + item.getValue());
}
}
}
}
示例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: 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;
}
}
示例4: 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.currentTrackRunIndex == trackBundle.fragment.trunCount) {
// This track fragment contains no more runs in the next mdat box.
} else {
long trunOffset = trackBundle.fragment.trunDataPosition[trackBundle.currentTrackRunIndex];
if (trunOffset < nextTrackRunOffset) {
nextTrackBundle = trackBundle;
nextTrackRunOffset = trunOffset;
}
}
}
return nextTrackBundle;
}
示例5: receiveDetections
import android.util.SparseArray; //导入方法依赖的package包/类
@Override
public void receiveDetections(Detector.Detections<TextBlock> detections) {
SparseArray<TextBlock> items = detections.getDetectedItems();
for (int i = 0; i < items.size(); ++i) {
TextBlock item = items.valueAt(i);
if (item != null && item.getValue() != null) {
Log.d("Processor", "Text detected! " + item.getValue());
}
}
}
示例6: getRawDataToIndex
import android.util.SparseArray; //导入方法依赖的package包/类
@Override
public List<SearchIndexableRaw> getRawDataToIndex(Context context, boolean enabled) {
final SparseArray<String> keyTitles = allKeyTitles(context);
final int N = keyTitles.size();
final List<SearchIndexableRaw> result = new ArrayList<SearchIndexableRaw>(N);
final Resources res = context.getResources();
for (int i = 0; i < N; i++) {
final SearchIndexableRaw data = new SearchIndexableRaw(context);
data.key = keyTitles.valueAt(i);
data.title = res.getString(keyTitles.keyAt(i));
data.screenTitle = res.getString(R.string.zen_mode_settings_title);
result.add(data);
}
return result;
}
示例7: dropView
import android.util.SparseArray; //导入方法依赖的package包/类
@Override
protected void dropView(View view) {
super.dropView(view);
// As a result of removeClippedSubviews, some views have strong references but are not attached
// to a parent. consequently, when the parent gets removed, these Views don't get cleaned up,
// because they aren't children (they also aren't removed from mTagsToViews, thus causing a
// leak). To solve this, we ask for said detached views and explicitly drop them.
if (view instanceof FlatViewGroup) {
FlatViewGroup flatViewGroup = (FlatViewGroup) view;
if (flatViewGroup.getRemoveClippedSubviews()) {
SparseArray<View> detachedViews = flatViewGroup.getDetachedViews();
for (int i = 0, size = detachedViews.size(); i < size; i++) {
View detachedChild = detachedViews.valueAt(i);
try {
dropView(detachedChild);
} catch (Exception e) {
// if the view is already dropped, ignore any exceptions
// in reality, we should find out the edge cases that cause
// this to happen and properly fix them.
}
// trigger onDetachedFromWindow and clean up this detached/clipped view
flatViewGroup.removeDetachedView(detachedChild);
}
}
}
}
示例8: 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;
}
示例9: clear
import android.util.SparseArray; //导入方法依赖的package包/类
void clear() {
final SparseArray<View> scrapHeap = mScrapHeap;
final int count = scrapHeap.size();
for (int i = 0; i < count; i++) {
final View view = scrapHeap.valueAt(i);
if (view != null) {
removeDetachedView(view, true);
}
}
scrapHeap.clear();
}
示例10: 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);
}
}
}
示例11: addViewWithAnimation
import android.util.SparseArray; //导入方法依赖的package包/类
synchronized public boolean addViewWithAnimation(final View view, final int position) {
if (mChildrenMeasure.hasPreLayoutView()) {
return false;
}
mChildrenMeasure.addViewStart(view, position);
SparseArray<Layout> layoutSet = mChildrenMeasure.measure().getLayoutSet();
final float alpha = view.getAlpha();
view.setAlpha(0.0f);
requestLayout();
int count = this.getChildCount();
if (count == 0) {
addView(view, position);
addAnimation(view, alpha, new AnimationCallback() {
@Override
public void onEnd() {
mChildrenMeasure.addedViewComplete();
}
});
return true;
}
final List<View> animatedViewList = new ArrayList<>();
for (int i = 0; i < count; i++) {
final View child = this.getChildAt(i);
if (!shouldLayout(child)) {
continue;
}
final Layout layout = layoutSet.valueAt(i);
if (layout == null) {
continue;
}
boolean isAnimated = translateAnimation(child, layout.l, layout.t, new AnimationCallback() {
@Override
public void onEnd() {
layout.applyTo(child);
child.setAnimation(null);
if (animatedViewList.contains(child)) {
animatedViewList.remove(child);
}
if (animatedViewList.isEmpty()) {
mChildrenMeasure.addedViewComplete();
addView(view, position);
addAnimation(view, alpha, new AnimationCallback() {
@Override
public void onEnd() {
}
});
}
}
});
if (isAnimated) {
animatedViewList.add(child);
}
}
return true;
}
示例12: waitAllTaskComplete
import android.util.SparseArray; //导入方法依赖的package包/类
private void waitAllTaskComplete(SparseArray<FutureTask<?>> uploadTaskMap) throws ExecutionException,
InterruptedException {
for (int i = 0; i < uploadTaskMap.size(); i++) {
FutureTask<?> uploadTask = uploadTaskMap.valueAt(i);
try {
// just need block here
Objects result = (Objects) uploadTask.get();
Logger.i("get index:" + i + " result>>>>>>" + result);
} catch (InterruptedException | ExecutionException e) { // executorService shut down
throw e;
}
}
}
示例13: detectFacesandOverlayEmoji
import android.util.SparseArray; //导入方法依赖的package包/类
static Bitmap detectFacesandOverlayEmoji(Context context, Bitmap picture) {
// Create the face detector, disable tracking and enable classifications
FaceDetector detector = new FaceDetector.Builder(context)
.setTrackingEnabled(false)
.setClassificationType(FaceDetector.ALL_CLASSIFICATIONS)
.build();
// Build the frame
Frame frame = new Frame.Builder().setBitmap(picture).build();
// Detect the faces
SparseArray<Face> faces = detector.detect(frame);
// Log the number of faces
Log.d(LOG_TAG, "detectFaces: number of faces = " + faces.size());
// Initialize result bitmap to original picture
Bitmap resultBitmap = picture;
// If there are no faces detected, show a Toast message
if (faces.size() == 0) {
Toast.makeText(context, R.string.no_faces_message, Toast.LENGTH_SHORT).show();
} else {
// Loop through the faces
for (int i = 0; i < faces.size(); ++i) {
Face face = faces.valueAt(i);
Bitmap emojiBitmap;
switch (whichEmoji(face)) {
case SMILE:
emojiBitmap = BitmapFactory.decodeResource(context.getResources(),
R.drawable.smile);
break;
case FROWN:
emojiBitmap = BitmapFactory.decodeResource(context.getResources(),
R.drawable.frown);
break;
case LEFT_WINK:
emojiBitmap = BitmapFactory.decodeResource(context.getResources(),
R.drawable.leftwink);
break;
case RIGHT_WINK:
emojiBitmap = BitmapFactory.decodeResource(context.getResources(),
R.drawable.rightwink);
break;
case LEFT_WINK_FROWN:
emojiBitmap = BitmapFactory.decodeResource(context.getResources(),
R.drawable.leftwinkfrown);
break;
case RIGHT_WINK_FROWN:
emojiBitmap = BitmapFactory.decodeResource(context.getResources(),
R.drawable.rightwinkfrown);
break;
case CLOSED_EYE_SMILE:
emojiBitmap = BitmapFactory.decodeResource(context.getResources(),
R.drawable.closed_smile);
break;
case CLOSED_EYE_FROWN:
emojiBitmap = BitmapFactory.decodeResource(context.getResources(),
R.drawable.closed_frown);
break;
default:
emojiBitmap = null;
Toast.makeText(context, R.string.no_emoji, Toast.LENGTH_SHORT).show();
}
// Add the emojiBitmap to the proper position in the original image
resultBitmap = addBitmapToFace(resultBitmap, emojiBitmap, face);
}
}
// Release the detector
detector.release();
return resultBitmap;
}
示例14: submitTasks
import android.util.SparseArray; //导入方法依赖的package包/类
private void submitTasks(ExecutorService executorService, SparseArray<FutureTask<?>> futureTaskMap) {
for (int i = 0; i < futureTaskMap.size(); i++) {
FutureTask<?> task = futureTaskMap.valueAt(i);
executorService.submit(task);
}
}
示例15: scan
import android.util.SparseArray; //导入方法依赖的package包/类
@Override
public BarcodeInfo scan(Bitmap bitmap) {
Frame frame = new Frame.Builder().setBitmap(bitmap).build();
SparseArray<Barcode> barcodes = mBarcodeDetector.detect(frame);
if (barcodes.size() > 0) {
Barcode barcode = barcodes.valueAt(0);
//Convert to the barcode info object
BarcodeInfo barcodeInfo = new BarcodeInfo();
barcodeInfo.setBoundingBox(barcode.getBoundingBox());
barcodeInfo.setRawValue(barcode.rawValue);
//Parse the contact info
barcodeInfo.setContact(parseContactInfo(barcode));
//Parse the url bookmarks
if (barcode.url != null)
barcodeInfo.setUrlBookmark(new BarcodeInfo.UrlBookmark(
barcode.url.title, barcode.url.url));
//Parse the Sms detail
if (barcode.sms != null)
barcodeInfo.setSms(new BarcodeInfo.Sms(barcode.sms.message, barcode.sms.phoneNumber));
//Parse the location detail
if (barcode.geoPoint != null)
barcodeInfo.setGeoPoint(new BarcodeInfo.GeoPoint(barcode.geoPoint.lat,
barcode.geoPoint.lng));
//Parse calender event
barcodeInfo.setCalendarEvent(parseCalenderEvent(barcode));
//Parse only number
if (barcode.phone != null)
barcodeInfo.setPhone(new BarcodeInfo.Phone(barcode.phone.number,
BarcodeScannerUtils.getPhoneTypeString(barcode.phone.type)));
return barcodeInfo;
}
return null;
}