当前位置: 首页>>代码示例>>Java>>正文


Java SparseArray类代码示例

本文整理汇总了Java中android.util.SparseArray的典型用法代码示例。如果您正苦于以下问题:Java SparseArray类的具体用法?Java SparseArray怎么用?Java SparseArray使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


SparseArray类属于android.util包,在下文中一共展示了SparseArray类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: extractUrlAndPlay

import android.util.SparseArray; //导入依赖的package包/类
/**
 * Extracts link from youtube video ID, so mediaPlayer can play it
 */
private void extractUrlAndPlay() {
    String youtubeLink = Config.YOUTUBE_BASE_URL + videoItem.getId();
    deviceBandwidthSampler.startSampling();

    new YouTubeExtractor(this) {
        @Override
        protected void onExtractionComplete(SparseArray<YtFile> ytFiles, VideoMeta videoMeta) {
            if (ytFiles == null) {
                // Something went wrong we got no urls. Always check this.
                Toast.makeText(YTApplication.getAppContext(), R.string.failed_playback,
                        Toast.LENGTH_SHORT).show();
                extractUrlAndPlay();

            } else {
                deviceBandwidthSampler.stopSampling();
                YtFile ytFile = getBestStream(ytFiles);
                try {
                    if (mMediaPlayer != null) {
                        mMediaPlayer.reset();
                        mMediaPlayer.setDataSource(ytFile.getUrl());
                        mMediaPlayer.setAudioStreamType(AudioManager.STREAM_MUSIC);
                        mMediaPlayer.prepare();
                        mMediaPlayer.start();
                        handleSeekBarChange(videoItem.getId());
                        sendBroadcast(videoItem.getDuration());
                    }
                } catch (IOException io) {
                    io.printStackTrace();
                }
            }
        }
    }.execute(youtubeLink);
}
 
开发者ID:pawelpaszki,项目名称:youtube_background_android,代码行数:37,代码来源:BackgroundAudioService.java

示例2: 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);
    }
}
 
开发者ID:BrandonVargas,项目名称:AndroidOCRFforID,代码行数:26,代码来源:OcrDetectorProcessor.java

示例3: setSource

import android.util.SparseArray; //导入依赖的package包/类
/**
 * Register an indefinite number of sources that will be asynchronously asked for Elements.
 * This will throw {@code IllegalArgumentException} if any circular dependency is detected.
 * @see ElementSource#dependsOn(ElementSource)
 *
 * @param sources one or more ElementSource.
 */
public void setSource(ElementSource... sources) {
    int count = sources.length;
    allSources = Arrays.asList(sources);
    sourceIdMap = new SparseArray<>(count);
    dependencyMap = new SparseArray<>(count);
    reverseDependencyMap = new SparseArray<>(count);
    groups = new ArrayList<>(count);
    for (int i = 0; i < count; i++) {
        // Assign a unique id to each source, based on its position in the input array.
        sourceIdMap.put(i, sources[i]);
        // Allocate maps for dependencies.
        dependencyMap.put(i, new HashSet<Integer>());
        reverseDependencyMap.put(i, new HashSet<Integer>());
    }

    // Initialize ordered lists.
    computeDependencies();
    computeGroups();
}
 
开发者ID:natario1,项目名称:Elements,代码行数:27,代码来源:ElementAdapter.java

示例4: printActive

import android.util.SparseArray; //导入依赖的package包/类
private void printActive(){
    try {
        Field field = getFragmentManager().getClass().getDeclaredField("mActive");
        field.setAccessible(true);
        SparseArray<Fragment>  active = (SparseArray<Fragment>) field.get(getFragmentManager());
        System.out.println();


        Method method = getFragmentManager().getClass().getDeclaredMethod("getActiveFragments");
        method.setAccessible(true);
        List<Fragment> fragments = (List<Fragment>) method.invoke(getFragmentManager());
        Log.p("mActive", Utils.joinCollections(fragments, ", "));
    } catch (Exception e){

    }
}
 
开发者ID:myl2ning,项目名称:fragmentnav,代码行数:17,代码来源:FmEnter.java

示例5: 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;
}
 
开发者ID:JackChan1999,项目名称:letv,代码行数:23,代码来源:BackStackRecord.java

示例6: deleteTimer

import android.util.SparseArray; //导入依赖的package包/类
@ReactMethod
public void deleteTimer(ExecutorToken executorToken, int timerId) {
  synchronized (mTimerGuard) {
    SparseArray<Timer> timersForContext = mTimerIdsToTimers.get(executorToken);
    if (timersForContext == null) {
      return;
    }
    Timer timer = timersForContext.get(timerId);
    if (timer == null) {
      return;
    }
    // We may have already called/removed it
    timersForContext.remove(timerId);
    if (timersForContext.size() == 0) {
      mTimerIdsToTimers.remove(executorToken);
    }
    mTimers.remove(timer);
  }
}
 
