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:com.wuman.androidimageloader.samples.BaseActivity.java

/**
 * Converts an intent into a {@link Bundle} suitable for use as fragment
 * arguments./* ww  w.  j  a  v a2s . c  o m*/
 */
public static Bundle intentToFragmentArguments(Intent intent) {
    Bundle arguments = new Bundle();
    if (intent == null) {
        return arguments;
    }

    final Uri data = intent.getData();
    if (data != null) {
        arguments.putParcelable("_uri", data);
    }

    final String action = intent.getAction();
    if (action != null) {
        arguments.putString("_action", action);
    }

    final String mimeType = intent.getType();
    if (mimeType != null) {
        arguments.putString("_mimetype", mimeType);
    }

    final Bundle extras = intent.getExtras();
    if (extras != null) {
        arguments.putAll(intent.getExtras());
    }

    return arguments;
}

From source file:com.facebook.share.internal.ShareInternalUtility.java

/**
 * Creates a new Request configured to upload a photo to the specified graph path.
 *
 * @param graphPath   the graph path to use
 * @param accessToken the access token to use, or null
 * @param image       the image to upload
 * @param caption     the user generated caption for the photo.
 * @param params      the parameters//from   ww w .  j  a v  a 2 s  .co  m
 * @param callback    a callback that will be called when the request is completed to handle
 *                    success or error conditions
 * @return a Request that is ready to execute
 */
public static GraphRequest newUploadPhotoRequest(String graphPath, AccessToken accessToken, Bitmap image,
        String caption, Bundle params, Callback callback) {
    Bundle parameters = new Bundle();
    if (params != null) {
        parameters.putAll(params);
    }
    parameters.putParcelable(PICTURE_PARAM, image);
    if (caption != null && !caption.isEmpty()) {
        parameters.putString(CAPTION_PARAM, caption);
    }

    return new GraphRequest(accessToken, graphPath, parameters, HttpMethod.POST, callback);
}

From source file:com.facebook.share.internal.ShareInternalUtility.java

/**
 * Creates a new Request configured to upload a photo to the specified graph path. The
 * photo will be read from the specified file.
 *
 * @param graphPath   the graph path to use
 * @param accessToken the access token to use, or null
 * @param file        the file containing the photo to upload
 * @param caption     the user generated caption for the photo.
 * @param params      the parameters/*from   ww w  .j a v  a 2s .com*/
 * @param callback    a callback that will be called when the request is completed to handle
 *                    success or error conditions
 * @return a Request that is ready to execute
 * @throws java.io.FileNotFoundException
 */
public static GraphRequest newUploadPhotoRequest(String graphPath, AccessToken accessToken, File file,
        String caption, Bundle params, Callback callback) throws FileNotFoundException {
    ParcelFileDescriptor descriptor = ParcelFileDescriptor.open(file, ParcelFileDescriptor.MODE_READ_ONLY);
    Bundle parameters = new Bundle();
    if (params != null) {
        parameters.putAll(params);
    }
    parameters.putParcelable(PICTURE_PARAM, descriptor);
    if (caption != null && !caption.isEmpty()) {
        parameters.putString(CAPTION_PARAM, caption);
    }

    return new GraphRequest(accessToken, graphPath, parameters, HttpMethod.POST, callback);
}

From source file:com.facebook.share.internal.ShareInternalUtility.java

/**
 * Creates a new Request configured to upload a photo to the specified graph path. The
 * photo will be read from the specified Uri.
 *
 * @param graphPath   the graph path to use
 * @param accessToken the access token to use, or null
 * @param photoUri    the file:// or content:// Uri to the photo on device.
 * @param caption     the user generated caption for the photo.
 * @param params      the parameters/*from  ww  w  . ja  v  a  2 s  . c  om*/
 * @param callback    a callback that will be called when the request is completed to handle
 *                    success or error conditions
 * @return a Request that is ready to execute
 * @throws FileNotFoundException
 */
public static GraphRequest newUploadPhotoRequest(String graphPath, AccessToken accessToken, Uri photoUri,
        String caption, Bundle params, Callback callback) throws FileNotFoundException {
    if (Utility.isFileUri(photoUri)) {
        return newUploadPhotoRequest(graphPath, accessToken, new File(photoUri.getPath()), caption, params,
                callback);
    } else if (!Utility.isContentUri(photoUri)) {
        throw new FacebookException("The photo Uri must be either a file:// or content:// Uri");
    }

    Bundle parameters = new Bundle();
    if (params != null) {
        parameters.putAll(params);
    }
    parameters.putParcelable(PICTURE_PARAM, photoUri);

    return new GraphRequest(accessToken, graphPath, parameters, HttpMethod.POST, callback);
}

