Java 类com.facebook.model.OpenGraphObject 实例源码

项目:yelo-android    文件:Request.java   
/**
 * Creates a new Request configured to create a user owned Open Graph object.
 *
 * @param session
 *            the Session to use, or null; if non-null, the session must be in an opened state
 * @param openGraphObject
 *            the Open Graph object to create; must not be null, and must have a non-empty type and title
 * @param callback
 *            a callback that will be called when the request is completed to handle success or error conditions
 * @return a Request that is ready to execute
 */
public static Request newPostOpenGraphObjectRequest(Session session,
        OpenGraphObject openGraphObject, Callback callback) {
    if (openGraphObject == null) {
        throw new FacebookException("openGraphObject cannot be null");
    }
    if (Utility.isNullOrEmpty(openGraphObject.getType())) {
        throw new FacebookException("openGraphObject must have non-null 'type' property");
    }
    if (Utility.isNullOrEmpty(openGraphObject.getTitle())) {
        throw new FacebookException("openGraphObject must have non-null 'title' property");
    }

    String path = String.format(MY_OBJECTS_FORMAT, openGraphObject.getType());
    Bundle bundle = new Bundle();
    bundle.putString(OBJECT_PARAM, openGraphObject.getInnerJSONObject().toString());
    return new Request(session, path, bundle, HttpMethod.POST, callback);
}
项目:yelo-android    文件:Request.java   
/**
 * Creates a new Request configured to update a user owned Open Graph object.
 *
 * @param session
 *            the Session to use, or null; if non-null, the session must be in an opened state
 * @param openGraphObject
 *            the Open Graph object to update, which must have a valid 'id' property
 * @param callback
 *            a callback that will be called when the request is completed to handle success or error conditions
 * @return a Request that is ready to execute
 */
