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 ShareOpenGraphContent createOpenGraphContent() { ShareOpenGraphAction.Builder actionBuilder = createEatActionBuilder(); boolean userGenerated = false; if (photoUri != null) { String photoUriString = photoUri.toString(); Pair<File, Integer> fileAndMinDimension = getImageFileAndMinDimension(); userGenerated = fileAndMinDimension.second >= USER_GENERATED_MIN_SIZE; if (fileAndMinDimension != null) { final SharePhoto actionPhoto = new SharePhoto.Builder() .setImageUrl(Uri.parse(photoUriString)) .setUserGenerated(userGenerated) .build(); actionBuilder.putPhotoArrayList("image", new ArrayList<SharePhoto>() {{ add(actionPhoto); }}); } } return new ShareOpenGraphContent.Builder() .setAction(actionBuilder.build()) .setPreviewPropertyName("meal") .build(); }
private SharePhoto buildSharePhoto(String url) { return new SharePhoto.Builder() .setImageUrl(Uri.parse(url)) .build(); } }
sharePhotoBuilder.setBitmap(bitmap); } else { sharePhotoBuilder.setImageUrl(Uri.parse(photoUri));
@LargeTest public void testCreateOpenGraphObject() throws InterruptedException { Uri testImage = Uri.parse("http://i.imgur.com/Diyvl7q.jpg"); SharePhoto photo = new SharePhoto.Builder() .setImageUrl(testImage) .setUserGenerated(true) .build(); ShareOpenGraphObject ogObject = new ShareOpenGraphObject.Builder() .putString("og:title", "a title") .putString("og:type", TEST_OG_OBJECT_TYPE) .putString("og:description", "a description") .putPhoto("og:image", photo) .build(); try { GraphRequest request = ShareGraphRequest.createOpenGraphObject(ogObject); GraphResponse response = request.executeAndWait(); assertNotNull(response); assertNull(response.getError()); JSONObject graphResult = response.getJSONObject(); assertNotNull(graphResult); assertNotNull(graphResult.optString("id")); assertNotNull(response.getRawResponse()); } catch (Exception e){ fail(); } }
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); }
@Override public Builder readFrom(final SharePhoto model) { if (model == null) { return this; } return super.readFrom(model) .setBitmap(model.getBitmap()) .setImageUrl(model.getImageUrl()) .setUserGenerated(model.getUserGenerated()) .setCaption(model.getCaption()) ; }
@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); }
public static SharePhoto.Builder getPhotoBuilder(final PhotoBuilderType type) { final SharePhoto.Builder builder = new SharePhoto.Builder().setUserGenerated( PHOTO_USER_GENERATED); switch (type) { case BITMAP: builder.setBitmap(PHOTO_BITMAP); break; case LOCAL_URL: builder.setImageUrl(getTestPhotoImageUrl()); break; } return builder; }