Android SparseArray - top ranked examples from Open Source projects

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

This code example shows how to use the following methods:
 
    private final List<RepositoryId> repos;
 
    private final int[] issues;
 
    private final SparseArray<IssueFragment> fragments = new SparseArray<IssueFragment>();
 
    private final IssueStore store;
 
    /** 
     * @param activity 
     * @param repoIds 
     * @param issueNumbers 
     * @param issueStore 
     */ 
    public IssuesPagerAdapter(SherlockFragmentActivity activity,
            List<RepositoryId> repoIds, int[] issueNumbers,
            IssueStore issueStore) {
        super(activity);
 
7
CodeRank
Experience pair programming with AI  Get Codota for Java
This code example shows how to use the following methods:saveHierarchyState
    public boolean collapseItemActionView(MenuBuilder menu, MenuItemImpl item) {
        return false; 
    } 
 
    public void saveHierarchyState(Bundle outState) {
        SparseArray<Parcelable> viewStates = new SparseArray<Parcelable>();
        if (mMenuView != null) {
            ((View) mMenuView).saveHierarchyState(viewStates);
        } 
        outState.putSparseParcelableArray(VIEWS_TAG, viewStates);
    } 
 
    public void restoreHierarchyState(Bundle inState) {
        SparseArray<Parcelable> viewStates = inState.getSparseParcelableArray(VIEWS_TAG);
        if (viewStates != null) {
            ((View) mMenuView).restoreHierarchyState(viewStates);
        } 
    } 
 
    public void setId(int id) {
7
CodeRank
Experience pair programming with AI  Get Codota for Java
This code example shows how to use the following methods:put
	 
	private SparseArray<String> mDtNames;
	 
	public ListAdapterDB2DeviceTypes(){ 
		 
		mDtNames = new SparseArray<String>();
		mDtNames.put(1, "TV ?");
		mDtNames.put(2, "Cablebox ?");
		mDtNames.put(3, "Tuner / Hifi ?");
		mDtNames.put(4, "BD Player ?");
		mDtNames.put(5, "? ?");
	} 
	 
	@Override 
	public int getCount() { 
		return 5; 
	} 
 
	@Override 
	public Object getItem(int position) {
7
CodeRank
Experience pair programming with AI  Get Codota for Java
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
Experience pair programming with AI  Get Codota for Java
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
Experience pair programming with AI  Get Codota for Java
This code example shows how to use the following methods:delete, indexOfValue, keyAt, size
                alarm.mAlaramSender);
    } 
 
    /*package*/  synchronized void cancelAlarm(Alarm alarm) {
        mAlarmManager.cancel(alarm.mAlaramSender);
        int index = mAlarms.indexOfValue(alarm);
        if (index >= 0) {
            mAlarms.delete(mAlarms.keyAt(index));
        } 
 
        // Unregister the BroadcastReceiver if there isn't a alarm anymore. 
        if (mAlarms.size() == 0) {
            mContext.unregisterReceiver(this);
        } 
    } 
 
    private static int sNextId = 0;
    private static synchronized int nextId() { 
        return sNextId++;
    } 
7
CodeRank
Experience pair programming with AI  Get Codota for Java
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
Experience pair programming with AI  Get Codota for Java
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
Experience pair programming with AI  Get Codota for Java
This code example shows how to use the following methods:get
7
CodeRank
Experience pair programming with AI  Get Codota for Java
This code example shows how to use the following methods:put
    } 
     
    public E put(String name, int uid, E value) {
        SparseArray<E> uids = mMap.get(name);
        if (uids == null) {
            uids = new SparseArray<E>(2);
            mMap.put(name, uids);
        } 
        uids.put(uid, value);
        return value;
    } 
     
    public void remove(String name, int uid) {
        SparseArray<E> uids = mMap.get(name);
        if (uids != null) {
            uids.remove(uid);
            if (uids.size() == 0) {
                mMap.remove(name);
            } 
        } 
7
CodeRank
Experience pair programming with AI  Get Codota for Java

Related Android SparseArray Questions & Answers:

See Code Examples for Android SparseArray Methods: