Java Code Examples for com.facebook.internal.Utility#putNonEmptyString()

The following examples show how to use com.facebook.internal.Utility#putNonEmptyString() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: WebDialogParameters.java    From kognitivo with Apache License 2.0 6 votes vote down vote up
public static Bundle create(AppGroupCreationContent appGroupCreationContent) {
    Bundle webParams = new Bundle();

    Utility.putNonEmptyString(
            webParams,
            ShareConstants.WEB_DIALOG_PARAM_NAME,
            appGroupCreationContent.getName());

    Utility.putNonEmptyString(
            webParams,
            ShareConstants.WEB_DIALOG_PARAM_DESCRIPTION,
            appGroupCreationContent.getDescription());

    AppGroupCreationContent.AppGroupPrivacy privacy =
            appGroupCreationContent.getAppGroupPrivacy();
    if (privacy != null) {
        Utility.putNonEmptyString(
                webParams,
                ShareConstants.WEB_DIALOG_PARAM_PRIVACY,
                privacy.toString().toLowerCase(Locale.ENGLISH));
    }

    return webParams;
}
 
Example 2
Source File: WebDialogParameters.java    From kognitivo with Apache License 2.0 6 votes vote down vote up
public static Bundle create(ShareOpenGraphContent shareOpenGraphContent) {
    Bundle params = new Bundle();

    Utility.putNonEmptyString(
            params,
            ShareConstants.WEB_DIALOG_PARAM_ACTION_TYPE,
            shareOpenGraphContent.getAction().getActionType());

    try {
        JSONObject ogJSON = ShareInternalUtility.toJSONObjectForWeb(shareOpenGraphContent);
        ogJSON = ShareInternalUtility.removeNamespacesFromOGJsonObject(ogJSON, false);
        if (ogJSON != null) {
            Utility.putNonEmptyString(
                    params,
                    ShareConstants.WEB_DIALOG_PARAM_ACTION_PROPERTIES,
                    ogJSON.toString());
        }
    } catch (JSONException e) {
        throw new FacebookException("Unable to serialize the ShareOpenGraphContent to JSON", e);
    }

    return params;
}
 
Example 3
Source File: WebDialogParameters.java    From kognitivo with Apache License 2.0 6 votes vote down vote up
public static Bundle createForFeed(ShareLinkContent shareLinkContent) {
    Bundle webParams = new Bundle();

    Utility.putNonEmptyString(
            webParams,
            ShareConstants.WEB_DIALOG_PARAM_NAME,
            shareLinkContent.getContentTitle());

    Utility.putNonEmptyString(
            webParams,
            ShareConstants.WEB_DIALOG_PARAM_DESCRIPTION,
            shareLinkContent.getContentDescription());

    Utility.putNonEmptyString(
            webParams,
            ShareConstants.WEB_DIALOG_PARAM_LINK,
            Utility.getUriString(shareLinkContent.getContentUrl()));

    Utility.putNonEmptyString(
            webParams,
            ShareConstants.WEB_DIALOG_PARAM_PICTURE,
            Utility.getUriString(shareLinkContent.getImageUrl()));

    return webParams;
}
 
Example 4
Source File: NativeDialogParameters.java    From kognitivo with Apache License 2.0 6 votes vote down vote up
private static Bundle create(
        ShareOpenGraphContent openGraphContent,
        JSONObject openGraphActionJSON,
        boolean dataErrorsFatal) {
    Bundle params = createBaseParameters(openGraphContent, dataErrorsFatal);

    // Strip namespace from preview property name
    String previewProperty = ShareInternalUtility.getFieldNameAndNamespaceFromFullName(
            openGraphContent.getPreviewPropertyName()).second;

    Utility.putNonEmptyString(
            params,
            ShareConstants.PREVIEW_PROPERTY_NAME,
            previewProperty);
    Utility.putNonEmptyString(
            params,
            ShareConstants.ACTION_TYPE,
            openGraphContent.getAction().getActionType());

    Utility.putNonEmptyString(
            params,
            ShareConstants.ACTION,
            openGraphActionJSON.toString());

    return params;
}
 
