Example usage for android.os PersistableBundle getInt

List of usage examples for android.os PersistableBundle getInt

Introduction

In this page you can find the example usage for android.os PersistableBundle getInt.

Prototype

public int getInt(String key, int defaultValue) 

Source Link

Document

Returns the value associated with the given key, or defaultValue if no mapping of the desired type exists for the given key.

Usage

From source file:com.android.contacts.DynamicShortcuts.java

@VisibleForTesting
void updatePinned() {
    final List<ShortcutInfo> updates = new ArrayList<>();
    final List<String> removedIds = new ArrayList<>();
    final List<String> enable = new ArrayList<>();

    for (ShortcutInfo shortcut : mShortcutManager.getPinnedShortcuts()) {
        final PersistableBundle extras = shortcut.getExtras();

        if (extras == null
                || extras.getInt(EXTRA_SHORTCUT_TYPE, SHORTCUT_TYPE_UNKNOWN) != SHORTCUT_TYPE_CONTACT_URI) {
            continue;
        }/* w ww .j  av a  2 s. co  m*/

        // The contact ID may have changed but that's OK because it is just an optimization
        final long contactId = extras.getLong(Contacts._ID);

        final ShortcutInfo update = createShortcutForUri(Contacts.getLookupUri(contactId, shortcut.getId()));
        if (update != null) {
            updates.add(update);
            if (!shortcut.isEnabled()) {
                // Handle the case that a contact is disabled because it doesn't exist but
                // later is created (for instance by a sync)
                enable.add(update.getId());
            }
        } else if (shortcut.isEnabled()) {
            removedIds.add(shortcut.getId());
        }
    }

    if (Log.isLoggable(TAG, Log.DEBUG)) {
        Log.d(TAG, "updating " + updates);
        Log.d(TAG, "enabling " + enable);
        Log.d(TAG, "disabling " + removedIds);
    }

    mShortcutManager.updateShortcuts(updates);
    mShortcutManager.enableShortcuts(enable);
    mShortcutManager.disableShortcuts(removedIds,
            mContext.getString(R.string.dynamic_shortcut_contact_removed_message));
}