/** * Adds multiple photos to the content. * @param photos {@link java.util.List} of {@link com.facebook.share.model.SharePhoto}s * to add. * @return The builder. */ public Builder addPhotos(@Nullable final List<SharePhoto> photos) { if (photos != null) { for (SharePhoto photo : photos) { this.addPhoto(photo); } } return this; }
.setUserGenerated(true) .build(); SharePhotoContent content = new SharePhotoContent.Builder().addPhoto(photo).build(); final ShareApi shareApi = new ShareApi(content); shareApi.setGraphNode(albumId);
@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 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); }