From source file:org.alfresco.mobile.android.application.fragments.browser.ChildrenBrowserFragment.java

public static ChildrenBrowserFragment newInstance(int folderTypeId) {
    ChildrenBrowserFragment bf = new ChildrenBrowserFragment();
    ListingContext lc = new ListingContext();
    lc.setSortProperty(DocumentFolderService.SORT_PROPERTY_NAME);
    lc.setIsSortAscending(true);/*from ww w.  ja v a  2s  . com*/
    Bundle b = createBundleArgs(folderTypeId);
    b.putAll(createBundleArgs(lc, LOAD_AUTO));
    bf.setArguments(b);
    return bf;
}

From source file:net.granoeste.scaffold.app.ScaffoldActivity.java

/**
 * Converts an intent into a {@link android.os.Bundle} suitable for use as
 * fragment arguments./*  w w w .j  a v a 2  s. c o  m*/
 */
public static Bundle intentToFragmentArguments(final Intent intent) {
    final Bundle arguments = new Bundle();
    if (intent == null) {
        return arguments;
    }

    final Uri data = intent.getData();
    if (data != null) {
        arguments.putParcelable(ScaffoldConstants.ARG_URI, data);
    }

    final String action = intent.getAction();
    if (action != null) {
        arguments.putString(ScaffoldConstants.ARG_ACTION, action);
    }

    final Bundle extras = intent.getExtras();
    if (extras != null) {
        arguments.putAll(intent.getExtras());
    }

    return arguments;
}

From source file:org.alfresco.mobile.android.application.fragments.browser.ChildrenBrowserFragment.java

public static ChildrenBrowserFragment newInstanceById(String folderIdentifier) {
    ChildrenBrowserFragment bf = new ChildrenBrowserFragment();
    ListingContext lc = new ListingContext();
    lc.setSortProperty(DocumentFolderService.SORT_PROPERTY_NAME);
    lc.setIsSortAscending(true);/*from   ww w  .  java 2  s . c o m*/
    Bundle b = createBundleArg(folderIdentifier);
    b.putBoolean(PARAM_IS_SHORTCUT, true);
    b.putAll(createBundleArgs(lc, LOAD_AUTO));
    bf.setArguments(b);
    return bf;
}

From source file:org.alfresco.mobile.android.application.fragments.browser.ChildrenBrowserFragment.java

private static ChildrenBrowserFragment newInstance(Folder parentFolder, String pathFolder, Site site,
        boolean isShortcut) {
    ChildrenBrowserFragment bf = new ChildrenBrowserFragment();
    ListingContext lc = new ListingContext();
    lc.setSortProperty(DocumentFolderService.SORT_PROPERTY_NAME);
    lc.setIsSortAscending(true);//from   ww  w  . jav  a  2 s .co  m
    Bundle b = createBundleArgs(parentFolder, pathFolder, site);
    b.putBoolean(PARAM_IS_SHORTCUT, isShortcut);
    b.putAll(createBundleArgs(lc, LOAD_AUTO));
    bf.setArguments(b);
    return bf;
}

From source file:com.paranoid.gerrit.PatchSetViewerActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    this.setTheme(Prefs.getCurrentThemeID(this));
    super.onCreate(savedInstanceState);

    // Show the Up button in the action bar.
    getActionBar().setDisplayHomeAsUpEnabled(true);

    /* If there was a fragment state save from previous configurations of
     * this activity, then it doesn't need to be added again.*/
    if (savedInstanceState == null) {
        /* Create the detail fragment and add it to the activity
         * using a fragment transaction.
         * Copy all the intent arguments over to the fragment */
        PatchSetViewerFragment fragment = new PatchSetViewerFragment();
        Bundle args = new Bundle();
        args.putAll(getIntent().getExtras());
        fragment.setArguments(args);//  w  ww.j  a  v  a2  s  . com

        // Display the fragment
        getSupportFragmentManager().beginTransaction().replace(android.R.id.content, fragment).commit();
    } else {
        setContentView(R.layout.commit_list);
    }
}

From source file:com.rakangsoftware.skyline.mvpvm.SkylineFragment.java

@Override
public void onSaveInstanceState(final Bundle outState) {
    if (mViewModel != null) {
        outState.putAll(mViewModel.getState());
    }/*ww  w  .ja  va  2s  .  c  o m*/

    super.onSaveInstanceState(outState);
}