开发者ID:qq565999484,项目名称:RNLearn_Project1,代码行数:20,代码来源:Timing.java

示例7: 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;
  }
}
 
开发者ID:LineChen,项目名称:Week_Calendar,代码行数:21,代码来源:RecycleBin.java

示例8: BadgeRenderer

import android.util.SparseArray; //导入依赖的package包/类
public BadgeRenderer(Context context, int iconSizePx) {
    mContext = context;

    Resources res = context.getResources();
    mSize = (int) (SIZE_PERCENTAGE * iconSizePx);
    mCharSize = (int) (CHAR_SIZE_PERCENTAGE * iconSizePx);
    mOffset = (int) (OFFSET_PERCENTAGE * iconSizePx);
    mStackOffsetX = (int) (STACK_OFFSET_PERCENTAGE_X * iconSizePx);
    mStackOffsetY = (int) (STACK_OFFSET_PERCENTAGE_Y * iconSizePx);
    mTextPaint.setTextSize(iconSizePx * TEXT_SIZE_PERCENTAGE);
    mTextPaint.setTextAlign(Paint.Align.CENTER);
    mLargeIconDrawer = new IconDrawer(res.getDimensionPixelSize(R.dimen.badge_small_padding));
    mSmallIconDrawer = new IconDrawer(res.getDimensionPixelSize(R.dimen.badge_large_padding));
    // Measure the text height.
    Rect tempTextHeight = new Rect();
    mTextPaint.getTextBounds("0", 0, 1, tempTextHeight);
    mTextHeight = tempTextHeight.height();

    mBackgroundsWithShadow = new SparseArray<>(3);
}
 
开发者ID:enricocid,项目名称:LaunchEnr,代码行数:21,代码来源:BadgeRenderer.java

示例9: didAddedNewTask

import android.util.SparseArray; //导入依赖的package包/类
public void didAddedNewTask(final int minDate, final SparseArray<ArrayList<Integer>> mids) {
    Utilities.stageQueue.postRunnable(new Runnable() {
        @Override
        public void run() {
            if (currentDeletingTaskMids == null && !gettingNewDeleteTask || currentDeletingTaskTime != 0 && minDate < currentDeletingTaskTime) {
                getNewDeleteTask(null);
            }
        }
    });
    AndroidUtilities.runOnUIThread(new Runnable() {
        @Override
        public void run() {
            NotificationCenter.getInstance().postNotificationName(NotificationCenter.didCreatedNewDeleteTask, mids);
        }
    });
}
 
开发者ID:pooyafaroka,项目名称:PlusGram,代码行数:17,代码来源:MessagesController.java

示例10: findAnotherInfoFromCompare

import android.util.SparseArray; //导入依赖的package包/类
@Test
public void findAnotherInfoFromCompare() {
    final SparseArray<DownloadTask> unStoredTasks = new SparseArray<>();
    final SparseArray<BreakpointInfo> storedInfos = new SparseArray<>();
    storeOnCache = new BreakpointStoreOnCache(storedInfos,
            new HashMap<String, String>(),
            unStoredTasks,
            new ArrayList<Integer>());

    final BreakpointInfo info1 = mock(BreakpointInfo.class);
    final BreakpointInfo info2 = mock(BreakpointInfo.class);
    final DownloadTask task = mock(DownloadTask.class);

    storedInfos.put(insertedId, info1);

    doReturn(true).when(info1).isSameFrom(task);
    doReturn(false).when(info2).isSameFrom(task);

    BreakpointInfo result = storeOnCache.findAnotherInfoFromCompare(task, info1);
    assertThat(result).isNull();
    result = storeOnCache.findAnotherInfoFromCompare(task, info2);
    assertThat(result).isEqualToComparingFieldByField(info1);
}
 
开发者ID:lingochamp,项目名称:okdownload,代码行数:24,代码来源:BreakpointStoreOnCacheTest.java

示例11: BasePool

import android.util.SparseArray; //导入依赖的package包/类
/**
 * Creates a new instance of the pool.
 * @param poolParams pool parameters
 * @param poolStatsTracker
 */
