Search in sources :

Example 1 with ShareMessengerOpenGraphMusicTemplateContent

use of com.facebook.share.model.ShareMessengerOpenGraphMusicTemplateContent in project facebook-android-sdk by facebook.

the class NativeDialogParameters method create.

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());
        }
    } else if (shareContent instanceof ShareMediaContent) {
        final ShareMediaContent mediaContent = (ShareMediaContent) shareContent;
        List<Bundle> mediaInfos = ShareInternalUtility.getMediaInfos(mediaContent, callId);
        nativeParams = create(mediaContent, mediaInfos, shouldFailOnDataError);
    } else if (shareContent instanceof ShareCameraEffectContent) {
        final ShareCameraEffectContent cameraEffectContent = (ShareCameraEffectContent) shareContent;
        // Put Bitmaps behind content uris.
        Bundle attachmentUrlsBundle = ShareInternalUtility.getTextureUrlBundle(cameraEffectContent, callId);
        nativeParams = create(cameraEffectContent, attachmentUrlsBundle, shouldFailOnDataError);
    } else if (shareContent instanceof ShareMessengerGenericTemplateContent) {
        final ShareMessengerGenericTemplateContent genericTemplateContent = (ShareMessengerGenericTemplateContent) shareContent;
        nativeParams = create(genericTemplateContent, shouldFailOnDataError);
    } else if (shareContent instanceof ShareMessengerOpenGraphMusicTemplateContent) {
        final ShareMessengerOpenGraphMusicTemplateContent openGraphMusicTemplateContent = (ShareMessengerOpenGraphMusicTemplateContent) shareContent;
        nativeParams = create(openGraphMusicTemplateContent, shouldFailOnDataError);
    } else if (shareContent instanceof ShareMessengerMediaTemplateContent) {
        final ShareMessengerMediaTemplateContent mediaTemplateContent = (ShareMessengerMediaTemplateContent) shareContent;
        nativeParams = create(mediaTemplateContent, shouldFailOnDataError);
    }
    return nativeParams;
}
Also used : ShareLinkContent(com.facebook.share.model.ShareLinkContent) SharePhotoContent(com.facebook.share.model.SharePhotoContent) ShareCameraEffectContent(com.facebook.share.model.ShareCameraEffectContent) Bundle(android.os.Bundle) ShareMessengerMediaTemplateContent(com.facebook.share.model.ShareMessengerMediaTemplateContent) JSONException(org.json.JSONException) ShareMessengerGenericTemplateContent(com.facebook.share.model.ShareMessengerGenericTemplateContent) ShareMediaContent(com.facebook.share.model.ShareMediaContent) ShareOpenGraphContent(com.facebook.share.model.ShareOpenGraphContent) JSONObject(org.json.JSONObject) FacebookException(com.facebook.FacebookException) ShareVideoContent(com.facebook.share.model.ShareVideoContent) ShareMessengerOpenGraphMusicTemplateContent(com.facebook.share.model.ShareMessengerOpenGraphMusicTemplateContent) ArrayList(java.util.ArrayList) List(java.util.List)

Aggregations

Bundle (android.os.Bundle)1 FacebookException (com.facebook.FacebookException)1 ShareCameraEffectContent (com.facebook.share.model.ShareCameraEffectContent)1 ShareLinkContent (com.facebook.share.model.ShareLinkContent)1 ShareMediaContent (com.facebook.share.model.ShareMediaContent)1 ShareMessengerGenericTemplateContent (com.facebook.share.model.ShareMessengerGenericTemplateContent)1 ShareMessengerMediaTemplateContent (com.facebook.share.model.ShareMessengerMediaTemplateContent)1 ShareMessengerOpenGraphMusicTemplateContent (com.facebook.share.model.ShareMessengerOpenGraphMusicTemplateContent)1 ShareOpenGraphContent (com.facebook.share.model.ShareOpenGraphContent)1 SharePhotoContent (com.facebook.share.model.SharePhotoContent)1 ShareVideoContent (com.facebook.share.model.ShareVideoContent)1 ArrayList (java.util.ArrayList)1 List (java.util.List)1 JSONException (org.json.JSONException)1 JSONObject (org.json.JSONObject)1