List of usage examples for android.os Bundle putParcelable
public void putParcelable(@Nullable String key, @Nullable Parcelable value)
From source file:com.facebook.share.internal.ShareInternalUtility.java
/** * Creates a new Request configured to upload an image to create a staging resource. Staging * resources allow you to post binary data such as images, in preparation for a post of an Open * Graph object or action which references the image. The URI returned when uploading a staging * resource may be passed as the image property for an Open Graph object or action. * * @param accessToken the access token to use, or null * @param imageUri the file:// or content:// Uri pointing to the image to upload * @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/*from ww w . j a va 2 s .co m*/ */ public static GraphRequest newUploadStagingResourceWithImageRequest(AccessToken accessToken, Uri imageUri, Callback callback) throws FileNotFoundException { if (Utility.isFileUri(imageUri)) { return newUploadStagingResourceWithImageRequest(accessToken, new File(imageUri.getPath()), callback); } else if (!Utility.isContentUri(imageUri)) { throw new FacebookException("The image Uri must be either a file:// or content:// Uri"); } GraphRequest.ParcelableResourceWithMimeType<Uri> resourceWithMimeType = new GraphRequest.ParcelableResourceWithMimeType<>( imageUri, "image/png"); Bundle parameters = new Bundle(1); parameters.putParcelable(STAGING_PARAM, resourceWithMimeType); return new GraphRequest(accessToken, MY_STAGING_RESOURCES, 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. * * @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/* w w w.j a va 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 */ 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/* www. j a v a 2 s . c o 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 * @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 .jav a2 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:com.alexandrepiveteau.library.tutorial.TutorialFragment.java
private static TutorialFragment getInstance(String name, String description, int imageResource, int imageResourceBackground, int imageResourceForeground, boolean hasAnimatedImageResource, boolean hasAnimatedImageResourceBackground, boolean hasAnimatedImageResourceForeground, int customActionIcon, PendingIntent pendingIntent, String customActionTitle) { Bundle bundle = new Bundle(); bundle.putInt(ARGUMENTS_TUTORIAL_IMAGE, imageResource); bundle.putInt(ARGUMENTS_TUTORIAL_IMAGE_BACKGROUND, imageResourceBackground); bundle.putInt(ARGUMENTS_TUTORIAL_IMAGE_FOREGROUND, imageResourceForeground); bundle.putString(ARGUMENTS_TUTORIAL_NAME, name); bundle.putString(ARGUMENTS_TUTORIAL_DESCRIPTION, description); bundle.putBoolean(ARGUMENTS_HAS_ANIMATED_IMAGE, hasAnimatedImageResource); bundle.putBoolean(ARGUMENTS_HAS_ANIMATED_IMAGE_BACKGROUND, hasAnimatedImageResourceBackground); bundle.putBoolean(ARGUMENTS_HAS_ANIMATED_IMAGE_FOREGROUND, hasAnimatedImageResourceForeground); bundle.putInt(ARGUMENTS_CUSTOM_ACTION_ICON, customActionIcon); bundle.putParcelable(ARGUMENTS_CUSTOM_ACTION_PENDING_INTENT, pendingIntent); bundle.putString(ARGUMENTS_CUSTOM_ACTION_TITLE, customActionTitle); TutorialFragment tutorialFragment = new TutorialFragment(); tutorialFragment.setArguments(bundle); return tutorialFragment; }
From source file:com.facebook.internal.Utility.java
public static void putObjectInBundle(Bundle bundle, String key, Object value) { if (value instanceof String) { bundle.putString(key, (String) value); } else if (value instanceof Parcelable) { bundle.putParcelable(key, (Parcelable) value); } else if (value instanceof byte[]) { bundle.putByteArray(key, (byte[]) value); } else {// w ww.ja va 2s .c o m throw new FacebookException("attempted to add unsupported type to Bundle"); } }
From source file:android.support.car.ui.CarActionExtender.java
@Override public NotificationCompat.Action.Builder extend(NotificationCompat.Action.Builder builder) { Bundle autoBundle = new Bundle(); autoBundle.putParcelable(EXTRA_INTENT, mIntent); builder.getExtras().putBundle(EXTRA_AUTO_EXTENDER, autoBundle); return builder; }
From source file:de.lebenshilfe_muenster.uk_gebaerden_muensterland.activities.LevelOneActivity.java
private void setupVideoFragment() { final Intent intent = getIntent(); final Bundle bundle = intent.getBundleExtra(EXTRA); Validate.notNull(bundle, "The bundle supplied to the activity is null."); final String fragmentToShow = bundle.getString(FRAGMENT_TO_SHOW, StringUtils.EMPTY); if (SignVideoFragment.class.getSimpleName().equals(fragmentToShow)) { final Parcelable sign = bundle.getParcelable(SignVideoFragment.SIGN_TO_SHOW); SignVideoFragment signVideoFragment = new SignVideoFragment(); final Bundle args = new Bundle(); args.putParcelable(SignVideoFragment.SIGN_TO_SHOW, sign); signVideoFragment.setArguments(args); setFragment(signVideoFragment, SIGN_VIDEO_TAG); } else {/*from www . ja v a 2 s . co m*/ throw new IllegalArgumentException("Cannot show the fragment with name: " + fragmentToShow); } }
From source file:com.android.volley.toolbox.AndroidAuthenticatorTest.java
@Test(expected = AuthFailureError.class) public void resultContainsIntent() throws Exception { Intent intent = new Intent(); Bundle bundle = new Bundle(); bundle.putParcelable(AccountManager.KEY_INTENT, intent); when(mAccountManager.getAuthToken(mAccount, "cooltype", false, null, null)).thenReturn(mFuture); when(mFuture.getResult()).thenReturn(bundle); when(mFuture.isDone()).thenReturn(true); when(mFuture.isCancelled()).thenReturn(false); mAuthenticator.getAuthToken();/*from ww w.java2 s .c om*/ }
From source file:com.binary_machinery.avalonschedule.view.schedule.SchedulePageFragment.java
@Nullable @Override//from w w w. j a v a 2 s.c om public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View rootView = inflater.inflate(R.layout.schedule_page, container, false); Bundle arguments = getArguments(); FragmentManager fragmentManager = getChildFragmentManager(); FragmentTransaction fragmentTransaction = fragmentManager.beginTransaction(); Func2<Integer, Integer, ?> setRecord = (dayOfWeek, layoutId) -> { String key = ARG_DAY + dayOfWeek; ScheduleRecord record = arguments.getParcelable(key); if (record != null) { Fragment fragment = (record.course != null) ? new RecordFragment() : new EmptyRecordFragment(); Bundle args = new Bundle(); args.putParcelable(RecordFragment.ARG_RECORD, record); fragment.setArguments(args); fragmentTransaction.replace(layoutId, fragment); } return 0; }; setRecord.call(Calendar.MONDAY, R.id.layoutMonday); setRecord.call(Calendar.TUESDAY, R.id.layoutTuesday); setRecord.call(Calendar.WEDNESDAY, R.id.layoutWednesday); setRecord.call(Calendar.THURSDAY, R.id.layoutThursday); setRecord.call(Calendar.FRIDAY, R.id.layoutFriday); setRecord.call(Calendar.SATURDAY, R.id.layoutSaturday); setRecord.call(Calendar.SUNDAY, R.id.layoutSunday); fragmentTransaction.commit(); return rootView; }