@Override public JSONObject toJSONObject(SharePhoto photo) { Uri photoUri = photo.getImageUrl(); JSONObject photoJSONObject = new JSONObject(); try { photoJSONObject.put( NativeProtocol.IMAGE_URL_KEY, photoUri.toString()); } catch (Exception e) { throw new FacebookException("Unable to attach images", e); } return photoJSONObject; } });
private static void validatePhoto(SharePhoto photo) { if (photo == null) { throw new FacebookException("Cannot share a null SharePhoto"); } Bitmap photoBitmap = photo.getBitmap(); Uri photoUri = photo.getImageUrl(); if (photoBitmap == null && photoUri == null) { throw new FacebookException("SharePhoto does not have a Bitmap or ImageUrl specified"); } }
private static NativeAppCallAttachmentStore.Attachment getAttachment( UUID callId, ShareMedia medium) { Bitmap bitmap = null; Uri uri = null; if (medium instanceof SharePhoto) { SharePhoto photo = (SharePhoto)medium; bitmap = photo.getBitmap(); uri = photo.getImageUrl(); } else if (medium instanceof ShareVideo) { ShareVideo video = (ShareVideo)medium; uri = video.getLocalUrl(); } return getAttachment(callId, uri, bitmap); }
public static void assertEquals(final SharePhoto a, final SharePhoto b) { Assert.assertEquals(a.getBitmap(), b.getBitmap()); Assert.assertEquals(a.getImageUrl(), b.getImageUrl()); Assert.assertEquals(a.getUserGenerated(), b.getUserGenerated()); }
private static void validatePhotoForApi(SharePhoto photo, Validator validator) { validatePhoto(photo); Bitmap photoBitmap = photo.getBitmap(); Uri photoUri = photo.getImageUrl(); if (photoBitmap == null && Utility.isWebUri(photoUri) && !validator.isOpenGraphContent()) { throw new FacebookException( "Cannot set the ImageUrl of a SharePhoto to the Uri of an image on the " + "web when sharing SharePhotoContent"); } }
private static void validatePhotoForNativeDialog(SharePhoto photo, Validator validator) { validatePhotoForApi(photo, validator); if (photo.getBitmap() != null || !Utility.isWebUri(photo.getImageUrl())) { Validate.hasContentProvider(FacebookSdk.getApplicationContext()); } }
@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()) ; }
final Uri photoUri = photo.getImageUrl(); String caption = photo.getCaption(); if (caption == null) {
onPhotoStagedListener) { final Bitmap bitmap = photo.getBitmap(); final Uri imageUrl = photo.getImageUrl(); if ((bitmap != null) || (imageUrl != null)) { final GraphRequest.Callback requestCallback = new GraphRequest.Callback() {
@Test public void testPhotoBuilder() { final SharePhoto photo = ShareModelTestUtility .getPhotoBuilder(ShareModelTestUtility.PhotoBuilderType.LOCAL_URL) .build(); assertEquals(ShareModelTestUtility.getTestPhotoImageUrl(), photo.getImageUrl()); assertEquals(ShareModelTestUtility.PHOTO_USER_GENERATED, photo.getUserGenerated()); ShareModelTestUtility.assertEquals(photo, TestUtils.parcelAndUnparcel(photo)); } }