use of com.facebook.share.model.SharePhoto in project facebook-android-sdk by facebook.
the class ShareInternalUtility method toJSONObjectForCall.
public static JSONObject toJSONObjectForCall(final UUID callId, final ShareOpenGraphContent content) throws JSONException {
final ShareOpenGraphAction action = content.getAction();
final ArrayList<NativeAppCallAttachmentStore.Attachment> attachments = new ArrayList<>();
JSONObject actionJSON = OpenGraphJSONUtility.toJSONObject(action, new OpenGraphJSONUtility.PhotoJSONProcessor() {
@Override
public JSONObject toJSONObject(SharePhoto photo) {
NativeAppCallAttachmentStore.Attachment attachment = getAttachment(callId, photo);
if (attachment == null) {
return null;
}
attachments.add(attachment);
JSONObject photoJSONObject = new JSONObject();
try {
photoJSONObject.put(NativeProtocol.IMAGE_URL_KEY, attachment.getAttachmentUrl());
if (photo.getUserGenerated()) {
photoJSONObject.put(NativeProtocol.IMAGE_USER_GENERATED_KEY, true);
}
} catch (JSONException e) {
throw new FacebookException("Unable to attach images", e);
}
return photoJSONObject;
}
});
NativeAppCallAttachmentStore.addAttachments(attachments);
// People and place tags must be moved from the share content to the open graph action
if (content.getPlaceId() != null) {
String placeTag = actionJSON.optString("place");
// share content
if (Utility.isNullOrEmpty(placeTag)) {
actionJSON.put("place", content.getPlaceId());
}
}
if (content.getPeopleIds() != null) {
JSONArray peopleTags = actionJSON.optJSONArray("tags");
Set<String> peopleIdSet = peopleTags == null ? new HashSet<String>() : Utility.jsonArrayToSet(peopleTags);
for (String peopleId : content.getPeopleIds()) {
peopleIdSet.add(peopleId);
}
actionJSON.put("tags", new JSONArray(peopleIdSet));
}
return actionJSON;
}
use of com.facebook.share.model.SharePhoto in project facebook-android-sdk by facebook.
the class WebDialogParameters method create.
public static Bundle create(SharePhotoContent sharePhotoContent) {
final Bundle params = createBaseParameters(sharePhotoContent);
final String[] urls = new String[sharePhotoContent.getPhotos().size()];
Utility.map(sharePhotoContent.getPhotos(), new Utility.Mapper<SharePhoto, String>() {
@Override
public String apply(SharePhoto item) {
return item.getImageUrl().toString();
}
}).toArray(urls);
params.putStringArray(ShareConstants.WEB_DIALOG_PARAM_MEDIA, urls);
return params;
}
use of com.facebook.share.model.SharePhoto in project facebook-android-sdk by facebook.
the class ShareContentValidation method validateVideoContent.
private static void validateVideoContent(ShareVideoContent videoContent, Validator validator) {
validator.validate(videoContent.getVideo());
SharePhoto previewPhoto = videoContent.getPreviewPhoto();
if (previewPhoto != null) {
validator.validate(previewPhoto);
}
}
use of com.facebook.share.model.SharePhoto in project react-native-fbsdk by facebook.
the class Utility method reactArrayToPhotoList.
public static List<SharePhoto> reactArrayToPhotoList(ReadableArray photos) {
List<SharePhoto> list = new ArrayList<>(photos.size());
for (int i = 0; i < photos.size(); i++) {
ReadableMap photoDetail = photos.getMap(i);
list.add(buildSharePhoto(photoDetail));
}
return list;
}
use of com.facebook.share.model.SharePhoto in project facebook-android-sdk by facebook.
the class ShareContentValidationTest method testItDoesNotAcceptShareVideoContentByWeb.
@Test(expected = FacebookException.class)
public void testItDoesNotAcceptShareVideoContentByWeb() {
SharePhoto previewPhoto = buildSharePhoto("https://facebook.com/awesome.gif");
ShareVideoContent shareVideoContent = new ShareVideoContent.Builder().setPreviewPhoto(previewPhoto).build();
ShareContentValidation.validateForWebShare(shareVideoContent);
}
Aggregations