Builder readFrom(final Parcel parcel) { return this.readFrom( (SharePhoto) parcel.readParcelable(SharePhoto.class.getClassLoader())); }
/** * Adds a photo to the content. * @param photo {@link com.facebook.share.model.SharePhoto} to add. * @return The builder. */ public Builder addPhoto(@Nullable final SharePhoto photo) { if (photo != null) { this.photos.add(new SharePhoto.Builder().readFrom(photo).build()); } return this; }
/** * Adds a medium to the content. * * @param medium {@link com.facebook.share.model.ShareMedia} to add. * @return The builder. */ public Builder addMedium(@Nullable final ShareMedia medium) { if (medium != null) { ShareMedia mediumToAdd; if (medium instanceof SharePhoto) { mediumToAdd = new SharePhoto.Builder().readFrom((SharePhoto) medium).build(); } else if (medium instanceof ShareVideo) { mediumToAdd = new ShareVideo.Builder().readFrom((ShareVideo) medium).build(); } else { throw new IllegalArgumentException( "medium must be either a SharePhoto or ShareVideo"); } this.media.add(mediumToAdd); } return this; }
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(); } }
ShareVideoContent(final Parcel in) { super(in); this.contentDescription = in.readString(); this.contentTitle = in.readString(); SharePhoto.Builder previewPhotoBuilder = new SharePhoto.Builder().readFrom(in); if (previewPhotoBuilder.getImageUrl() != null || previewPhotoBuilder.getBitmap() != null) { this.previewPhoto = previewPhotoBuilder.build(); } else { this.previewPhoto = null; } this.video = new ShareVideo.Builder().readFrom(in).build(); }
/** * Sets the photo to be used as a preview for the video. * @param previewPhoto Preview {@link com.facebook.share.model.SharePhoto} for the content. * @return The builder. */ public Builder setPreviewPhoto(@Nullable final SharePhoto previewPhoto) { this.previewPhoto = ( previewPhoto == null ? null : new SharePhoto.Builder().readFrom(previewPhoto).build()); return this; }