SparseArray get - top ranked examples from Open Source projects

These code examples were ranked by Codota’s semantic indexing as the best open source examples for SparseArray get method.

This code example shows how to use the following methods:get
 
    /** 
     * Returns {@code true} if the key will be handled globally. 
     */ 
    boolean shouldHandleGlobalKey(int keyCode, KeyEvent event) {
        return mKeyMapping.get(keyCode) != null;
    } 
 
    private void loadGlobalKeys(Context context) {
        XmlResourceParser parser = null;
        try { 
            parser = context.getResources().getXml(com.android.internal.R.xml.global_keys);
            XmlUtils.beginDocument(parser, TAG_GLOBAL_KEYS);
            int version = parser.getAttributeIntValue(null, ATTR_VERSION, 0);
            if (GLOBAL_KEY_FILE_VERSION == version) {
                while (true) { 
                    XmlUtils.nextElement(parser);
                    String element = parser.getName();
                    if (element == null) {
                        break; 
7
CodeRank
This code example shows how to use the following methods:delete, get, put
 
    class RecycleBin { 
        private final SparseArray<View> mScrapHeap = new SparseArray<View>();
 
        public void put(int position, View v) {
            mScrapHeap.put(position, v);
        } 
 
        View get(int position) {
            // System.out.print("Looking for " + position); 
            View result = mScrapHeap.get(position);
            if (result != null) {
                // System.out.println(" HIT"); 
                mScrapHeap.delete(position);
            } else { 
                // System.out.println(" MISS"); 
            } 
            return result;
        } 
 
7
CodeRank
This code example shows how to use the following methods:get
     * @param arguments 
     * @return this adapter 
     */ 
    public IssuesPagerAdapter onDialogResult(int position, int requestCode,
            int resultCode, Bundle arguments) {
        IssueFragment fragment = fragments.get(position);
        if (fragment != null)
            fragment.onDialogResult(requestCode, resultCode, arguments);
        return this;
    } 
} 
7
CodeRank
This code example shows how to use the following methods:get
        Intent intent = null;
 
        // First try the exact keycode (with modifiers). 
        int shortcut = kcm.get(keyCode, metaState);
        if (shortcut != 0) {
            intent = mShortcutIntents.get(shortcut);
        } 
 
        // Next try the primary character on that key. 
        if (intent == null) {
            shortcut = Character.toLowerCase(kcm.getDisplayLabel(keyCode));
            if (shortcut != 0) {
                intent = mShortcutIntents.get(shortcut);
            } 
        } 
 
        return intent;
    } 
 
} 
7
CodeRank
This code example shows how to use the following methods:get, put
        // displayed (since the locale could change after we insert into the provider). 
        Bookmarks.add(getContentResolver(), intent, "", DEFAULT_BOOKMARK_FOLDER, shortcut, 0);
    } 
     
    private ShortcutPreference getOrCreatePreference(char shortcut) {
        ShortcutPreference pref = mShortcutToPreference.get(shortcut);
        if (pref != null) {
            return pref;
        } else { 
            Log.w(TAG, "Unknown shortcut '" + shortcut + "', creating preference anyway");
            return createPreference(shortcut);
        } 
    } 
     
    private ShortcutPreference createPreference(char shortcut) {
        ShortcutPreference pref = new ShortcutPreference(QuickLaunchSettings.this, shortcut);
        mShortcutGroup.addPreference(pref);
        mShortcutToPreference.put(shortcut, pref);
        return pref;
    } 

7
CodeRank
This code example shows how to use the following methods:get
This code example shows how to use the following methods:get, put
    public Typeface getTypeface(int value) {
        if (DEBUG) {
            Log.d(TAG, "Getting Typeface for value " + value);
        } 
         
        Typeface tf = mTypefaces.get(value);
        if (tf != null) {
            if (DEBUG) {
                Log.i(TAG, "Typeface was loaded from memory.");
            } 
            return tf;
        } 
         
        int resourceId = getResourceId(value);
        tf = getFontFromRes(resourceId);
        mTypefaces.put(value, tf);
 
        if (DEBUG) {
            Log.i(TAG, "Typeface was lazily created.");
        } 
         
6
CodeRank
This code example shows how to use the following methods:get, put
		final int localTileID = pGlobalTileID - this.mFirstGlobalTileID;
		return this.mTMXTileProperties.get(localTileID);
	} 
 
	public void addTMXTileProperty(final int pLocalTileID, final TMXTileProperty pTMXTileProperty) {
		final TMXProperties<TMXTileProperty> existingProperties = this.mTMXTileProperties.get(pLocalTileID);
		if(existingProperties != null) {
			existingProperties.add(pTMXTileProperty);
		} else { 
			final TMXProperties<TMXTileProperty> newProperties = new TMXProperties<TMXTileProperty>();
			newProperties.add(pTMXTileProperty);
			this.mTMXTileProperties.put(pLocalTileID, newProperties);
		} 
	} 
 
	public ITextureRegion getTextureRegionFromGlobalTileID(final int pGlobalTileID) {
		final int localTileID = pGlobalTileID - this.mFirstGlobalTileID;
		final int tileColumn = localTileID % this.mTilesHorizontal;
		final int tileRow = localTileID / this.mTilesHorizontal;
 
6
CodeRank
This code example shows how to use the following methods:get, put
	} 
 
	public ITextureRegion getTextureRegionFromGlobalTileID(final int pGlobalTileID) {
		final SparseArray<ITextureRegion> globalTileIDToTextureRegionCache = this.mGlobalTileIDToTextureRegionCache;
 
		final ITextureRegion cachedTextureRegion = globalTileIDToTextureRegionCache.get(pGlobalTileID);
		if(cachedTextureRegion != null) {
			return cachedTextureRegion;
		} else { 
			final ArrayList<TMXTileSet> tmxTileSets = this.mTMXTileSets;
 
			for(int i = tmxTileSets.size() - 1; i >= 0; i--) {
				final TMXTileSet tmxTileSet = tmxTileSets.get(i);
				if(pGlobalTileID >= tmxTileSet.getFirstGlobalTileID()) {
					final ITextureRegion textureRegion = tmxTileSet.getTextureRegionFromGlobalTileID(pGlobalTileID);
					/* Add to cache for the all future pGlobalTileIDs with the same value. */ 
					globalTileIDToTextureRegionCache.put(pGlobalTileID, textureRegion);
					return textureRegion;
				} 
			} 

6
CodeRank
This code example shows how to use the following methods:get, put
     * @param typefaceValue values ​​for the "typeface" attribute 
     * @return Roboto {@link Typeface} 
     * @throws IllegalArgumentException if unknown `typeface` attribute value. 
     */ 
    private Typeface obtaintTypeface(Context context, int typefaceValue) throws IllegalArgumentException {
        Typeface typeface = mTypefaces.get(typefaceValue);
        if (typeface == null) {
            typeface = createTypeface(context, typefaceValue);
            mTypefaces.put(typefaceValue, typeface);
        } 
        return typeface;
    } 
 
    /** 
     * Create typeface from assets. 
     * 
     * @param context       The Context the widget is running in, through which it can 
     *                      access the current theme, resources, etc. 
     * @param typefaceValue values ​​for the "typeface" attribute 
     * @return Roboto {@link Typeface} 
6
CodeRank
get Method Overview
Gets the Object mapped from the specified key, or null if no such mapping has been made.
See Code Examples for other Android SparseArray Methods: