com.facebook.model.OpenGraphAction Java Examples
The following examples show how to use
com.facebook.model.OpenGraphAction.
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: FacebookDialogTests.java From FacebookImageShareIntent with MIT License | 6 votes |
public void testOpenGraphActionImageAttachments() throws JSONException { OpenGraphAction action = OpenGraphAction.Factory.createForPost("foo"); action.setProperty("foo", "bar"); FacebookDialog.OpenGraphActionDialogBuilder builder = new FacebookDialog.OpenGraphActionDialogBuilder(getActivity(), action, "foo"); Bitmap bitmap = Bitmap.createBitmap(20, 20, Bitmap.Config.ALPHA_8); builder.setImageAttachmentsForAction(Arrays.asList(bitmap)); List<JSONObject> images = action.getImage(); assertNotNull(images); assertTrue(images.size() == 1); List<String> attachmentNames = builder.getImageAttachmentNames(); assertNotNull(attachmentNames); assertTrue(attachmentNames.size() == 1); String attachmentName = getAttachmentNameFromContentUri(images.get(0).getString("url")); assertEquals(attachmentNames.get(0), attachmentName); }
Example #2
Source File: FacebookDialog.java From facebook-api-android-maven with Apache License 2.0 | 6 votes |
/** * Constructor. * * @param activity the Activity which is presenting the native Open Graph action publish dialog; * must not be null * @param action the Open Graph action to be published, which must contain a reference to at least one * Open Graph object with the property name specified by setPreviewPropertyName; the action * must have had its type specified via the {@link OpenGraphAction#setType(String)} method * @param previewPropertyName the name of a property on the Open Graph action that contains the * Open Graph object which will be displayed as a preview to the user */ public OpenGraphDialogBuilderBase(Activity activity, OpenGraphAction action, String previewPropertyName) { super(activity); Validate.notNull(action, "action"); Validate.notNullOrEmpty(action.getType(), "action.getType()"); Validate.notNullOrEmpty(previewPropertyName, "previewPropertyName"); if (action.getProperty(previewPropertyName) == null) { throw new IllegalArgumentException( "A property named \"" + previewPropertyName + "\" was not found on the action. The name of " + "the preview property must match the name of an action property."); } this.action = action; this.actionType = action.getType(); this.previewPropertyName = previewPropertyName; }
Example #3
Source File: FacebookDialog.java From facebook-api-android-maven with Apache License 2.0 | 6 votes |
/** * Constructor. * * @param activity the Activity which is presenting the native Open Graph action publish dialog; * must not be null * @param action the Open Graph action to be published, which must contain a reference to at least one * Open Graph object with the property name specified by setPreviewPropertyName; the action * must have had its type specified via the {@link OpenGraphAction#setType(String)} method * @param actionType the type of the Open Graph action to be published, which should be the namespace-qualified * name of the action type (e.g., "myappnamespace:myactiontype"); this will override the type * of the action passed in. * @param previewPropertyName the name of a property on the Open Graph action that contains the * Open Graph object which will be displayed as a preview to the user */ @Deprecated public OpenGraphDialogBuilderBase(Activity activity, OpenGraphAction action, String actionType, String previewPropertyName) { super(activity); Validate.notNull(action, "action"); Validate.notNullOrEmpty(actionType, "actionType"); Validate.notNullOrEmpty(previewPropertyName, "previewPropertyName"); if (action.getProperty(previewPropertyName) == null) { throw new IllegalArgumentException( "A property named \"" + previewPropertyName + "\" was not found on the action. The name of " + "the preview property must match the name of an action property."); } String typeOnAction = action.getType(); if (!Utility.isNullOrEmpty(typeOnAction) && !typeOnAction.equals(actionType)) { throw new IllegalArgumentException("'actionType' must match the type of 'action' if it is specified. " + "Consider using OpenGraphDialogBuilderBase(Activity activity, OpenGraphAction action, " + "String previewPropertyName) instead."); } this.action = action; this.actionType = actionType; this.previewPropertyName = previewPropertyName; }
Example #4
Source File: FacebookDialog.java From Abelana-Android with Apache License 2.0 | 6 votes |
/** * Constructor. * * @param activity the Activity which is presenting the native Open Graph action publish dialog; * must not be null * @param action the Open Graph action to be published, which must contain a reference to at least one * Open Graph object with the property name specified by setPreviewPropertyName; the action * must have had its type specified via the {@link OpenGraphAction#setType(String)} method * @param previewPropertyName the name of a property on the Open Graph action that contains the * Open Graph object which will be displayed as a preview to the user */ public OpenGraphDialogBuilderBase(Activity activity, OpenGraphAction action, String previewPropertyName) { super(activity); Validate.notNull(action, "action"); Validate.notNullOrEmpty(action.getType(), "action.getType()"); Validate.notNullOrEmpty(previewPropertyName, "previewPropertyName"); if (action.getProperty(previewPropertyName) == null) { throw new IllegalArgumentException( "A property named \"" + previewPropertyName + "\" was not found on the action. The name of " + "the preview property must match the name of an action property."); } this.action = action; this.actionType = action.getType(); this.previewPropertyName = previewPropertyName; }
Example #5
Source File: FacebookDialogTests.java From FacebookImageShareIntent with MIT License | 6 votes |
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); }
Example #6
Source File: FacebookDialog.java From Abelana-Android with Apache License 2.0 | 6 votes |
/** * Constructor. * * @param activity the Activity which is presenting the native Open Graph action publish dialog; * must not be null * @param action the Open Graph action to be published, which must contain a reference to at least one * Open Graph object with the property name specified by setPreviewPropertyName; the action * must have had its type specified via the {@link OpenGraphAction#setType(String)} method * @param actionType the type of the Open Graph action to be published, which should be the namespace-qualified * name of the action type (e.g., "myappnamespace:myactiontype"); this will override the type * of the action passed in. * @param previewPropertyName the name of a property on the Open Graph action that contains the * Open Graph object which will be displayed as a preview to the user */ @Deprecated public OpenGraphDialogBuilderBase(Activity activity, OpenGraphAction action, String actionType, String previewPropertyName) { super(activity); Validate.notNull(action, "action"); Validate.notNullOrEmpty(actionType, "actionType"); Validate.notNullOrEmpty(previewPropertyName, "previewPropertyName"); if (action.getProperty(previewPropertyName) == null) { throw new IllegalArgumentException( "A property named \"" + previewPropertyName + "\" was not found on the action. The name of " + "the preview property must match the name of an action property."); } String typeOnAction = action.getType(); if (!Utility.isNullOrEmpty(typeOnAction) && !typeOnAction.equals(actionType)) { throw new IllegalArgumentException("'actionType' must match the type of 'action' if it is specified. " + "Consider using OpenGraphDialogBuilderBase(Activity activity, OpenGraphAction action, " + "String previewPropertyName) instead."); } this.action = action; this.actionType = actionType; this.previewPropertyName = previewPropertyName; }
Example #7
Source File: FacebookDialogTests.java From FacebookImageShareIntent with MIT License | 5 votes |
@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) { } }
Example #8
Source File: FacebookDialogTests.java From FacebookImageShareIntent with MIT License | 5 votes |
public void testCantSetAttachmentsWithNullBitmaps() { try { OpenGraphAction action = OpenGraphAction.Factory.createForPost("foo"); action.setProperty("foo", "bar"); FacebookDialog.OpenGraphActionDialogBuilder builder = new FacebookDialog.OpenGraphActionDialogBuilder(getActivity(), action, "foo"); builder.setImageAttachmentsForAction(Arrays.asList((Bitmap)null)); fail("expected exception"); } catch (NullPointerException exception) { } }
Example #9
Source File: FacebookDialogTests.java From FacebookImageShareIntent with MIT License | 5 votes |
@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) { } }
Example #10
Source File: FacebookDialogTests.java From FacebookImageShareIntent with MIT License | 5 votes |
public void testOpenGraphDialogBuilderRequiresPreviewPropertyToExist() { try { FacebookDialog.OpenGraphActionDialogBuilder builder = new FacebookDialog.OpenGraphActionDialogBuilder(getActivity(), OpenGraphAction.Factory.createForPost("foo"), "nosuchproperty"); builder.build(); fail("expected exception"); } catch (IllegalArgumentException exception) { } }
Example #11
Source File: FacebookDialogTests.java From FacebookImageShareIntent with MIT License | 5 votes |
public void testOpenGraphDialogBuilderRequiresPreviewPropertyName() { try { FacebookDialog.OpenGraphActionDialogBuilder builder = new FacebookDialog.OpenGraphActionDialogBuilder(getActivity(), OpenGraphAction.Factory.createForPost("foo"), null); builder.build(); fail("expected exception"); } catch (IllegalArgumentException exception) { } }
Example #12
Source File: FacebookDialogTests.java From FacebookImageShareIntent with MIT License | 5 votes |
public void testOpenGraphDialogBuilderRequiresActionType() { try { FacebookDialog.OpenGraphActionDialogBuilder builder = new FacebookDialog.OpenGraphActionDialogBuilder(getActivity(), OpenGraphAction.Factory.createForPost(null), "foo"); builder.build(); fail("expected exception"); } catch (IllegalArgumentException exception) { } }
Example #13
Source File: FacebookDialogTests.java From FacebookImageShareIntent with MIT License | 5 votes |
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)); }
Example #14
Source File: FacebookDialogTests.java From FacebookImageShareIntent with MIT License | 5 votes |
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) { } }
Example #15
Source File: FacebookDialogTests.java From FacebookImageShareIntent with MIT License | 5 votes |
public void testCantSetObjectAttachmentsWithNonGraphObjectProperty() { try { OpenGraphAction action = OpenGraphAction.Factory.createForPost("foo"); FacebookDialog.OpenGraphActionDialogBuilder builder = new FacebookDialog.OpenGraphActionDialogBuilder(getActivity(), action, "foo"); action.setProperty("foo", "bar"); builder.setImageAttachmentsForObject("foo", new ArrayList<Bitmap>()); fail("expected exception"); } catch (IllegalArgumentException exception) { } }
Example #16
Source File: FacebookDialogTests.java From FacebookImageShareIntent with MIT License | 5 votes |
public void testCantSetObjectAttachmentsWithoutObjectProperty() { try { OpenGraphAction action = OpenGraphAction.Factory.createForPost("foo"); FacebookDialog.OpenGraphActionDialogBuilder builder = new FacebookDialog.OpenGraphActionDialogBuilder(getActivity(), action, "foo"); builder.setImageAttachmentsForObject("foo", new ArrayList<Bitmap>()); fail("expected exception"); } catch (IllegalArgumentException exception) { } }
Example #17
Source File: FacebookDialog.java From Abelana-Android with Apache License 2.0 | 2 votes |
/** * Constructor. * * @param activity the Activity which is presenting the native Open Graph action publish dialog; * must not be null * @param action the Open Graph action to be published, which must contain a reference to at least one * Open Graph object with the property name specified by setPreviewPropertyName; the action * must have had its type specified via the {@link OpenGraphAction#setType(String)} method * @param actionType the type of the Open Graph action to be published, which should be the namespace-qualified * name of the action type (e.g., "myappnamespace:myactiontype"); this will override the type * of the action passed in. * @param previewPropertyName the name of a property on the Open Graph action that contains the * Open Graph object which will be displayed as a preview to the user */ @Deprecated public OpenGraphActionDialogBuilder(Activity activity, OpenGraphAction action, String actionType, String previewPropertyName) { super(activity, action, actionType, previewPropertyName); }
Example #18
Source File: FacebookDialog.java From Abelana-Android with Apache License 2.0 | 2 votes |
/** * Constructor. * * @param activity the Activity which is presenting the native Open Graph action publish dialog; * must not be null * @param action the Open Graph action to be published, which must contain a reference to at least one * Open Graph object with the property name specified by setPreviewPropertyName; the action * must have had its type specified via the {@link OpenGraphAction#setType(String)} method * @param previewPropertyName the name of a property on the Open Graph action that contains the * Open Graph object which will be displayed as a preview to the user */ public OpenGraphActionDialogBuilder(Activity activity, OpenGraphAction action, String previewPropertyName) { super(activity, action, previewPropertyName); }
Example #19
Source File: FacebookDialog.java From Abelana-Android with Apache License 2.0 | 2 votes |
/** * Constructor. * * @param activity the Activity which is presenting the native Open Graph action message dialog; * must not be null * @param action the Open Graph action to be sent, which must contain a reference to at least one * Open Graph object with the property name specified by setPreviewPropertyName; the action * must have had its type specified via the {@link OpenGraphAction#setType(String)} method * @param previewPropertyName the name of a property on the Open Graph action that contains the * Open Graph object which will be displayed as a preview to the user */ public OpenGraphMessageDialogBuilder(Activity activity, OpenGraphAction action, String previewPropertyName) { super(activity, action, previewPropertyName); }
Example #20
Source File: FacebookDialog.java From facebook-api-android-maven with Apache License 2.0 | 2 votes |
/** * Constructor. * * @param activity the Activity which is presenting the native Open Graph action publish dialog; * must not be null * @param action the Open Graph action to be published, which must contain a reference to at least one * Open Graph object with the property name specified by setPreviewPropertyName; the action * must have had its type specified via the {@link OpenGraphAction#setType(String)} method * @param actionType the type of the Open Graph action to be published, which should be the namespace-qualified * name of the action type (e.g., "myappnamespace:myactiontype"); this will override the type * of the action passed in. * @param previewPropertyName the name of a property on the Open Graph action that contains the * Open Graph object which will be displayed as a preview to the user */ @Deprecated public OpenGraphActionDialogBuilder(Activity activity, OpenGraphAction action, String actionType, String previewPropertyName) { super(activity, action, actionType, previewPropertyName); }
Example #21
Source File: FacebookDialog.java From facebook-api-android-maven with Apache License 2.0 | 2 votes |
/** * Constructor. * * @param activity the Activity which is presenting the native Open Graph action publish dialog; * must not be null * @param action the Open Graph action to be published, which must contain a reference to at least one * Open Graph object with the property name specified by setPreviewPropertyName; the action * must have had its type specified via the {@link OpenGraphAction#setType(String)} method * @param previewPropertyName the name of a property on the Open Graph action that contains the * Open Graph object which will be displayed as a preview to the user */ public OpenGraphActionDialogBuilder(Activity activity, OpenGraphAction action, String previewPropertyName) { super(activity, action, previewPropertyName); }
Example #22
Source File: FacebookDialog.java From facebook-api-android-maven with Apache License 2.0 | 2 votes |
/** * Constructor. * * @param activity the Activity which is presenting the native Open Graph action message dialog; * must not be null * @param action the Open Graph action to be sent, which must contain a reference to at least one * Open Graph object with the property name specified by setPreviewPropertyName; the action * must have had its type specified via the {@link OpenGraphAction#setType(String)} method * @param previewPropertyName the name of a property on the Open Graph action that contains the * Open Graph object which will be displayed as a preview to the user */ public OpenGraphMessageDialogBuilder(Activity activity, OpenGraphAction action, String previewPropertyName) { super(activity, action, previewPropertyName); }
Example #23
Source File: BaseListElement.java From FacebookNewsfeedSample-Android with Apache License 2.0 | 2 votes |
/** * Populate an OpenGraphAction with the results of this list element. * * @param action the action to populate with data */ protected abstract void populateOGAction(OpenGraphAction action);