public static Request newUpdateOpenGraphObjectRequest(Session session, OpenGraphObject openGraphObject,
        Callback callback) {
    if (openGraphObject == null) {
        throw new FacebookException("openGraphObject cannot be null");
    }

    String path = openGraphObject.getId();
    if (path == null) {
        throw new FacebookException("openGraphObject must have an id");
    }

    Bundle bundle = new Bundle();
    bundle.putString(OBJECT_PARAM, openGraphObject.getInnerJSONObject().toString());
    return new Request(session, path, bundle, HttpMethod.POST, callback);
}
项目:ExerciseMe    文件:BadgeDialogFragment.java   
private void shareToFB(Context context, String badgeName) {
    String description = context.getResources().getText(context.getResources()
            .getIdentifier(badgeName + "FB", "string", context.getPackageName())).toString();

    String imgURL = context.getResources().getText(context.getResources()
            .getIdentifier(badgeName + "imgURL", "string", context.getPackageName())).toString();

    if (FacebookDialog.canPresentOpenGraphActionDialog(context.getApplicationContext(),
            FacebookDialog.OpenGraphActionDialogFeature.OG_ACTION_DIALOG)) {
        OpenGraphObject badge = OpenGraphObject.Factory.createForPost
                (OpenGraphObject.class, "exercisemeapp:badge", "I earned a new badge!",
                        imgURL, null, description);
        OpenGraphAction action = GraphObject.Factory.create(OpenGraphAction.class);
        action.setProperty("badge", badge);
        action.setType("exercisemeapp:earn");

        FacebookDialog shareDialog = new FacebookDialog.OpenGraphActionDialogBuilder(getActivity(), action, "badge")
                .build();
        uiHelper.trackPendingDialogCall(shareDialog.present());
    } else {
        Toast.makeText(getActivity(), "Facebook not available", Toast.LENGTH_SHORT).show();
    }
}
项目:LostAndFound    文件:FacebookDialogTests.java   
public void testOpenGraphObjectImageAttachments() throws JSONException {
    OpenGraphAction action = OpenGraphAction.Factory.createForPost("foo");
    OpenGraphObject object = OpenGraphObject.Factory.createForPost("bar");
    action.setProperty("foo", object);

    FacebookDialog.OpenGraphActionDialogBuilder builder =
            new FacebookDialog.OpenGraphActionDialogBuilder(getActivity(), action, "foo");

    Bitmap bitmap = Bitmap.createBitmap(20, 20, Bitmap.Config.ALPHA_8);

    builder.setImageAttachmentsForObject("foo", Arrays.asList(bitmap));

    List<GraphObject> images = object.getImage();
    assertNotNull(images);
    assertTrue(images.size() == 1);

    List<String> attachmentNames = builder.getImageAttachmentNames();
    assertNotNull(attachmentNames);
    assertTrue(attachmentNames.size() == 1);

    String attachmentName = getAttachmentNameFromContentUri((String) images.get(0).getProperty("url"));
    assertEquals(attachmentNames.get(0), attachmentName);
}
项目:FacebookImageShareIntent    文件:FacebookDialogTests.java   
public void testOpenGraphObjectImageAttachments() throws JSONException {
    OpenGraphAction action = OpenGraphAction.Factory.createForPost("foo");
    OpenGraphObject object = OpenGraphObject.Factory.createForPost("bar");
    action.setProperty("foo", object);

    FacebookDialog.OpenGraphActionDialogBuilder builder =
            new FacebookDialog.OpenGraphActionDialogBuilder(getActivity(), action, "foo");

    Bitmap bitmap = Bitmap.createBitmap(20, 20, Bitmap.Config.ALPHA_8);

    builder.setImageAttachmentsForObject("foo", Arrays.asList(bitmap));

    List<GraphObject> images = object.getImage();
    assertNotNull(images);
    assertTrue(images.size() == 1);

    List<String> attachmentNames = builder.getImageAttachmentNames();
    assertNotNull(attachmentNames);
    assertTrue(attachmentNames.size() == 1);

    String attachmentName = getAttachmentNameFromContentUri((String) images.get(0).getProperty("url"));
    assertEquals(attachmentNames.get(0), attachmentName);
}
项目:QuotesSocial    文件:MainPageListFragment.java   
public static void shareToFB(Activity activity, String quoteText, UiLifecycleHelper uiHelper) {
    if (FacebookDialog.canPresentOpenGraphActionDialog(activity.getApplicationContext(),
            FacebookDialog.OpenGraphActionDialogFeature.OG_ACTION_DIALOG)) {
        OpenGraphObject quote = OpenGraphObject.Factory.createForPost
                (OpenGraphObject.class, "speakeasydevfest:post", "I loved this quote!",
                        "http://i.imgur.com/ec9p33P.jpg", null, "\"" + quoteText + "\"");
        OpenGraphAction action = GraphObject.Factory.create(OpenGraphAction.class);
        action.setProperty("quote", quote);
        action.setType("speakeasydevfest:love");
        FacebookDialog shareDialog = new FacebookDialog.OpenGraphActionDialogBuilder(activity, action, "quote")
                .build();
        uiHelper.trackPendingDialogCall(shareDialog.present());
    } else {
        Toast.makeText(activity, "Facebook not available", Toast.LENGTH_SHORT).show();
    }
}
项目:yelo-android    文件:FacebookDialog.java   
void updateObjectAttachmentUrls(String objectProperty, List<String> attachmentUrls, boolean isUserGenerated) {
    final OpenGraphObject object;
    try {
        object = action.getPropertyAs(objectProperty, OpenGraphObject.class);
        if (object == null) {
            throw new IllegalArgumentException("Action does not contain a property '" + objectProperty + "'");
        }
    } catch (FacebookGraphObjectException exception) {
        throw new IllegalArgumentException("Property '" + objectProperty + "' is not a graph object");
    }
    if (!object.getCreateObject()) {
        throw new IllegalArgumentException(
                "The Open Graph object in '" + objectProperty + "' is not marked for creation");
    }

    GraphObjectList<GraphObject> attachments = object.getImage();
    if (attachments == null) {
        attachments = GraphObject.Factory.createList(GraphObject.class);
    }
    for (String url : attachmentUrls) {
        GraphObject graphObject = GraphObject.Factory.create();
        graphObject.setProperty(NativeProtocol.IMAGE_URL_KEY, url);
        if (isUserGenerated) {
            graphObject.setProperty(NativeProtocol.IMAGE_USER_GENERATED_KEY, true);
        }
        attachments.add(graphObject);
    }
    object.setImage(attachments);
}
项目:BrillaMXAndroid    文件:FacebookDialog.java   
void updateObjectAttachmentUrls(String objectProperty, List<String> attachmentUrls, boolean isUserGenerated) {
    final OpenGraphObject object;
    try {
        object = action.getPropertyAs(objectProperty, OpenGraphObject.class);
        if (object == null) {
            throw new IllegalArgumentException("Action does not contain a property '" + objectProperty + "'");
        }
    } catch (FacebookGraphObjectException exception) {
        throw new IllegalArgumentException("Property '" + objectProperty + "' is not a graph object");
    }
    if (!object.getCreateObject()) {
        throw new IllegalArgumentException(
                "The Open Graph object in '" + objectProperty + "' is not marked for creation");
    }

    GraphObjectList<GraphObject> attachments = object.getImage();
    if (attachments == null) {
        attachments = GraphObject.Factory.createList(GraphObject.class);
    }
    for (String url : attachmentUrls) {
        GraphObject graphObject = GraphObject.Factory.create();
        graphObject.setProperty(NativeProtocol.IMAGE_URL_KEY, url);
        if (isUserGenerated) {
            graphObject.setProperty(NativeProtocol.IMAGE_USER_GENERATED_KEY, true);
        }
        attachments.add(graphObject);
    }
    object.setImage(attachments);
}
项目:TP-Formation-Android    文件:FacebookDialog.java   
void updateObjectAttachmentUrls(String objectProperty, List<String> attachmentUrls, boolean isUserGenerated) {
    final OpenGraphObject object;
    try {
        object = action.getPropertyAs(objectProperty, OpenGraphObject.class);
        if (object == null) {
            throw new IllegalArgumentException("Action does not contain a property '" + objectProperty + "'");
        }
    } catch (FacebookGraphObjectException exception) {
        throw new IllegalArgumentException("Property '" + objectProperty + "' is not a graph object");
    }
    if (!object.getCreateObject()) {
        throw new IllegalArgumentException(
                "The Open Graph object in '" + objectProperty + "' is not marked for creation");
    }

    GraphObjectList<GraphObject> attachments = object.getImage();
    if (attachments == null) {
        attachments = GraphObject.Factory.createList(GraphObject.class);
    }
    for (String url : attachmentUrls) {
        GraphObject graphObject = GraphObject.Factory.create();
        graphObject.setProperty(NativeProtocol.IMAGE_URL_KEY, url);
        if (isUserGenerated) {
            graphObject.setProperty(NativeProtocol.IMAGE_USER_GENERATED_KEY, true);
        }
        attachments.add(graphObject);
    }
    object.setImage(attachments);
}
项目:AutoTimeHelper    文件:FacebookDialog.java   
void updateObjectAttachmentUrls(String objectProperty, List<String> attachmentUrls, boolean isUserGenerated) {
    final OpenGraphObject object;
    try {
        object = action.getPropertyAs(objectProperty, OpenGraphObject.class);
        if (object == null) {
            throw new IllegalArgumentException("Action does not contain a property '" + objectProperty + "'");
        }
    } catch (FacebookGraphObjectException exception) {
        throw new IllegalArgumentException("Property '" + objectProperty + "' is not a graph object");
    }
    if (!object.getCreateObject()) {
        throw new IllegalArgumentException(
                "The Open Graph object in '" + objectProperty + "' is not marked for creation");
    }

    GraphObjectList<GraphObject> attachments = object.getImage();
    if (attachments == null) {
        attachments = GraphObject.Factory.createList(GraphObject.class);
    }
    for (String url : attachmentUrls) {
        GraphObject graphObject = GraphObject.Factory.create();
        graphObject.setProperty(NativeProtocol.IMAGE_URL_KEY, url);
        if (isUserGenerated) {
            graphObject.setProperty(NativeProtocol.IMAGE_USER_GENERATED_KEY, true);
        }
        attachments.add(graphObject);
    }
    object.setImage(attachments);
}
项目:BrainStudio    文件:FacebookDialog.java   
void updateObjectAttachmentUrls(String objectProperty, List<String> attachmentUrls, boolean isUserGenerated) {
    final OpenGraphObject object;
    try {
        object = action.getPropertyAs(objectProperty, OpenGraphObject.class);
        if (object == null) {
            throw new IllegalArgumentException("Action does not contain a property '" + objectProperty + "'");
        }
    } catch (FacebookGraphObjectException exception) {
        throw new IllegalArgumentException("Property '" + objectProperty + "' is not a graph object");
    }
    if (!object.getCreateObject()) {
        throw new IllegalArgumentException(
                "The Open Graph object in '" + objectProperty + "' is not marked for creation");
    }

    GraphObjectList<GraphObject> attachments = object.getImage();
    if (attachments == null) {
        attachments = GraphObject.Factory.createList(GraphObject.class);
    }
    for (String url : attachmentUrls) {
        GraphObject graphObject = GraphObject.Factory.create();
        graphObject.setProperty(NativeProtocol.IMAGE_URL_KEY, url);
        if (isUserGenerated) {
            graphObject.setProperty(NativeProtocol.IMAGE_USER_GENERATED_KEY, true);
        }
        attachments.add(graphObject);
    }
    object.setImage(attachments);
}
项目:QuizUpWinner    文件:Request.java   
public static Request newPostOpenGraphObjectRequest(Session paramSession, OpenGraphObject paramOpenGraphObject, Callback paramCallback)
{
  if (paramOpenGraphObject == null)
    throw new FacebookException("openGraphObject cannot be null");
  if (Utility.isNullOrEmpty(paramOpenGraphObject.getType()))
    throw new FacebookException("openGraphObject must have non-null 'type' property");
  if (Utility.isNullOrEmpty(paramOpenGraphObject.getTitle()))
    throw new FacebookException("openGraphObject must have non-null 'title' property");
  Object[] arrayOfObject = new Object[1];
  arrayOfObject[0] = paramOpenGraphObject.getType();
  String str = String.format("me/objects/%s", arrayOfObject);
  Bundle localBundle = new Bundle();
  localBundle.putString("object", paramOpenGraphObject.getInnerJSONObject().toString());
  return new Request(paramSession, str, localBundle, HttpMethod.POST, paramCallback);
}
项目:QuizUpWinner    文件:Request.java   
public static Request newPostOpenGraphObjectRequest(Session paramSession, String paramString1, String paramString2, String paramString3, String paramString4, String paramString5, GraphObject paramGraphObject, Callback paramCallback)
{
  OpenGraphObject localOpenGraphObject = OpenGraphObject.Factory.createForPost(OpenGraphObject.class, paramString1, paramString2, paramString3, paramString4, paramString5);
  if (paramGraphObject != null)
    localOpenGraphObject.setData(paramGraphObject);
  return newPostOpenGraphObjectRequest(paramSession, localOpenGraphObject, paramCallback);
}
项目:QuizUpWinner    文件:Request.java   
public static Request newUpdateOpenGraphObjectRequest(Session paramSession, OpenGraphObject paramOpenGraphObject, Callback paramCallback)
{
  if (paramOpenGraphObject == null)
    throw new FacebookException("openGraphObject cannot be null");
  String str = paramOpenGraphObject.getId();
  if (str == null)
    throw new FacebookException("openGraphObject must have an id");
  Bundle localBundle = new Bundle();
  localBundle.putString("object", paramOpenGraphObject.getInnerJSONObject().toString());
  return new Request(paramSession, str, localBundle, HttpMethod.POST, paramCallback);
}
项目:QuizUpWinner    文件:Request.java   
public static Request newUpdateOpenGraphObjectRequest(Session paramSession, String paramString1, String paramString2, String paramString3, String paramString4, String paramString5, GraphObject paramGraphObject, Callback paramCallback)
{
  OpenGraphObject localOpenGraphObject = OpenGraphObject.Factory.createForPost(OpenGraphObject.class, null, paramString2, paramString3, paramString4, paramString5);
  localOpenGraphObject.setId(paramString1);
  localOpenGraphObject.setData(paramGraphObject);
  return newUpdateOpenGraphObjectRequest(paramSession, localOpenGraphObject, paramCallback);
}
项目:Qtino.SharingKit    文件:FacebookDialog.java   
void updateObjectAttachmentUrls(String objectProperty, List<String> attachmentUrls, boolean isUserGenerated) {
    final OpenGraphObject object;
    try {
        object = action.getPropertyAs(objectProperty, OpenGraphObject.class);
        if (object == null) {
            throw new IllegalArgumentException("Action does not contain a property '" + objectProperty + "'");
        }
    } catch (FacebookGraphObjectException exception) {
        throw new IllegalArgumentException("Property '" + objectProperty + "' is not a graph object");
    }
    if (!object.getCreateObject()) {
        throw new IllegalArgumentException(
                "The Open Graph object in '" + objectProperty + "' is not marked for creation");
    }

    GraphObjectList<GraphObject> attachments = object.getImage();
    if (attachments == null) {
        attachments = GraphObject.Factory.createList(GraphObject.class);
    }
    for (String url : attachmentUrls) {
        GraphObject graphObject = GraphObject.Factory.create();
        graphObject.setProperty(NativeProtocol.IMAGE_URL_KEY, url);
        if (isUserGenerated) {
            graphObject.setProperty(NativeProtocol.IMAGE_USER_GENERATED_KEY, true);
        }
        attachments.add(graphObject);
    }
    object.setImage(attachments);
}
项目:smartenit    文件:FacebookDialog.java   
void updateObjectAttachmentUrls(String objectProperty, List<String> attachmentUrls, boolean isUserGenerated) {
    final OpenGraphObject object;
    try {
        object = action.getPropertyAs(objectProperty, OpenGraphObject.class);
        if (object == null) {
            throw new IllegalArgumentException("Action does not contain a property '" + objectProperty + "'");
        }
    } catch (FacebookGraphObjectException exception) {
        throw new IllegalArgumentException("Property '" + objectProperty + "' is not a graph object");
    }
    if (!object.getCreateObject()) {
        throw new IllegalArgumentException(
                "The Open Graph object in '" + objectProperty + "' is not marked for creation");
    }

    GraphObjectList<GraphObject> attachments = object.getImage();
    if (attachments == null) {
        attachments = GraphObject.Factory.createList(GraphObject.class);
    }
    for (String url : attachmentUrls) {
        GraphObject graphObject = GraphObject.Factory.create();
        graphObject.setProperty(NativeProtocol.IMAGE_URL_KEY, url);
        if (isUserGenerated) {
            graphObject.setProperty(NativeProtocol.IMAGE_USER_GENERATED_KEY, true);
        }
        attachments.add(graphObject);
    }
    object.setImage(attachments);
}
项目:DualRunner    文件:FacebookDialog.java   
void updateObjectAttachmentUrls(String objectProperty, List<String> attachmentUrls, boolean isUserGenerated) {
    final OpenGraphObject object;
    try {
        object = action.getPropertyAs(objectProperty, OpenGraphObject.class);
        if (object == null) {
            throw new IllegalArgumentException("Action does not contain a property '" + objectProperty + "'");
        }
    } catch (FacebookGraphObjectException exception) {
        throw new IllegalArgumentException("Property '" + objectProperty + "' is not a graph object");
    }
    if (!object.getCreateObject()) {
        throw new IllegalArgumentException(
                "The Open Graph object in '" + objectProperty + "' is not marked for creation");
    }

    GraphObjectList<GraphObject> attachments = object.getImage();
    if (attachments == null) {
        attachments = GraphObject.Factory.createList(GraphObject.class);
    }
    for (String url : attachmentUrls) {
        GraphObject graphObject = GraphObject.Factory.create();
        graphObject.setProperty(NativeProtocol.IMAGE_URL_KEY, url);
        if (isUserGenerated) {
            graphObject.setProperty(NativeProtocol.IMAGE_USER_GENERATED_KEY, true);
        }
        attachments.add(graphObject);
    }
    object.setImage(attachments);
}
项目:MeNextAndroid    文件:FacebookDialog.java   
void updateObjectAttachmentUrls(String objectProperty, List<String> attachmentUrls, boolean isUserGenerated) {
    final OpenGraphObject object;
    try {
        object = action.getPropertyAs(objectProperty, OpenGraphObject.class);
        if (object == null) {
            throw new IllegalArgumentException("Action does not contain a property '" + objectProperty + "'");
        }
    } catch (FacebookGraphObjectException exception) {
        throw new IllegalArgumentException("Property '" + objectProperty + "' is not a graph object");
    }
    if (!object.getCreateObject()) {
        throw new IllegalArgumentException(
                "The Open Graph object in '" + objectProperty + "' is not marked for creation");
    }

    GraphObjectList<GraphObject> attachments = object.getImage();
    if (attachments == null) {
        attachments = GraphObject.Factory.createList(GraphObject.class);
    }
    for (String url : attachmentUrls) {
        GraphObject graphObject = GraphObject.Factory.create();
        graphObject.setProperty(NativeProtocol.IMAGE_URL_KEY, url);
        if (isUserGenerated) {
            graphObject.setProperty(NativeProtocol.IMAGE_USER_GENERATED_KEY, true);
        }
        attachments.add(graphObject);
    }
    object.setImage(attachments);
}
项目:ClassParticipation2    文件:FacebookDialog.java   
void updateObjectAttachmentUrls(String objectProperty, List<String> attachmentUrls, boolean isUserGenerated) {
    final OpenGraphObject object;
    try {
        object = action.getPropertyAs(objectProperty, OpenGraphObject.class);
        if (object == null) {
            throw new IllegalArgumentException("Action does not contain a property '" + objectProperty + "'");
        }
    } catch (FacebookGraphObjectException exception) {
        throw new IllegalArgumentException("Property '" + objectProperty + "' is not a graph object");
    }
    if (!object.getCreateObject()) {
        throw new IllegalArgumentException(
                "The Open Graph object in '" + objectProperty + "' is not marked for creation");
    }

    GraphObjectList<GraphObject> attachments = object.getImage();
    if (attachments == null) {
        attachments = GraphObject.Factory.createList(GraphObject.class);
    }
    for (String url : attachmentUrls) {
        GraphObject graphObject = GraphObject.Factory.create();
        graphObject.setProperty(NativeProtocol.IMAGE_URL_KEY, url);
        if (isUserGenerated) {
            graphObject.setProperty(NativeProtocol.IMAGE_USER_GENERATED_KEY, true);
        }
        attachments.add(graphObject);
    }
    object.setImage(attachments);
}
项目:LostAndFound    文件:FacebookDialogTests.java   
public void testCantSetObjectAttachmentsWithNullBitmaps() {
    try {
        OpenGraphAction action = OpenGraphAction.Factory.createForPost("foo");
        action.setProperty("foo", OpenGraphObject.Factory.createForPost("bar"));

        FacebookDialog.OpenGraphActionDialogBuilder builder =
                new FacebookDialog.OpenGraphActionDialogBuilder(getActivity(), action, "foo");

        builder.setImageAttachmentsForObject("foo", Arrays.asList((Bitmap)null));
        fail("expected exception");
    } catch (NullPointerException exception) {
    }
}
项目:LostAndFound    文件:FacebookDialogTests.java   
public void testOpenGraphActionAndObjectImageAttachments() throws JSONException {
    OpenGraphAction action = OpenGraphAction.Factory.createForPost("foo");
    OpenGraphObject object = OpenGraphObject.Factory.createForPost("bar");
    action.setProperty("foo", object);

    FacebookDialog.OpenGraphActionDialogBuilder builder =
            new FacebookDialog.OpenGraphActionDialogBuilder(getActivity(), action, "foo");

    Bitmap bitmap = Bitmap.createBitmap(20, 20, Bitmap.Config.ALPHA_8);

    builder.setImageAttachmentsForAction(Arrays.asList(bitmap));
    builder.setImageAttachmentsForObject("foo", Arrays.asList(bitmap));

    List<String> attachmentNames = builder.getImageAttachmentNames();
    assertNotNull(attachmentNames);
    assertTrue(attachmentNames.size() == 2);

    List<GraphObject> objectImages = object.getImage();
    assertNotNull(objectImages);
    assertTrue(objectImages.size() == 1);

    String attachmentName = getAttachmentNameFromContentUri((String) objectImages.get(0).getProperty("url"));
    assertTrue(attachmentNames.contains(attachmentName));

    List<JSONObject> actionImages = action.getImage();
    assertNotNull(actionImages);
    assertTrue(actionImages.size() == 1);

    attachmentName = getAttachmentNameFromContentUri((String) actionImages.get(0).getString("url"));
    assertTrue(attachmentNames.contains(attachmentName));
}
项目:LostAndFound    文件:FacebookDialogTests.java   
@SuppressWarnings("deprecation")
public void testOpenGraphDialogBuilderDeprecatedConstructorRequiresActionType() {
    try {
        OpenGraphAction action = OpenGraphAction.Factory.createForPost();
        OpenGraphObject object = OpenGraphObject.Factory.createForPost("bar");
        action.setProperty("object", object);
        FacebookDialog.OpenGraphActionDialogBuilder builder =
                new FacebookDialog.OpenGraphActionDialogBuilder(getActivity(), action, "", "object");

        builder.build();
        fail("expected exception");
    } catch (IllegalArgumentException exception) {
    }

}
项目:LostAndFound    文件:FacebookDialogTests.java   
@SuppressWarnings("deprecation")
public void testOpenGraphDialogBuilderDeprecatedConstructorRequiresActionTypeMatches() {
    try {
        OpenGraphAction action = OpenGraphAction.Factory.createForPost("foo");
        OpenGraphObject object = OpenGraphObject.Factory.createForPost("bar");
        action.setProperty("object", object);
        FacebookDialog.OpenGraphActionDialogBuilder builder =
                new FacebookDialog.OpenGraphActionDialogBuilder(getActivity(), action, "notfoo", "object");

        builder.build();
        fail("expected exception");
    } catch (IllegalArgumentException exception) {
    }

}
项目:PetTinder    文件:FacebookDialog.java   
void updateObjectAttachmentUrls(String objectProperty, List<String> attachmentUrls, boolean isUserGenerated) {
    final OpenGraphObject object;
    try {
        object = action.getPropertyAs(objectProperty, OpenGraphObject.class);
        if (object == null) {
            throw new IllegalArgumentException("Action does not contain a property '" + objectProperty + "'");
        }
    } catch (FacebookGraphObjectException exception) {
        throw new IllegalArgumentException("Property '" + objectProperty + "' is not a graph object");
    }
    if (!object.getCreateObject()) {
        throw new IllegalArgumentException(
                "The Open Graph object in '" + objectProperty + "' is not marked for creation");
    }

    GraphObjectList<GraphObject> attachments = object.getImage();
    if (attachments == null) {
        attachments = GraphObject.Factory.createList(GraphObject.class);
    }
    for (String url : attachmentUrls) {
        GraphObject graphObject = GraphObject.Factory.create();
        graphObject.setProperty(NativeProtocol.IMAGE_URL_KEY, url);
        if (isUserGenerated) {
            graphObject.setProperty(NativeProtocol.IMAGE_USER_GENERATED_KEY, true);
        }
        attachments.add(graphObject);
    }
    object.setImage(attachments);
}
项目:StoryTeller    文件:FacebookDialog.java   
void updateObjectAttachmentUrls(String objectProperty, List<String> attachmentUrls, boolean isUserGenerated) {
    final OpenGraphObject object;
    try {
        object = action.getPropertyAs(objectProperty, OpenGraphObject.class);
        if (object == null) {
            throw new IllegalArgumentException("Action does not contain a property '" + objectProperty + "'");
        }
    } catch (FacebookGraphObjectException exception) {
        throw new IllegalArgumentException("Property '" + objectProperty + "' is not a graph object");
    }
    if (!object.getCreateObject()) {
        throw new IllegalArgumentException(
                "The Open Graph object in '" + objectProperty + "' is not marked for creation");
    }

    GraphObjectList<GraphObject> attachments = object.getImage();
    if (attachments == null) {
        attachments = GraphObject.Factory.createList(GraphObject.class);
    }
    for (String url : attachmentUrls) {
        GraphObject graphObject = GraphObject.Factory.create();
        graphObject.setProperty(NativeProtocol.IMAGE_URL_KEY, url);
        if (isUserGenerated) {
            graphObject.setProperty(NativeProtocol.IMAGE_USER_GENERATED_KEY, true);
        }
        attachments.add(graphObject);
    }
    object.setImage(attachments);
}
项目:HereAStory-Android    文件:FacebookDialog.java   
void updateObjectAttachmentUrls(String objectProperty, List<String> attachmentUrls, boolean isUserGenerated) {
    final OpenGraphObject object;
    try {
        object = action.getPropertyAs(objectProperty, OpenGraphObject.class);
        if (object == null) {
            throw new IllegalArgumentException("Action does not contain a property '" + objectProperty + "'");
        }
    } catch (FacebookGraphObjectException exception) {
        throw new IllegalArgumentException("Property '" + objectProperty + "' is not a graph object");
    }
    if (!object.getCreateObject()) {
        throw new IllegalArgumentException(
                "The Open Graph object in '" + objectProperty + "' is not marked for creation");
    }

    GraphObjectList<GraphObject> attachments = object.getImage();
    if (attachments == null) {
        attachments = GraphObject.Factory.createList(GraphObject.class);
    }
    for (String url : attachmentUrls) {
        GraphObject graphObject = GraphObject.Factory.create();
        graphObject.setProperty(NativeProtocol.IMAGE_URL_KEY, url);
        if (isUserGenerated) {
            graphObject.setProperty(NativeProtocol.IMAGE_USER_GENERATED_KEY, true);
        }
        attachments.add(graphObject);
    }
    object.setImage(attachments);
}
项目:FacebookImageShareIntent    文件:FacebookDialogTests.java   
public void testCantSetObjectAttachmentsWithNullBitmaps() {
    try {
        OpenGraphAction action = OpenGraphAction.Factory.createForPost("foo");
        action.setProperty("foo", OpenGraphObject.Factory.createForPost("bar"));

        FacebookDialog.OpenGraphActionDialogBuilder builder =
                new FacebookDialog.OpenGraphActionDialogBuilder(getActivity(), action, "foo");

        builder.setImageAttachmentsForObject("foo", Arrays.asList((Bitmap)null));
        fail("expected exception");
    } catch (NullPointerException exception) {
    }
}
项目:FacebookImageShareIntent    文件:FacebookDialogTests.java   
public void testOpenGraphActionAndObjectImageAttachments() throws JSONException {
    OpenGraphAction action = OpenGraphAction.Factory.createForPost("foo");
    OpenGraphObject object = OpenGraphObject.Factory.createForPost("bar");
    action.setProperty("foo", object);

    FacebookDialog.OpenGraphActionDialogBuilder builder =
            new FacebookDialog.OpenGraphActionDialogBuilder(getActivity(), action, "foo");

    Bitmap bitmap = Bitmap.createBitmap(20, 20, Bitmap.Config.ALPHA_8);

    builder.setImageAttachmentsForAction(Arrays.asList(bitmap));
    builder.setImageAttachmentsForObject("foo", Arrays.asList(bitmap));

    List<String> attachmentNames = builder.getImageAttachmentNames();
    assertNotNull(attachmentNames);
    assertTrue(attachmentNames.size() == 2);

    List<GraphObject> objectImages = object.getImage();
    assertNotNull(objectImages);
    assertTrue(objectImages.size() == 1);

    String attachmentName = getAttachmentNameFromContentUri((String) objectImages.get(0).getProperty("url"));
    assertTrue(attachmentNames.contains(attachmentName));

    List<JSONObject> actionImages = action.getImage();
    assertNotNull(actionImages);
    assertTrue(actionImages.size() == 1);

    attachmentName = getAttachmentNameFromContentUri((String) actionImages.get(0).getString("url"));
    assertTrue(attachmentNames.contains(attachmentName));
}
项目:FacebookImageShareIntent    文件:FacebookDialogTests.java   
@SuppressWarnings("deprecation")
public void testOpenGraphDialogBuilderDeprecatedConstructorRequiresActionType() {
    try {
        OpenGraphAction action = OpenGraphAction.Factory.createForPost();
        OpenGraphObject object = OpenGraphObject.Factory.createForPost("bar");
        action.setProperty("object", object);
        FacebookDialog.OpenGraphActionDialogBuilder builder =
                new FacebookDialog.OpenGraphActionDialogBuilder(getActivity(), action, "", "object");

        builder.build();
        fail("expected exception");
    } catch (IllegalArgumentException exception) {
    }

}
项目:FacebookImageShareIntent    文件:FacebookDialogTests.java   
@SuppressWarnings("deprecation")
public void testOpenGraphDialogBuilderDeprecatedConstructorRequiresActionTypeMatches() {
    try {
        OpenGraphAction action = OpenGraphAction.Factory.createForPost("foo");
        OpenGraphObject object = OpenGraphObject.Factory.createForPost("bar");
        action.setProperty("object", object);
        FacebookDialog.OpenGraphActionDialogBuilder builder =
                new FacebookDialog.OpenGraphActionDialogBuilder(getActivity(), action, "notfoo", "object");

        builder.build();
        fail("expected exception");
    } catch (IllegalArgumentException exception) {
    }
}
项目:Abelana-Android    文件:FacebookDialog.java   
void updateObjectAttachmentUrls(String objectProperty, List<String> attachmentUrls, boolean isUserGenerated) {
    final OpenGraphObject object;
    try {
        object = action.getPropertyAs(objectProperty, OpenGraphObject.class);
        if (object == null) {
            throw new IllegalArgumentException("Action does not contain a property '" + objectProperty + "'");
        }
    } catch (FacebookGraphObjectException exception) {
        throw new IllegalArgumentException("Property '" + objectProperty + "' is not a graph object");
    }
    if (!object.getCreateObject()) {
        throw new IllegalArgumentException(
                "The Open Graph object in '" + objectProperty + "' is not marked for creation");
    }

    GraphObjectList<GraphObject> attachments = object.getImage();
    if (attachments == null) {
        attachments = GraphObject.Factory.createList(GraphObject.class);
    }
    for (String url : attachmentUrls) {
        GraphObject graphObject = GraphObject.Factory.create();
        graphObject.setProperty(NativeProtocol.IMAGE_URL_KEY, url);
        if (isUserGenerated) {
            graphObject.setProperty(NativeProtocol.IMAGE_USER_GENERATED_KEY, true);
        }
        attachments.add(graphObject);
    }
    object.setImage(attachments);
}
项目:localhost-android    文件:FacebookDialog.java   
void updateObjectAttachmentUrls(String objectProperty, List<String> attachmentUrls, boolean isUserGenerated) {
    final OpenGraphObject object;
    try {
        object = action.getPropertyAs(objectProperty, OpenGraphObject.class);
        if (object == null) {
            throw new IllegalArgumentException("Action does not contain a property '" + objectProperty + "'");
        }
    } catch (FacebookGraphObjectException exception) {
        throw new IllegalArgumentException("Property '" + objectProperty + "' is not a graph object");
    }
    if (!object.getCreateObject()) {
        throw new IllegalArgumentException(
                "The Open Graph object in '" + objectProperty + "' is not marked for creation");
    }

    GraphObjectList<GraphObject> attachments = object.getImage();
    if (attachments == null) {
        attachments = GraphObject.Factory.createList(GraphObject.class);
    }
    for (String url : attachmentUrls) {
        GraphObject graphObject = GraphObject.Factory.create();
        graphObject.setProperty(NativeProtocol.IMAGE_URL_KEY, url);
        if (isUserGenerated) {
            graphObject.setProperty(NativeProtocol.IMAGE_USER_GENERATED_KEY, true);
        }
        attachments.add(graphObject);
    }
    object.setImage(attachments);
}
项目:facebook-api-android-maven    文件:FacebookDialog.java   
void updateObjectAttachmentUrls(String objectProperty, List<String> attachmentUrls, boolean isUserGenerated) {
    final OpenGraphObject object;
    try {
        object = action.getPropertyAs(objectProperty, OpenGraphObject.class);
        if (object == null) {
            throw new IllegalArgumentException("Action does not contain a property '" + objectProperty + "'");
        }
    } catch (FacebookGraphObjectException exception) {
        throw new IllegalArgumentException("Property '" + objectProperty + "' is not a graph object");
    }
    if (!object.getCreateObject()) {
        throw new IllegalArgumentException(
                "The Open Graph object in '" + objectProperty + "' is not marked for creation");
    }

    GraphObjectList<GraphObject> attachments = object.getImage();
    if (attachments == null) {
        attachments = GraphObject.Factory.createList(GraphObject.class);
    }
    for (String url : attachmentUrls) {
        GraphObject graphObject = GraphObject.Factory.create();
        graphObject.setProperty(NativeProtocol.IMAGE_URL_KEY, url);
        if (isUserGenerated) {
            graphObject.setProperty(NativeProtocol.IMAGE_USER_GENERATED_KEY, true);
        }
        attachments.add(graphObject);
    }
    object.setImage(attachments);
}
项目:yelo-android    文件:Request.java   
/**
 * Creates a new Request configured to create a user owned Open Graph object.
 *
 * @param session
 *            the Session to use, or null; if non-null, the session must be in an opened state
 * @param type
 *            the fully-specified Open Graph object type (e.g., my_app_namespace:my_object_name); must not be null
 * @param title
 *            the title of the Open Graph object; must not be null
 * @param imageUrl
 *            the link to an image to be associated with the Open Graph object; may be null
 * @param url
 *            the url to be associated with the Open Graph object; may be null
 * @param description
 *            the description to be associated with the object; may be null
 * @param objectProperties
 *            any additional type-specific properties for the Open Graph object; may be null
 * @param callback
 *            a callback that will be called when the request is completed to handle success or error conditions;
 *            may be null
 * @return a Request that is ready to execute
 */
