Example usage for android.os Bundle putAll

List of usage examples for android.os Bundle putAll

Introduction

In this page you can find the example usage for android.os Bundle putAll.

Prototype

public void putAll(Bundle bundle) 

Source Link

Document

Inserts all mappings from the given Bundle into this Bundle.

Usage

From source file:org.wheelmap.android.fragment.POIsOsmdroidFragment.java

@Override
public void onSearch(Bundle bundle) {
    Bundle boundingBoxExtras = fillExtrasWithBoundingRect();
    bundle.putAll(boundingBoxExtras);

    mWorkerFragment.requestSearch(bundle);
}

From source file:androidx.navigation.NavController.java

/**
 * Checks the given Intent for a Navigation deep link and navigates to the deep link if present.
 * This is called automatically for you the first time you set the graph if you've passed in an
 * {@link Activity} as the context when constructing this NavController, but should be manually
 * called if your Activity receives new Intents in {@link Activity#onNewIntent(Intent)}.
 * <p>/*from w  w w  . j av  a2  s .co m*/
 * The types of Intents that are supported include:
 * <ul>
 *     <ol>Intents created by {@link NavDeepLinkBuilder} or
 *     {@link #createDeepLink()}. This assumes that the current graph shares
 *     the same hierarchy to get to the deep linked destination as when the deep link was
 *     constructed.</ol>
 *     <ol>Intents that include a {@link Intent#getData() data Uri}. This Uri will be checked
 *     against the Uri patterns added via {@link NavDestination#addDeepLink(String)}.</ol>
 * </ul>
 * <p>The {@link #getGraph() navigation graph} should be set before calling this method.</p>
 * @param intent The Intent that may contain a valid deep link
 * @return True if the navigation controller found a valid deep link and navigated to it.
 * @see NavDestination#addDeepLink(String)
 */
public boolean onHandleDeepLink(@Nullable Intent intent) {
    if (intent == null) {
        return false;
    }
    Bundle extras = intent.getExtras();
    int[] deepLink = extras != null ? extras.getIntArray(KEY_DEEP_LINK_IDS) : null;
    Bundle bundle = new Bundle();
    Bundle deepLinkExtras = extras != null ? extras.getBundle(KEY_DEEP_LINK_EXTRAS) : null;
    if (deepLinkExtras != null) {
        bundle.putAll(deepLinkExtras);
    }
    if ((deepLink == null || deepLink.length == 0) && intent.getData() != null) {
        Pair<NavDestination, Bundle> matchingDeepLink = mGraph.matchDeepLink(intent.getData());
        if (matchingDeepLink != null) {
            deepLink = matchingDeepLink.first.buildDeepLinkIds();
            bundle.putAll(matchingDeepLink.second);
        }
    }
    if (deepLink == null || deepLink.length == 0) {
        return false;
    }
    bundle.putParcelable(KEY_DEEP_LINK_INTENT, intent);
    int flags = intent.getFlags();
    if ((flags & Intent.FLAG_ACTIVITY_NEW_TASK) != 0 && (flags & Intent.FLAG_ACTIVITY_CLEAR_TASK) == 0) {
        // Someone called us with NEW_TASK, but we don't know what state our whole
        // task stack is in, so we need to manually restart the whole stack to
        // ensure we're in a predictably good state.
        intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK);
        TaskStackBuilder taskStackBuilder = TaskStackBuilder.create(mContext)
                .addNextIntentWithParentStack(intent);
        taskStackBuilder.startActivities();
        if (mActivity != null) {
            mActivity.finish();
        }
        return true;
    }
    if ((flags & Intent.FLAG_ACTIVITY_NEW_TASK) != 0) {
        // Start with a cleared task starting at our root when we're on our own task
        if (!mBackStack.isEmpty()) {
            navigate(mGraph.getStartDestination(), bundle, new NavOptions.Builder()
                    .setPopUpTo(mGraph.getId(), true).setEnterAnim(0).setExitAnim(0).build());
        }
        int index = 0;
        while (index < deepLink.length) {
            int destinationId = deepLink[index++];
            NavDestination node = findDestination(destinationId);
            if (node == null) {
                throw new IllegalStateException("unknown destination during deep link: "
                        + NavDestination.getDisplayName(mContext, destinationId));
            }
            node.navigate(bundle, new NavOptions.Builder().setEnterAnim(0).setExitAnim(0).build());
        }
        return true;
    }
    // Assume we're on another apps' task and only start the final destination
    NavGraph graph = mGraph;
    for (int i = 0; i < deepLink.length; i++) {
        int destinationId = deepLink[i];
        NavDestination node = i == 0 ? mGraph : graph.findNode(destinationId);
        if (node == null) {
            throw new IllegalStateException("unknown destination during deep link: "
                    + NavDestination.getDisplayName(mContext, destinationId));
        }
        if (i != deepLink.length - 1) {
            // We're not at the final NavDestination yet, so keep going through the chain
            graph = (NavGraph) node;
        } else {
            // Navigate to the last NavDestination, clearing any existing destinations
            node.navigate(bundle, new NavOptions.Builder().setPopUpTo(mGraph.getId(), true).setEnterAnim(0)
                    .setExitAnim(0).build());
        }
    }
    return true;
}

From source file:com.openerp.MainActivity.java

/**
 * Request sync./*from w  w  w .  j  a  v  a  2 s. co m*/
 * 
 * @param authority
 *            the authority
 * @param bundle
 *            the extra data
 */
public void requestSync(String authority, Bundle bundle) {
    Account account = OpenERPAccountManager.getAccount(getApplicationContext(),
            OEUser.current(getApplicationContext()).getAndroidName());
    Bundle settingsBundle = new Bundle();
    settingsBundle.putBoolean(ContentResolver.SYNC_EXTRAS_MANUAL, true);
    settingsBundle.putBoolean(ContentResolver.SYNC_EXTRAS_EXPEDITED, true);
    if (bundle != null) {
        settingsBundle.putAll(bundle);
    }
    ContentResolver.requestSync(account, authority, settingsBundle);
}

From source file:org.deviceconnect.android.message.DevicePluginContext.java

/**
 * Device Connect???.//from  www .  ja  v a2  s .c o m
 *
 * @param event 
 * @param bundle 
 * @return ????true????false?
 */
@Override
public boolean sendEvent(final Event event, final Bundle bundle) {
    Intent intent = EventManager.createEventMessage(event);
    Bundle original = intent.getExtras();
    if (original != null) {
        original.putAll(bundle);
        intent.putExtras(original);
    }
    return sendEvent(intent, event.getAccessToken());
}

From source file:com.serenegiant.aceparrot.BaseFragment.java

@Override
public void onSaveInstanceState(final Bundle outState) {
    super.onSaveInstanceState(outState);
    final Bundle args = getArguments();
    if (args != null) {
        outState.putAll(args);
    }/*  www.ja va 2s  .c om*/
    if (DEBUG)
        Log.v(TAG, "onSaveInstanceState:" + outState);
}

From source file:bolts.AppLinkNavigation.java

/**
 * Creates a bundle containing the final, constructed App Link data to be used in navigation.
 *//*w  w w.ja va  2s  .  c om*/
private Bundle buildAppLinkDataForNavigation(Context context) {
    Bundle data = new Bundle();
    Bundle refererAppLinkData = new Bundle();
    if (context != null) {
        String refererAppPackage = context.getPackageName();
        if (refererAppPackage != null) {
            refererAppLinkData.putString(KEY_NAME_REFERER_APP_LINK_PACKAGE, refererAppPackage);
        }
        ApplicationInfo appInfo = context.getApplicationInfo();
        if (appInfo != null) {
            String refererAppName = context.getString(appInfo.labelRes);
            if (refererAppName != null) {
                refererAppLinkData.putString(KEY_NAME_REFERER_APP_LINK_APP_NAME, refererAppName);
            }
        }
    }
    data.putAll(getAppLinkData());
    data.putString(AppLinks.KEY_NAME_TARGET, getAppLink().getSourceUrl().toString());
    data.putString(KEY_NAME_VERSION, VERSION);
    data.putString(KEY_NAME_USER_AGENT, "Bolts Android " + Bolts.VERSION);
    data.putBundle(KEY_NAME_REFERER_APP_LINK, refererAppLinkData);
    data.putBundle(AppLinks.KEY_NAME_EXTRAS, getExtras());
    return data;
}

From source file:com.android.deskclock.timer.TimerFullScreenFragment.java

@Override
public void onSaveInstanceState(Bundle outState) {
    super.onSaveInstanceState(outState);
    if (mAdapter != null) {
        mAdapter.onSaveInstanceState(outState);
    }/*  w  ww.j a  v a 2s.c  o  m*/
    if (mTimerSetup != null) {
        saveViewState(outState);
    } else if (mViewState != null) {
        outState.putAll(mViewState);
    }
}

From source file:com.rbsoftware.pfm.personalfinancemanager.MainActivity.java

@Override
public void onSaveInstanceState(Bundle outState) {
    outState.putString("mActiveAccountId", getActiveAccountId());
    outState.putString("activeAccountName", drawerAccountHeader.getActiveProfile().getEmail().getText());
    //add the values which need to be saved from the drawer to the bundle
    outState.putAll(mMaterialDrawer.saveInstanceState(outState));
    //add the values which need to be saved from the accountHeader to the bundle
    outState.putAll(drawerAccountHeader.saveInstanceState(outState));

    //saving current orientation state
    outState.putInt("screenOrientation", orientationState);
    super.onSaveInstanceState(outState);
}

From source file:org.mariotaku.twidere.fragment.UserProfileFragment.java

@Override
public void onActivityCreated(final Bundle savedInstanceState) {
    mTwitterWrapper = getApplication().getTwitterWrapper();
    mPreferences = getSharedPreferences(SHARED_PREFERENCES_NAME, Context.MODE_PRIVATE);
    super.onActivityCreated(savedInstanceState);
    final Bundle args = getArguments();
    long account_id = -1, user_id = -1;
    String screen_name = null;/* w  w w.j a v a 2s. c o  m*/
    if (args != null) {
        if (savedInstanceState != null) {
            args.putAll(savedInstanceState);
        }
        account_id = args.getLong(INTENT_KEY_ACCOUNT_ID, -1);
        user_id = args.getLong(INTENT_KEY_USER_ID, -1);
        screen_name = args.getString(INTENT_KEY_SCREEN_NAME);
    }
    mProfileImageLoader = getApplication().getProfileImageLoader();
    mAdapter = new ListActionAdapter(getActivity());
    mProfileImageContainer.setOnClickListener(this);
    mNameContainer.setOnClickListener(this);
    mEditFollowButton.setOnClickListener(this);
    mTweetsContainer.setOnClickListener(this);
    mFollowersContainer.setOnClickListener(this);
    mFriendsContainer.setOnClickListener(this);
    mRetryButton.setOnClickListener(this);
    mMoreOptionsButton.setOnClickListener(this);
    mProfileNameBannerContainer.setOnSizeChangedListener(this);
    setListAdapter(null);
    mListView = getListView();
    mListView.addHeaderView(mHeaderView, null, false);
    mListView.setOnItemClickListener(this);
    mListView.setOnItemLongClickListener(this);
    setListAdapter(mAdapter);
    getUserInfo(account_id, user_id, screen_name, false);

}

From source file:org.mariotaku.twidere.fragment.support.UserProfileFragment.java

@Override
public void onActivityCreated(final Bundle savedInstanceState) {
    super.onActivityCreated(savedInstanceState);
    setHasOptionsMenu(true);/*w w w .  j  a v a  2s. c  om*/
    mPreferences = getSharedPreferences(SHARED_PREFERENCES_NAME, Context.MODE_PRIVATE);
    getSharedPreferences(USER_COLOR_PREFERENCES_NAME, Context.MODE_PRIVATE)
            .registerOnSharedPreferenceChangeListener(this);
    getSharedPreferences(USER_NICKNAME_PREFERENCES_NAME, Context.MODE_PRIVATE)
            .registerOnSharedPreferenceChangeListener(this);
    mLocale = getResources().getConfiguration().locale;
    final Bundle args = getArguments();
    long account_id = -1, user_id = -1;
    String screen_name = null;
    if (args != null) {
        if (savedInstanceState != null) {
            args.putAll(savedInstanceState);
        }
        account_id = args.getLong(EXTRA_ACCOUNT_ID, -1);
        user_id = args.getLong(EXTRA_USER_ID, -1);
        screen_name = args.getString(EXTRA_SCREEN_NAME);
    }
    mProfileImageLoader = getApplication().getImageLoaderWrapper();
    mAdapter = new ListActionAdapter(getActivity());
    mProfileImageView.setOnClickListener(this);
    mProfileBannerView.setOnClickListener(this);
    mTweetsContainer.setOnClickListener(this);
    mFollowersContainer.setOnClickListener(this);
    mFriendsContainer.setOnClickListener(this);
    mRetryButton.setOnClickListener(this);
    setListAdapter(null);
    mListView = getListView();
    mListView.addHeaderView(mHeaderView, null, false);
    mListView.setOnItemClickListener(this);
    mListView.setOnItemLongClickListener(this);

    mMenuBar.setVisibility(shouldUseNativeMenu() ? View.GONE : View.VISIBLE);
    mMenuBar.inflate(R.menu.menu_user_profile);
    mMenuBar.setIsBottomBar(true);
    mMenuBar.setOnMenuItemClickListener(this);

    setListAdapter(mAdapter);
    getUserInfo(account_id, user_id, screen_name, false);
}