public BasePool(
    MemoryTrimmableRegistry memoryTrimmableRegistry,
    PoolParams poolParams,
    PoolStatsTracker poolStatsTracker) {
  mMemoryTrimmableRegistry = Preconditions.checkNotNull(memoryTrimmableRegistry);
  mPoolParams = Preconditions.checkNotNull(poolParams);
  mPoolStatsTracker = Preconditions.checkNotNull(poolStatsTracker);

  // initialize the buckets
  mBuckets = new SparseArray<Bucket<V>>();
  initBuckets(new SparseIntArray(0));

  mInUseValues = Sets.newIdentityHashSet();

  mFree = new Counter();
  mUsed = new Counter();
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:23,代码来源:BasePool.java

示例12: ensureCachedScrollSelectorValue

import android.util.SparseArray; //导入依赖的package包/类
private void ensureCachedScrollSelectorValue(int selectorIndex) {
    SparseArray<String> cache = mSelectorIndexToStringCache;
    String scrollSelectorValue = cache.get(selectorIndex);
    if (scrollSelectorValue != null) {
        return;
    }
    if (selectorIndex < mMinValue || selectorIndex > mMaxValue) {
        scrollSelectorValue = "";
    } else {
        if (mDisplayedValues != null) {
            int displayedValueIndex = selectorIndex - mMinValue;
            scrollSelectorValue = mDisplayedValues[displayedValueIndex];
        } else {
            scrollSelectorValue = formatNumber(selectorIndex);
        }
    }
    cache.put(selectorIndex, scrollSelectorValue);
}
 
开发者ID:pooyafaroka,项目名称:PlusGram,代码行数:19,代码来源:NumberPicker.java

示例13: dispatchSaveInstanceState

import android.util.SparseArray; //导入依赖的package包/类
private void dispatchSaveInstanceState(Bundle outState) {
    if (mPresenters.isEmpty()) return;

    SparseArray<Parcelable> presenterStates = new SparseArray<Parcelable>();

    for (WeakReference<MenuPresenter> ref : mPresenters) {
        final MenuPresenter presenter = ref.get();
        if (presenter == null) {
            mPresenters.remove(ref);
        } else {
            final int id = presenter.getId();
            if (id > 0) {
                final Parcelable state = presenter.onSaveInstanceState();
                if (state != null) {
                    presenterStates.put(id, state);
                }
            }
        }
    }

    outState.putSparseParcelableArray(PRESENTER_KEY, presenterStates);
}
 
开发者ID:treasure-lau,项目名称:CSipSimple,代码行数:23,代码来源:MenuBuilder.java

示例14: DocumentTabModelImpl

import android.util.SparseArray; //导入依赖的package包/类
/**
 * Construct a DocumentTabModel.
 * @param activityDelegate Delegate to use for accessing the ActivityManager.
 * @param storageDelegate Delegate to use for accessing persistent storage.
 * @param tabCreatorManager Used to create Tabs.
 * @param isIncognito Whether or not the TabList is managing incognito tabs.
 * @param prioritizedTabId ID of the tab to prioritize when loading.
 * @param context Context to use for accessing SharedPreferences.
 */
public DocumentTabModelImpl(ActivityDelegate activityDelegate, StorageDelegate storageDelegate,
        TabCreatorManager tabCreatorManager, boolean isIncognito, int prioritizedTabId,
        Context context) {
    super(isIncognito, false);
    mActivityDelegate = activityDelegate;
    mStorageDelegate = storageDelegate;
    mContext = context;

    mCurrentState = STATE_UNINITIALIZED;
    mTabIdList = new ArrayList<Integer>();
    mEntryMap = new SparseArray<Entry>();
    mHistoricalTabs = new ArrayList<Integer>();

    mLastShownTabId = DocumentUtils.getLastShownTabIdFromPrefs(mContext, isIncognito());

    // Restore the tab list.
    setCurrentState(STATE_READ_RECENT_TASKS_START);
    mStorageDelegate.restoreTabEntries(
            isIncognito, activityDelegate, mEntryMap, mTabIdList, mHistoricalTabs);
    setCurrentState(STATE_READ_RECENT_TASKS_END);
}
 
开发者ID:rkshuai,项目名称:chromium-for-android-56-debug-video,代码行数:31,代码来源:DocumentTabModelImpl.java

示例15: AdRecordStore

import android.util.SparseArray; //导入依赖的package包/类
/**
 * Instantiates a new Bluetooth LE device Ad Record Store.
 *
 * @param adRecords the ad records
 */
public AdRecordStore(final SparseArray<AdRecord> adRecords) {
    mAdRecords = adRecords;

    mLocalNameComplete = AdRecordUtils.getRecordDataAsString(
            mAdRecords.get(AdRecord.TYPE_LOCAL_NAME_COMPLETE));

    mLocalNameShort = AdRecordUtils.getRecordDataAsString(
            mAdRecords.get(AdRecord.TYPE_LOCAL_NAME_SHORT));

}
 
开发者ID:Twelvelines,项目名称:AndroidMuseumBleManager,代码行数:16,代码来源:AdRecordStore.java


注:本文中的android.util.SparseArray类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。