public static Request newPostOpenGraphObjectRequest(Session session, String type, String title, String imageUrl,
        String url, String description, GraphObject objectProperties, Callback callback) {
    OpenGraphObject openGraphObject = OpenGraphObject.Factory.createForPost(OpenGraphObject.class, type, title,
            imageUrl, url, description);
    if (objectProperties != null) {
        openGraphObject.setData(objectProperties);
    }

    return newPostOpenGraphObjectRequest(session, openGraphObject, callback);
}
项目:yelo-android    文件:Request.java   
/**
 * Creates a new Request configured to update a user owned Open Graph object.
 *
 * @param session
 *            the Session to use, or null; if non-null, the session must be in an opened state
 * @param id
 *            the id of the Open Graph object
 * @param title
 *            the title of the Open Graph object
 * @param imageUrl
 *            the link to an image to be associated with the Open Graph object
 * @param url
 *            the url to be associated with the Open Graph object
 * @param description
 *            the description to be associated with the object
 * @param objectProperties
 *            any additional type-specific properties for the Open Graph object
 * @param callback
 *            a callback that will be called when the request is completed to handle success or error conditions
 * @return a Request that is ready to execute
 */
public static Request newUpdateOpenGraphObjectRequest(Session session, String id, String title, String imageUrl,
        String url, String description, GraphObject objectProperties, Callback callback) {
    OpenGraphObject openGraphObject = OpenGraphObject.Factory.createForPost(OpenGraphObject.class, null, title,
            imageUrl, url, description);
    openGraphObject.setId(id);
    openGraphObject.setData(objectProperties);

    return newUpdateOpenGraphObjectRequest(session, openGraphObject, callback);
}