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); }
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()); } }
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(); } }
@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()) ; }
return; final Bitmap bitmap = photo.getBitmap(); final Uri photoUri = photo.getImageUrl(); String caption = photo.getCaption();
private void stagePhoto(final SharePhoto photo, final CollectionMapper.OnMapValueCompleteListener onPhotoStagedListener) { final Bitmap bitmap = photo.getBitmap(); final Uri imageUrl = photo.getImageUrl(); if ((bitmap != null) || (imageUrl != null)) {