private static void validate(ShareContent content, Validator validator) throws FacebookException { if (content == null) { throw new FacebookException("Must provide non-null content to share"); } if (content instanceof ShareLinkContent) { validator.validate((ShareLinkContent) content); } else if (content instanceof SharePhotoContent) { validator.validate((SharePhotoContent) content); } else if (content instanceof ShareVideoContent) { validator.validate((ShareVideoContent) content); } else if (content instanceof ShareOpenGraphContent) { validator.validate((ShareOpenGraphContent) content); } }
public static String getVideoUrl(final ShareVideoContent videoContent, final UUID appCallId) { if (videoContent == null || videoContent.getVideo() == null) { return null; } NativeAppCallAttachmentStore.Attachment attachment = NativeAppCallAttachmentStore.createAttachment( appCallId, videoContent.getVideo().getLocalUrl()); ArrayList<NativeAppCallAttachmentStore.Attachment> attachments = new ArrayList<>(1); attachments.add(attachment); NativeAppCallAttachmentStore.addAttachments(attachments); return attachment.getAttachmentUrl(); }
public static synchronized void uploadAsync( ShareVideoContent videoContent, String graphNode, FacebookCallback<Sharer.Result> callback) throws FileNotFoundException { if (!initialized) { registerAccessTokenTracker(); initialized = true; } Validate.notNull(videoContent, "videoContent"); Validate.notNull(graphNode, "graphNode"); ShareVideo video = videoContent.getVideo(); Validate.notNull(video, "videoContent.video"); Uri videoUri = video.getLocalUrl(); Validate.notNull(videoUri, "videoContent.video.localUrl"); UploadContext uploadContext = new UploadContext(videoContent, graphNode, callback); uploadContext.initialize(); pendingUploads.add(uploadContext); enqueueUploadStart( uploadContext, 0); }
private UploadContext( ShareVideoContent videoContent, String graphNode, FacebookCallback<Sharer.Result> callback) { // Store off the access token right away so that under no circumstances will we // end up with different tokens between phases. We will rely on the access token tracker // to cancel pending uploads. this.accessToken = AccessToken.getCurrentAccessToken(); this.videoUri = videoContent.getVideo().getLocalUrl(); this.title = videoContent.getContentTitle(); this.description = videoContent.getContentDescription(); this.ref = videoContent.getRef(); this.graphNode = graphNode; this.callback = callback; this.params = videoContent.getVideo().getParameters(); }
public static synchronized void uploadAsync( ShareVideoContent videoContent, String targetId, FacebookCallback<Sharer.Result> callback) throws FileNotFoundException { if (!initialized) { registerAccessTokenTracker(); initialized = true; } Validate.notNull(videoContent, "videoContent"); Validate.notNull(targetId, "targetId"); ShareVideo video = videoContent.getVideo(); Validate.notNull(video, "videoContent.video"); Uri videoUri = video.getLocalUrl(); Validate.notNull(videoUri, "videoContent.video.localUrl"); UploadContext uploadContext = new UploadContext(videoContent, targetId, callback); uploadContext.initialize(); pendingUploads.add(uploadContext); enqueueUploadStart( uploadContext, 0); }
public static Bundle create( UUID callId, ShareContent shareContent, boolean shouldFailOnDataError) { Validate.notNull(shareContent, "shareContent"); Validate.notNull(callId, "callId"); Bundle nativeParams = null; if (shareContent instanceof ShareLinkContent) { final ShareLinkContent linkContent = (ShareLinkContent) shareContent; nativeParams = create(linkContent, shouldFailOnDataError); } else if (shareContent instanceof SharePhotoContent) { final SharePhotoContent photoContent = (SharePhotoContent) shareContent; List<String> photoUrls = ShareInternalUtility.getPhotoUrls( photoContent, callId); nativeParams = create(photoContent, photoUrls, shouldFailOnDataError); } else if (shareContent instanceof ShareVideoContent) { final ShareVideoContent videoContent = (ShareVideoContent) shareContent; String videoUrl = ShareInternalUtility.getVideoUrl(videoContent, callId); nativeParams = create(videoContent, videoUrl, shouldFailOnDataError); } else if (shareContent instanceof ShareOpenGraphContent) { final ShareOpenGraphContent openGraphContent = (ShareOpenGraphContent) shareContent; try { JSONObject openGraphActionJSON = ShareInternalUtility.toJSONObjectForCall( callId, openGraphContent); openGraphActionJSON = ShareInternalUtility.removeNamespacesFromOGJsonObject( openGraphActionJSON, false); nativeParams = create(openGraphContent, openGraphActionJSON, shouldFailOnDataError); } catch (final JSONException e) { throw new FacebookException( "Unable to create a JSON Object from the provided ShareOpenGraphContent: " + e.getMessage()); } } return nativeParams; }
private static Bundle create( ShareVideoContent videoContent, String videoUrl, boolean dataErrorsFatal) { Bundle params = createBaseParameters(videoContent, dataErrorsFatal); Utility.putNonEmptyString(params, ShareConstants.TITLE, videoContent.getContentTitle()); Utility.putNonEmptyString( params, ShareConstants.DESCRIPTION, videoContent.getContentDescription()); Utility.putNonEmptyString(params, ShareConstants.VIDEO_URL, videoUrl); return params; }
private static void validateVideoContent( ShareVideoContent videoContent, Validator validator) { validator.validate(videoContent.getVideo()); SharePhoto previewPhoto = videoContent.getPreviewPhoto(); if (previewPhoto != null) { validator.validate(previewPhoto); } }
public static Bundle create( UUID callId, ShareContent shareContent, boolean shouldFailOnDataError) { Validate.notNull(shareContent, "shareContent"); Validate.notNull(callId, "callId"); Bundle nativeParams = null; if (shareContent instanceof ShareLinkContent) { final ShareLinkContent linkContent = (ShareLinkContent)shareContent; nativeParams = create(linkContent, shouldFailOnDataError); } else if (shareContent instanceof SharePhotoContent) { final SharePhotoContent photoContent = (SharePhotoContent)shareContent; List<String> photoUrls = ShareInternalUtility.getPhotoUrls( photoContent, callId); nativeParams = create(photoContent, photoUrls, shouldFailOnDataError); } else if (shareContent instanceof ShareVideoContent) { final ShareVideoContent videoContent = (ShareVideoContent)shareContent; nativeParams = create(videoContent, shouldFailOnDataError); } else if (shareContent instanceof ShareOpenGraphContent) { final ShareOpenGraphContent openGraphContent = (ShareOpenGraphContent) shareContent; try { JSONObject openGraphActionJSON = ShareInternalUtility.toJSONObjectForCall( callId, openGraphContent); nativeParams = create(openGraphContent, openGraphActionJSON, shouldFailOnDataError); } catch (final JSONException e) { throw new FacebookException( "Unable to create a JSON Object from the provided ShareOpenGraphContent: " + e.getMessage()); } } return nativeParams; }
private void publishVideo(String videoUrl) { Uri videoFileUri = Uri.parse("file://" + videoUrl); ShareVideo video = new ShareVideo.Builder() .setLocalUrl(videoFileUri) .build(); ShareVideoContent content = new ShareVideoContent.Builder() .setVideo(video) .build(); shareDialog.show(content); }
public static Bundle create( UUID callId, ShareContent shareContent, boolean shouldFailOnDataError) { Validate.notNull(shareContent, "shareContent"); Validate.notNull(callId, "callId"); Bundle nativeParams = null; if (shareContent instanceof ShareLinkContent) { final ShareLinkContent linkContent = (ShareLinkContent) shareContent; nativeParams = create(linkContent, shouldFailOnDataError); } else if (shareContent instanceof SharePhotoContent) { final SharePhotoContent photoContent = (SharePhotoContent) shareContent; List<String> photoUrls = ShareInternalUtility.getPhotoUrls( photoContent, callId); nativeParams = create(photoContent, photoUrls, shouldFailOnDataError); } else if (shareContent instanceof ShareVideoContent) { final ShareVideoContent videoContent = (ShareVideoContent) shareContent; nativeParams = create(videoContent, shouldFailOnDataError); } else if (shareContent instanceof ShareOpenGraphContent) { final ShareOpenGraphContent openGraphContent = (ShareOpenGraphContent) shareContent; final ShareOpenGraphAction action = openGraphContent.getAction(); try { JSONObject openGraphActionJSON = ShareInternalUtility.toJSONObjectForCall( callId, action); openGraphActionJSON = ShareInternalUtility.removeNamespacesFromOGJsonObject( openGraphActionJSON, false); nativeParams = create(openGraphContent, openGraphActionJSON, shouldFailOnDataError); } catch (final JSONException e) { throw new FacebookException( "Unable to create a JSON Object from the provided ShareOpenGraphContent: " + e.getMessage()); } } return nativeParams; }
private static Bundle create(ShareVideoContent videoContent, boolean dataErrorsFatal) { ShareVideo video = videoContent.getVideo(); Bundle params = createBaseParameters(videoContent, dataErrorsFatal); Utility.putNonEmptyString(params, ShareConstants.TITLE, videoContent.getContentTitle()); Utility.putNonEmptyString( params, ShareConstants.DESCRIPTION, videoContent.getContentDescription()); Utility.putUri(params, ShareConstants.VIDEO_URL, video.getLocalUrl()); return params; }
public static Bundle create( UUID callId, ShareContent shareContent, boolean shouldFailOnDataError) { Validate.notNull(shareContent, "shareContent"); Validate.notNull(callId, "callId"); Bundle nativeParams = null; if (shareContent instanceof ShareLinkContent) { final ShareLinkContent linkContent = (ShareLinkContent)shareContent; nativeParams = create(linkContent, shouldFailOnDataError); } else if (shareContent instanceof SharePhotoContent) { final SharePhotoContent photoContent = (SharePhotoContent)shareContent; List<String> photoUrls = ShareInternalUtility.getPhotoUrls( photoContent, callId); nativeParams = create(photoContent, photoUrls, shouldFailOnDataError); } else if (shareContent instanceof ShareVideoContent) { final ShareVideoContent videoContent = (ShareVideoContent)shareContent; nativeParams = create(videoContent, shouldFailOnDataError); } else if (shareContent instanceof ShareOpenGraphContent) { final ShareOpenGraphContent openGraphContent = (ShareOpenGraphContent) shareContent; final ShareOpenGraphAction action = openGraphContent.getAction(); try { JSONObject openGraphActionJSON = ShareInternalUtility.toJSONObjectForCall( callId, action); nativeParams = create(openGraphContent, openGraphActionJSON, shouldFailOnDataError); } catch (final JSONException e) { throw new FacebookException( "Unable to create a JSON Object from the provided ShareOpenGraphContent: " + e.getMessage()); } } return nativeParams; }
private UploadContext( ShareVideoContent videoContent, String targetId, FacebookCallback<Sharer.Result> callback) { // Store off the access token right away so that under no circumstances will we // end up with different tokens between phases. We will rely on the access token tracker // to cancel pending uploads. this.accessToken = AccessToken.getCurrentAccessToken(); this.videoUri = videoContent.getVideo().getLocalUrl(); this.title = videoContent.getContentTitle(); this.description = videoContent.getContentDescription(); this.ref = videoContent.getRef(); this.targetId = targetId; this.callback = callback; }
@Override public void validate(final ShareVideoContent videoContent) { throw new FacebookException("Cannot share ShareVideoContent via web sharing dialogs"); }
public void validate(final ShareVideoContent videoContent) { validateVideoContent(videoContent, this); }
private static Bundle create(ShareVideoContent videoContent, boolean dataErrorsFatal) { // Not supported return null; }
public static synchronized void uploadAsync( ShareVideoContent videoContent, FacebookCallback<Sharer.Result> callback) throws FileNotFoundException { uploadAsync(videoContent, "me", callback); }