Java Code Examples for com.facebook.model.GraphObjectList#add()
The following examples show how to use
com.facebook.model.GraphObjectList#add() .
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: AuthorizationClientTests.java From FacebookImageShareIntent with MIT License | 6 votes |
@Override Request createGetPermissionsRequest(String accessToken) { final List<String> permissions = permissionsToReport; return new MockRequest() { @Override public Response createResponse() { GraphObject permissionsObject = GraphObject.Factory.create(); if (permissions != null) { for (String permission : permissions) { permissionsObject.setProperty(permission, 1); } } GraphObjectList<GraphObject> data = GraphObject.Factory.createList(GraphObject.class); data.add(permissionsObject); GraphMultiResult result = GraphObject.Factory.create(GraphMultiResult.class); result.setProperty("data", data); return new Response(this, null, null, result, false); } }; }
Example 2
Source File: FacebookDialog.java From Abelana-Android with Apache License 2.0 | 5 votes |
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); }
Example 3
Source File: FacebookDialog.java From facebook-api-android-maven with Apache License 2.0 | 5 votes |
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); }