Example 5
Source File: NativeDialogParameters.java    From kognitivo with Apache License 2.0 6 votes vote down vote up
private static Bundle createBaseParameters(ShareContent content, boolean dataErrorsFatal) {
    Bundle params = new Bundle();

    Utility.putUri(params, ShareConstants.CONTENT_URL, content.getContentUrl());
    Utility.putNonEmptyString(params, ShareConstants.PLACE_ID, content.getPlaceId());
    Utility.putNonEmptyString(params, ShareConstants.REF, content.getRef());

    params.putBoolean(ShareConstants.DATA_FAILURES_FATAL, dataErrorsFatal);

    List<String> peopleIds = content.getPeopleIds();
    if (!Utility.isNullOrEmpty(peopleIds)) {
        params.putStringArrayList(
                ShareConstants.PEOPLE_IDS,
                new ArrayList<String>(peopleIds));
    }

    return params;
}
 
Example 6
Source File: LegacyNativeDialogParameters.java    From kognitivo with Apache License 2.0 6 votes vote down vote up
private static Bundle create(
        ShareOpenGraphContent openGraphContent,
        JSONObject openGraphActionJSON,
        boolean dataErrorsFatal) {
    Bundle params = createBaseParameters(openGraphContent, dataErrorsFatal);

    Utility.putNonEmptyString(
            params,
            ShareConstants.LEGACY_PREVIEW_PROPERTY_NAME,
            openGraphContent.getPreviewPropertyName());
    Utility.putNonEmptyString(
            params,
            ShareConstants.LEGACY_ACTION_TYPE,
            openGraphContent.getAction().getActionType());

    Utility.putNonEmptyString(
            params,
            ShareConstants.LEGACY_ACTION,
            openGraphActionJSON.toString());

    return params;
}
 
Example 7
Source File: LegacyNativeDialogParameters.java    From kognitivo with Apache License 2.0 6 votes vote down vote up
private static Bundle createBaseParameters(ShareContent content, boolean dataErrorsFatal) {
    Bundle params = new Bundle();

    Utility.putUri(params, ShareConstants.LEGACY_LINK, content.getContentUrl());
    Utility.putNonEmptyString(params, ShareConstants.LEGACY_PLACE_TAG, content.getPlaceId());
    Utility.putNonEmptyString(params, ShareConstants.LEGACY_REF, content.getRef());

    params.putBoolean(ShareConstants.LEGACY_DATA_FAILURES_FATAL, dataErrorsFatal);

    List<String> peopleIds = content.getPeopleIds();
    if (!Utility.isNullOrEmpty(peopleIds)) {
        params.putStringArrayList(
                ShareConstants.LEGACY_FRIEND_TAGS,
                new ArrayList<>(peopleIds));
    }

    return params;
}
 
Example 8
Source File: WebDialogParameters.java    From kognitivo with Apache License 2.0 5 votes vote down vote up
public static Bundle createForFeed(ShareFeedContent shareFeedContent) {
    Bundle webParams = new Bundle();

    Utility.putNonEmptyString(
            webParams,
            ShareConstants.FEED_TO_PARAM,
            shareFeedContent.getToId());

    Utility.putNonEmptyString(
            webParams,
            ShareConstants.FEED_LINK_PARAM,
            shareFeedContent.getLink());

    Utility.putNonEmptyString(
            webParams,
            ShareConstants.FEED_PICTURE_PARAM,
            shareFeedContent.getPicture());

    Utility.putNonEmptyString(
            webParams,
            ShareConstants.FEED_SOURCE_PARAM,
            shareFeedContent.getMediaSource());

    Utility.putNonEmptyString(
            webParams,
            ShareConstants.FEED_NAME_PARAM,
            shareFeedContent.getLinkName());

    Utility.putNonEmptyString(
            webParams,
            ShareConstants.FEED_CAPTION_PARAM,
            shareFeedContent.getLinkCaption());

    Utility.putNonEmptyString(
            webParams,
            ShareConstants.FEED_DESCRIPTION_PARAM,
            shareFeedContent.getLinkDescription());

    return webParams;
}
 
