private SharePhotoContent createAndMapAttachments( final SharePhotoContent content, final UUID callId) { final SharePhotoContent.Builder contentBuilder = new SharePhotoContent.Builder().readFrom(content); final List<SharePhoto> photos = new ArrayList<>(); final List<NativeAppCallAttachmentStore.Attachment> attachments = new ArrayList<>(); for (int i = 0; i < content.getPhotos().size(); i++) { SharePhoto sharePhoto = content.getPhotos().get(i); final Bitmap photoBitmap = sharePhoto.getBitmap(); if (photoBitmap != null) { NativeAppCallAttachmentStore.Attachment attachment = NativeAppCallAttachmentStore.createAttachment(callId, photoBitmap); sharePhoto = new SharePhoto.Builder() .readFrom(sharePhoto) .setImageUrl(Uri.parse(attachment.getAttachmentUrl())) .setBitmap(null) .build(); attachments.add(attachment); } photos.add(sharePhoto); } contentBuilder.setPhotos(photos); NativeAppCallAttachmentStore.addAttachments(attachments); return contentBuilder.build(); } }
private void postPhoto() { Bitmap image = BitmapFactory.decodeResource(this.getResources(), R.drawable.icon); SharePhoto sharePhoto = new SharePhoto.Builder().setBitmap(image).build(); ArrayList<SharePhoto> photos = new ArrayList<>(); photos.add(sharePhoto); SharePhotoContent sharePhotoContent = new SharePhotoContent.Builder().setPhotos(photos).build(); if (canPresentShareDialogWithPhotos) { shareDialog.show(sharePhotoContent); } else if (hasPublishPermission()) { ShareApi.share(sharePhotoContent, shareCallback); } else { pendingAction = PendingAction.POST_PHOTO; // We need to get new permissions, then complete the action when we get called back. LoginManager.getInstance().logInWithPublishPermissions( this, Arrays.asList(PERMISSION)); } }
.setUserGenerated(true) .build(); SharePhotoContent content = new SharePhotoContent.Builder().addPhoto(photo).build(); final ShareApi shareApi = new ShareApi(content); shareApi.setGraphNode(albumId);
public static SharePhotoContent.Builder getPhotoContentBuilder() { return new SharePhotoContent.Builder().addPhotos(PHOTO_CONTENT_PHOTOS); }
@Test(expected = FacebookException.class) public void testItValidatesMaxSizeOfPhotoShareByMessage() { SharePhotoContent sharePhotoContent = new SharePhotoContent.Builder() .addPhoto(buildSharePhoto("https://facebook.com/awesome-1.gif")) .addPhoto(buildSharePhoto("https://facebook.com/awesome-2.gif")) .addPhoto(buildSharePhoto("https://facebook.com/awesome-3.gif")) .addPhoto(buildSharePhoto("https://facebook.com/awesome-4.gif")) .addPhoto(buildSharePhoto("https://facebook.com/awesome-5.gif")) .addPhoto(buildSharePhoto("https://facebook.com/awesome-6.gif")) .addPhoto(buildSharePhoto("https://facebook.com/awesome-7.gif")) .build(); ShareContentValidation.validateForMessage(sharePhotoContent); }
@Test(expected = FacebookException.class) public void testItValidatesNullImageForSharePhotoContentByApi() { SharePhotoContent.Builder spcBuilder = new SharePhotoContent.Builder(); SharePhoto sharePhoto = new SharePhoto.Builder().setImageUrl(null) .build(); SharePhotoContent sharePhotoContent = spcBuilder.addPhoto(sharePhoto).build(); ShareContentValidation.validateForApiShare(sharePhotoContent); }
@Test(expected = FacebookException.class) public void testItValidatesEmptyListOfPhotoForPhotoShareByMessage() { SharePhotoContent sharePhoto = new SharePhotoContent.Builder().build(); ShareContentValidation.validateForMessage(sharePhoto); }
@Test(expected = FacebookException.class) public void testItValidatesNullImageForPhotoShareByMessage() { SharePhotoContent.Builder spcBuilder = new SharePhotoContent.Builder(); SharePhoto sharePhoto = new SharePhoto.Builder().setImageUrl(null).setBitmap(null) .build(); SharePhotoContent sharePhotoContent = spcBuilder.addPhoto(sharePhoto).build(); ShareContentValidation.validateForMessage(sharePhotoContent); }
@Test public void testItDoesAcceptSharePhotoContentByWeb() { SharePhoto sharePhoto = buildSharePhoto("https://facebook.com/awesome.gif"); SharePhotoContent sharePhotoContent = new SharePhotoContent.Builder().addPhoto(sharePhoto).build(); ShareContentValidation.validateForWebShare(sharePhotoContent); }
public static void makePublishPostRequest(Uri attachmentUri, FacebookCallback<Sharer.Result> callback) { SharePhoto photo = new SharePhoto.Builder() .setImageUrl(attachmentUri) .build(); SharePhotoContent content = new SharePhotoContent.Builder() .addPhoto(photo) .build(); ShareApi.share(content, callback); }