Java 类com.facebook.share.model.ShareOpenGraphObject 实例源码

项目:android-oss    文件:ThanksShareViewHolder.java   
private void startShareOnFacebook(final @NonNull Project project) {
  if (!ShareDialog.canShow(ShareLinkContent.class)) {
    return;
  }

  final Photo photo = project.photo();
  final ShareOpenGraphObject object = new ShareOpenGraphObject.Builder()
    .putString("og:type", "kickstarter:project")
    .putString("og:title", project.name())
    .putString("og:description", project.blurb())
    .putString("og:image", photo == null ? null : photo.small())
    .putString("og:url", project.webProjectUrl())
    .build();

  final ShareOpenGraphAction action = new ShareOpenGraphAction.Builder()
    .setActionType("kickstarter:back")
    .putObject("project", object)
    .build();

  final ShareOpenGraphContent content = new ShareOpenGraphContent.Builder()
    .setPreviewPropertyName("project")
    .setAction(action)
    .build();

  this.shareDialog.show(content);
}
项目:kognitivo    文件:OpenGraphJSONUtility.java   
private static JSONObject toJSONObject(
        final ShareOpenGraphObject object,
        final PhotoJSONProcessor photoJSONProcessor) throws JSONException {
    final JSONObject result = new JSONObject();
    final Set<String> keys = object.keySet();
    for (String key : keys) {
        result.put(key, toJSONValue(object.get(key), photoJSONProcessor));
    }
    return result;
}
项目:kognitivo    文件:OpenGraphJSONUtility.java   
public static Object toJSONValue(
        @Nullable final Object object,
        final PhotoJSONProcessor photoJSONProcessor) throws JSONException {
    if (object == null) {
        return JSONObject.NULL;
    }
    if ((object instanceof String) ||
            (object instanceof Boolean) ||
            (object instanceof Double) ||
            (object instanceof Float) ||
            (object instanceof Integer) ||
            (object instanceof Long)) {
        return object;
    }
    if (object instanceof SharePhoto) {
        if (photoJSONProcessor != null) {
            return photoJSONProcessor.toJSONObject((SharePhoto) object);
        }
        return null;
    }
    if (object instanceof ShareOpenGraphObject) {
        return toJSONObject((ShareOpenGraphObject) object, photoJSONProcessor);
    }
    if (object instanceof List) {
        return toJSONArray((List) object, photoJSONProcessor);
    }
    throw new IllegalArgumentException(
            "Invalid object found for JSON serialization: " +object.toString());
}
项目:kognitivo    文件:ShareContentValidation.java   
private static void validateOpenGraphObject(
        ShareOpenGraphObject openGraphObject,
        Validator validator) {
    if (openGraphObject == null) {
        throw new FacebookException("Cannot share a null ShareOpenGraphObject");
    }

    validator.validate((ShareOpenGraphValueContainer) openGraphObject, true);
}
项目:kognitivo    文件:ShareContentValidation.java   
private static void validateOpenGraphValueContainerObject(
        Object o, Validator validator) {
    if (o instanceof ShareOpenGraphObject) {
        validator.validate((ShareOpenGraphObject) o);
    } else if (o instanceof SharePhoto) {
        validator.validate((SharePhoto) o);
    }
}
项目:SjekkUT    文件:CheckinAndSocialView.java   
private ShareContent getFacebookShareContent(@NonNull PlaceCheckin theCheckin, @NonNull Place place, String applink) {
    ShareOpenGraphObject.Builder objectBuilder = new ShareOpenGraphObject.Builder()
            .putString("og:type", "fitness.course")
            .putString("og:url", applink)
            .putString("og:title", getContext().getString(R.string.share_title, place.getName()));

    if (place.getDescription() != null) {
        objectBuilder.putString("og:description", place.getDescription());
    }

    if (place.hasLocation()) {
        objectBuilder.putDouble("fitness:metrics:location:latitude", place.getLocation().getLatitude());
        objectBuilder.putDouble("fitness:metrics:location:longitude", place.getLocation().getLongitude());
    }

    // Create an action
    ShareOpenGraphAction.Builder actionBuilder = new ShareOpenGraphAction.Builder()
            .setActionType("fitness.walks")
            .putObject("fitness:course", objectBuilder.build());
    if (theCheckin.getImageUrl(SHARE_IMAGE_WIDTH) != null) {
        SharePhoto photo = new SharePhoto.Builder()
                .setImageUrl(Uri.parse(theCheckin.getImageUrl(SHARE_IMAGE_WIDTH)))
                .setUserGenerated(true)
                .build();
        ArrayList<SharePhoto> photoArray = new ArrayList<>();
        photoArray.add(photo);
        actionBuilder.putPhotoArrayList("image", photoArray);
    }

    return new ShareOpenGraphContent.Builder()
            .setPreviewPropertyName("fitness:course")
            .setAction(actionBuilder.build())
            .build();
}
项目:Move-Alarm_ORCA    文件:OpenGraphJSONUtility.java   
private static JSONObject toJSONObject(
        final ShareOpenGraphObject object,
        final PhotoJSONProcessor photoJSONProcessor) throws JSONException {
    final JSONObject result = new JSONObject();
    final Set<String> keys = object.keySet();
    for (String key : keys) {
        result.put(key, toJSONValue(object.get(key), photoJSONProcessor));
    }
    return result;
}
项目:Move-Alarm_ORCA    文件:OpenGraphJSONUtility.java   
public static Object toJSONValue(
        @Nullable final Object object,
        final PhotoJSONProcessor photoJSONProcessor) throws JSONException {
    if (object == null) {
        return JSONObject.NULL;
    }
    if ((object instanceof String) ||
            (object instanceof Boolean) ||
            (object instanceof Double) ||
            (object instanceof Float) ||
            (object instanceof Integer) ||
            (object instanceof Long)) {
        return object;
    }
    if (object instanceof SharePhoto) {
        if (photoJSONProcessor != null) {
            return photoJSONProcessor.toJSONObject((SharePhoto) object);
        }
        return null;
    }
    if (object instanceof ShareOpenGraphObject) {
        return toJSONObject((ShareOpenGraphObject) object, photoJSONProcessor);
    }
    if (object instanceof List) {
        return toJSONArray((List) object, photoJSONProcessor);
    }
    throw new IllegalArgumentException(
            "Invalid object found for JSON serialization: " +object.toString());
}
项目:Move-Alarm_ORCA    文件:ShareContentValidation.java   
private static void validateOpenGraphObject(
        ShareOpenGraphObject openGraphObject,
        Validator validator) {
    if (openGraphObject == null) {
        throw new FacebookException("Cannot share a null ShareOpenGraphObject");
    }

    validator.validate((ShareOpenGraphValueContainer) openGraphObject, true);
}
项目:Move-Alarm_ORCA    文件:ShareContentValidation.java   
private static void validateOpenGraphValueContainerObject(
        Object o, Validator validator) {
    if (o instanceof ShareOpenGraphObject) {
        validator.validate((ShareOpenGraphObject) o);
    } else if (o instanceof SharePhoto) {
        validator.validate((SharePhoto) o);
    }
}
项目:SocioBlood    文件:OpenGraphJSONUtility.java   
private static JSONObject toJSONObject(
        final ShareOpenGraphObject object,
        final PhotoJSONProcessor photoJSONProcessor) throws JSONException {
    final JSONObject result = new JSONObject();
    final Set<String> keys = object.keySet();
    for (String key : keys) {
        result.put(key, toJSONValue(object.get(key), photoJSONProcessor));
    }
    return result;
}
项目:SocioBlood    文件:OpenGraphJSONUtility.java   
public static Object toJSONValue(
        @Nullable final Object object,
        final PhotoJSONProcessor photoJSONProcessor) throws JSONException {
    if (object == null) {
        return JSONObject.NULL;
    }
    if ((object instanceof String) ||
            (object instanceof Boolean) ||
            (object instanceof Double) ||
            (object instanceof Float) ||
            (object instanceof Integer) ||
            (object instanceof Long)) {
        return object;
    }
    if (object instanceof SharePhoto) {
        if (photoJSONProcessor != null) {
            return photoJSONProcessor.toJSONObject((SharePhoto) object);
        }
        return null;
    }
    if (object instanceof ShareOpenGraphObject) {
        return toJSONObject((ShareOpenGraphObject) object, photoJSONProcessor);
    }
    if (object instanceof List) {
        return toJSONArray((List) object, photoJSONProcessor);
    }
    throw new IllegalArgumentException(
            "Invalid object found for JSON serialization: " +object.toString());
}
项目:SocioBlood    文件:ShareContentValidation.java   
private static void validateOpenGraphObject(
        ShareOpenGraphObject openGraphObject,
        Validator validator) {
    if (openGraphObject == null) {
        throw new FacebookException("Cannot share a null ShareOpenGraphObject");
    }

    validator.validate((ShareOpenGraphValueContainer) openGraphObject, true);
}
项目:SocioBlood    文件:ShareContentValidation.java   
private static void validateOpenGraphValueContainerObject(
        Object o, Validator validator) {
    if (o instanceof ShareOpenGraphObject) {
        validator.validate((ShareOpenGraphObject) o);
    } else if (o instanceof SharePhoto) {
        validator.validate((SharePhoto) o);
    }
}
项目:kognitivo    文件:ShareContentValidation.java   
public void validate(final ShareOpenGraphObject openGraphObject) {
    validateOpenGraphObject(openGraphObject, this);
}
项目:Move-Alarm_ORCA    文件:ShareContentValidation.java   
public void validate(final ShareOpenGraphObject openGraphObject) {
    validateOpenGraphObject(openGraphObject, this);
}
项目:SocioBlood    文件:ShareContentValidation.java   
public void validate(final ShareOpenGraphObject openGraphObject) {
    validateOpenGraphObject(openGraphObject, this);
}