Example 9
Source File: NativeDialogParameters.java    From kognitivo with Apache License 2.0 5 votes vote down vote up
private static Bundle create(ShareLinkContent linkContent, boolean dataErrorsFatal) {
    Bundle params = createBaseParameters(linkContent, dataErrorsFatal);

    Utility.putNonEmptyString(params, ShareConstants.TITLE, linkContent.getContentTitle());
    Utility.putNonEmptyString(
            params, ShareConstants.DESCRIPTION, linkContent.getContentDescription());
    Utility.putUri(params, ShareConstants.IMAGE_URL, linkContent.getImageUrl());

    return params;
}
 
Example 10
Source File: NativeDialogParameters.java    From kognitivo with Apache License 2.0 5 votes vote down vote up
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;
}
 
Example 11
Source File: LegacyNativeDialogParameters.java    From kognitivo with Apache License 2.0 5 votes vote down vote up
private static Bundle create(ShareLinkContent linkContent, boolean dataErrorsFatal) {
    Bundle params = createBaseParameters(linkContent, dataErrorsFatal);

    Utility.putNonEmptyString(
            params, ShareConstants.LEGACY_TITLE, linkContent.getContentTitle());
    Utility.putNonEmptyString(
            params, ShareConstants.LEGACY_DESCRIPTION, linkContent.getContentDescription());
    Utility.putUri(params, ShareConstants.LEGACY_IMAGE, linkContent.getImageUrl());

    return params;
}
 
Example 12
Source File: VideoUploader.java    From kognitivo with Apache License 2.0 5 votes vote down vote up
@Override
public Bundle getParameters() {
    Bundle parameters = new Bundle();
    if (uploadContext.params != null) {
        parameters.putAll(uploadContext.params);
    }
    parameters.putString(PARAM_UPLOAD_PHASE, PARAM_VALUE_UPLOAD_FINISH_PHASE);
    parameters.putString(PARAM_SESSION_ID, uploadContext.sessionId);
    Utility.putNonEmptyString(parameters, PARAM_TITLE, uploadContext.title);
    Utility.putNonEmptyString(parameters, PARAM_DESCRIPTION, uploadContext.description);
    Utility.putNonEmptyString(parameters, PARAM_REF, uploadContext.ref);

    return parameters;
}
 
Example 13
Source File: WebDialogParameters.java    From kognitivo with Apache License 2.0 4 votes vote down vote up
public static Bundle create(GameRequestContent gameRequestContent) {
    Bundle webParams = new Bundle();

    Utility.putNonEmptyString(
            webParams,
            ShareConstants.WEB_DIALOG_PARAM_MESSAGE,
            gameRequestContent.getMessage());
    Utility.putNonEmptyString(
            webParams,
            ShareConstants.WEB_DIALOG_PARAM_TO,
            gameRequestContent.getTo());
    Utility.putNonEmptyString(
            webParams,
            ShareConstants.WEB_DIALOG_PARAM_TITLE,
            gameRequestContent.getTitle());
    Utility.putNonEmptyString(
            webParams,
            ShareConstants.WEB_DIALOG_PARAM_DATA,
            gameRequestContent.getData());
    if (gameRequestContent.getActionType() != null) {
        Utility.putNonEmptyString(
                webParams,
                ShareConstants.WEB_DIALOG_PARAM_ACTION_TYPE,
                gameRequestContent.getActionType().toString().toLowerCase(Locale.ENGLISH));
    }
    Utility.putNonEmptyString(
            webParams,
            ShareConstants.WEB_DIALOG_PARAM_OBJECT_ID,
            gameRequestContent.getObjectId());
    if (gameRequestContent.getFilters() != null) {
        Utility.putNonEmptyString(
                webParams,
                ShareConstants.WEB_DIALOG_PARAM_FILTERS,
                gameRequestContent.getFilters().toString().toLowerCase(Locale.ENGLISH));
    }
    Utility.putCommaSeparatedStringList(
            webParams,
            ShareConstants.WEB_DIALOG_PARAM_SUGGESTIONS,
            gameRequestContent.getSuggestions());
    return webParams;
}