com.facebook.model.GraphObjectList Java Examples
The following examples show how to use
com.facebook.model.GraphObjectList.
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: Response.java From barterli_android with Apache License 2.0 | 5 votes |
Response(Request request, HttpURLConnection connection, GraphObjectList<GraphObject> graphObjects, boolean isFromCache) { this.request = request; this.connection = connection; this.graphObject = null; this.graphObjectList = graphObjects; this.isFromCache = isFromCache; this.error = null; }
Example #3
Source File: Response.java From platform-friends-android with BSD 2-Clause "Simplified" License | 5 votes |
Response(Request request, HttpURLConnection connection, GraphObjectList<GraphObject> graphObjects, boolean isFromCache) { this.request = request; this.connection = connection; this.graphObject = null; this.graphObjectList = graphObjects; this.isFromCache = isFromCache; this.error = null; }
Example #4
Source File: Response.java From KlyphMessenger with MIT License | 5 votes |
Response(Request request, HttpURLConnection connection, GraphObjectList<GraphObject> graphObjects, boolean isFromCache) { this.request = request; this.connection = connection; this.graphObject = null; this.graphObjectList = graphObjects; this.isFromCache = isFromCache; this.error = null; }
Example #5
Source File: Response.java From platform-friends-android with BSD 2-Clause "Simplified" License | 5 votes |
private static Response createResponseFromObject(Request request, HttpURLConnection connection, Object object, boolean isFromCache, Object originalResult) throws JSONException { if (object instanceof JSONObject) { JSONObject jsonObject = (JSONObject) object; FacebookRequestError error = FacebookRequestError.checkResponseAndCreateError(jsonObject, originalResult, connection); if (error != null) { if (error.getErrorCode() == INVALID_SESSION_FACEBOOK_ERROR_CODE) { Session session = request.getSession(); if (session != null) { session.closeAndClearTokenInformation(); } } return new Response(request, connection, error); } Object body = Utility.getStringPropertyAsJSON(jsonObject, BODY_KEY, NON_JSON_RESPONSE_PROPERTY); if (body instanceof JSONObject) { GraphObject graphObject = GraphObject.Factory.create((JSONObject) body); return new Response(request, connection, graphObject, isFromCache); } else if (body instanceof JSONArray) { GraphObjectList<GraphObject> graphObjectList = GraphObject.Factory.createList( (JSONArray) body, GraphObject.class); return new Response(request, connection, graphObjectList, isFromCache); } // We didn't get a body we understand how to handle, so pretend we got nothing. object = JSONObject.NULL; } if (object == JSONObject.NULL) { return new Response(request, connection, (GraphObject)null, isFromCache); } else { throw new FacebookException("Got unexpected object type in response, class: " + object.getClass().getSimpleName()); } }
Example #6
Source File: GraphObjectPagingLoader.java From Klyph with MIT License | 5 votes |
private void addResults(Response response) { SimpleGraphObjectCursor<T> cursorToModify = (cursor == null || !appendResults) ? new SimpleGraphObjectCursor<T>() : new SimpleGraphObjectCursor<T>(cursor); PagedResults result = response.getGraphObjectAs(PagedResults.class); boolean fromCache = response.getIsFromCache(); GraphObjectList<T> data = result.getData().castToListOf(graphObjectClass); boolean haveData = data.size() > 0; if (haveData) { nextRequest = response.getRequestForPagedResults(Response.PagingDirection.NEXT); cursorToModify.addGraphObjects(data, fromCache); cursorToModify.setMoreObjectsAvailable(true); } if (!haveData) { cursorToModify.setMoreObjectsAvailable(false); cursorToModify.setFromCache(fromCache); nextRequest = null; } // Once we get any set of results NOT from the cache, stop trying to get any future ones // from it. if (!fromCache) { skipRoundtripIfCached = false; } deliverResult(cursorToModify); }
Example #7
Source File: Response.java From Klyph with MIT License | 5 votes |
private static Response createResponseFromObject(Request request, HttpURLConnection connection, Object object, boolean isFromCache, Object originalResult) throws JSONException { if (object instanceof JSONObject) { JSONObject jsonObject = (JSONObject) object; FacebookRequestError error = FacebookRequestError.checkResponseAndCreateError(jsonObject, originalResult, connection); if (error != null) { if (error.getErrorCode() == INVALID_SESSION_FACEBOOK_ERROR_CODE) { Session session = request.getSession(); if (session != null) { session.closeAndClearTokenInformation(); } } return new Response(request, connection, error); } Object body = Utility.getStringPropertyAsJSON(jsonObject, BODY_KEY, NON_JSON_RESPONSE_PROPERTY); if (body instanceof JSONObject) { GraphObject graphObject = GraphObject.Factory.create((JSONObject) body); return new Response(request, connection, graphObject, isFromCache); } else if (body instanceof JSONArray) { GraphObjectList<GraphObject> graphObjectList = GraphObject.Factory.createList( (JSONArray) body, GraphObject.class); return new Response(request, connection, graphObjectList, isFromCache); } // We didn't get a body we understand how to handle, so pretend we got nothing. object = JSONObject.NULL; } if (object == JSONObject.NULL) { return new Response(request, connection, (GraphObject)null, isFromCache); } else { throw new FacebookException("Got unexpected object type in response, class: " + object.getClass().getSimpleName()); } }
Example #8
Source File: GraphObjectPagingLoader.java From KlyphMessenger with MIT License | 5 votes |
private void addResults(Response response) { SimpleGraphObjectCursor<T> cursorToModify = (cursor == null || !appendResults) ? new SimpleGraphObjectCursor<T>() : new SimpleGraphObjectCursor<T>(cursor); PagedResults result = response.getGraphObjectAs(PagedResults.class); boolean fromCache = response.getIsFromCache(); GraphObjectList<T> data = result.getData().castToListOf(graphObjectClass); boolean haveData = data.size() > 0; if (haveData) { nextRequest = response.getRequestForPagedResults(Response.PagingDirection.NEXT); cursorToModify.addGraphObjects(data, fromCache); cursorToModify.setMoreObjectsAvailable(true); } if (!haveData) { cursorToModify.setMoreObjectsAvailable(false); cursorToModify.setFromCache(fromCache); nextRequest = null; } // Once we get any set of results NOT from the cache, stop trying to get any future ones // from it. if (!fromCache) { skipRoundtripIfCached = false; } deliverResult(cursorToModify); }
Example #9
Source File: Response.java From Klyph with MIT License | 5 votes |
Response(Request request, HttpURLConnection connection, GraphObjectList<GraphObject> graphObjects, boolean isFromCache) { this.request = request; this.connection = connection; this.graphObject = null; this.graphObjectList = graphObjects; this.isFromCache = isFromCache; this.error = null; }
Example #10
Source File: GraphObjectPagingLoader.java From platform-friends-android with BSD 2-Clause "Simplified" License | 5 votes |
private void addResults(Response response) { SimpleGraphObjectCursor<T> cursorToModify = (cursor == null || !appendResults) ? new SimpleGraphObjectCursor<T>() : new SimpleGraphObjectCursor<T>(cursor); PagedResults result = response.getGraphObjectAs(PagedResults.class); boolean fromCache = response.getIsFromCache(); GraphObjectList<T> data = result.getData().castToListOf(graphObjectClass); boolean haveData = data.size() > 0; if (haveData) { nextRequest = response.getRequestForPagedResults(Response.PagingDirection.NEXT); cursorToModify.addGraphObjects(data, fromCache); cursorToModify.setMoreObjectsAvailable(true); } if (!haveData) { cursorToModify.setMoreObjectsAvailable(false); cursorToModify.setFromCache(fromCache); nextRequest = null; } // Once we get any set of results NOT from the cache, stop trying to get any future ones // from it. if (!fromCache) { skipRoundtripIfCached = false; } deliverResult(cursorToModify); }
Example #11
Source File: Response.java From KlyphMessenger with MIT License | 5 votes |
private static Response createResponseFromObject(Request request, HttpURLConnection connection, Object object, boolean isFromCache, Object originalResult) throws JSONException { if (object instanceof JSONObject) { JSONObject jsonObject = (JSONObject) object; FacebookRequestError error = FacebookRequestError.checkResponseAndCreateError(jsonObject, originalResult, connection); if (error != null) { if (error.getErrorCode() == INVALID_SESSION_FACEBOOK_ERROR_CODE) { Session session = request.getSession(); if (session != null) { session.closeAndClearTokenInformation(); } } return new Response(request, connection, error); } Object body = Utility.getStringPropertyAsJSON(jsonObject, BODY_KEY, NON_JSON_RESPONSE_PROPERTY); if (body instanceof JSONObject) { GraphObject graphObject = GraphObject.Factory.create((JSONObject) body); return new Response(request, connection, graphObject, isFromCache); } else if (body instanceof JSONArray) { GraphObjectList<GraphObject> graphObjectList = GraphObject.Factory.createList( (JSONArray) body, GraphObject.class); return new Response(request, connection, graphObjectList, isFromCache); } // We didn't get a body we understand how to handle, so pretend we got nothing. object = JSONObject.NULL; } if (object == JSONObject.NULL) { return new Response(request, connection, (GraphObject)null, isFromCache); } else { throw new FacebookException("Got unexpected object type in response, class: " + object.getClass().getSimpleName()); } }
Example #12
Source File: Response.java From aws-mobile-self-paced-labs-samples with Apache License 2.0 | 5 votes |
private static Response createResponseFromObject(Request request, HttpURLConnection connection, Object object, boolean isFromCache, Object originalResult) throws JSONException { if (object instanceof JSONObject) { JSONObject jsonObject = (JSONObject) object; FacebookRequestError error = FacebookRequestError.checkResponseAndCreateError(jsonObject, originalResult, connection); if (error != null) { if (error.getErrorCode() == INVALID_SESSION_FACEBOOK_ERROR_CODE) { Session session = request.getSession(); if (session != null) { session.closeAndClearTokenInformation(); } } return new Response(request, connection, error); } Object body = Utility.getStringPropertyAsJSON(jsonObject, BODY_KEY, NON_JSON_RESPONSE_PROPERTY); if (body instanceof JSONObject) { GraphObject graphObject = GraphObject.Factory.create((JSONObject) body); return new Response(request, connection, graphObject, isFromCache); } else if (body instanceof JSONArray) { GraphObjectList<GraphObject> graphObjectList = GraphObject.Factory.createList( (JSONArray) body, GraphObject.class); return new Response(request, connection, graphObjectList, isFromCache); } // We didn't get a body we understand how to handle, so pretend we got nothing. object = JSONObject.NULL; } if (object == JSONObject.NULL) { return new Response(request, connection, (GraphObject)null, isFromCache); } else { throw new FacebookException("Got unexpected object type in response, class: " + object.getClass().getSimpleName()); } }
Example #13
Source File: Response.java From aws-mobile-self-paced-labs-samples with Apache License 2.0 | 5 votes |
Response(Request request, HttpURLConnection connection, GraphObjectList<GraphObject> graphObjects, boolean isFromCache) { this.request = request; this.connection = connection; this.graphObject = null; this.graphObjectList = graphObjects; this.isFromCache = isFromCache; this.error = null; }
Example #14
Source File: GraphObjectPagingLoader.java From aws-mobile-self-paced-labs-samples with Apache License 2.0 | 5 votes |
private void addResults(Response response) { SimpleGraphObjectCursor<T> cursorToModify = (cursor == null || !appendResults) ? new SimpleGraphObjectCursor<T>() : new SimpleGraphObjectCursor<T>(cursor); PagedResults result = response.getGraphObjectAs(PagedResults.class); boolean fromCache = response.getIsFromCache(); GraphObjectList<T> data = result.getData().castToListOf(graphObjectClass); boolean haveData = data.size() > 0; if (haveData) { nextRequest = response.getRequestForPagedResults(Response.PagingDirection.NEXT); cursorToModify.addGraphObjects(data, fromCache); cursorToModify.setMoreObjectsAvailable(true); } if (!haveData) { cursorToModify.setMoreObjectsAvailable(false); cursorToModify.setFromCache(fromCache); nextRequest = null; } // Once we get any set of results NOT from the cache, stop trying to get any future ones // from it. if (!fromCache) { skipRoundtripIfCached = false; } deliverResult(cursorToModify); }
Example #15
Source File: Response.java From barterli_android with Apache License 2.0 | 5 votes |
private static Response createResponseFromObject(Request request, HttpURLConnection connection, Object object, boolean isFromCache, Object originalResult) throws JSONException { if (object instanceof JSONObject) { JSONObject jsonObject = (JSONObject) object; FacebookRequestError error = FacebookRequestError.checkResponseAndCreateError(jsonObject, originalResult, connection); if (error != null) { if (error.getErrorCode() == INVALID_SESSION_FACEBOOK_ERROR_CODE) { Session session = request.getSession(); if (session != null) { session.closeAndClearTokenInformation(); } } return new Response(request, connection, error); } Object body = Utility.getStringPropertyAsJSON(jsonObject, BODY_KEY, NON_JSON_RESPONSE_PROPERTY); if (body instanceof JSONObject) { GraphObject graphObject = GraphObject.Factory.create((JSONObject) body); return new Response(request, connection, graphObject, isFromCache); } else if (body instanceof JSONArray) { GraphObjectList<GraphObject> graphObjectList = GraphObject.Factory.createList( (JSONArray) body, GraphObject.class); return new Response(request, connection, graphObjectList, isFromCache); } // We didn't get a body we understand how to handle, so pretend we got nothing. object = JSONObject.NULL; } if (object == JSONObject.NULL) { return new Response(request, connection, (GraphObject)null, isFromCache); } else { throw new FacebookException("Got unexpected object type in response, class: " + object.getClass().getSimpleName()); } }
Example #16
Source File: GraphObjectPagingLoader.java From Abelana-Android with Apache License 2.0 | 5 votes |
private void addResults(Response response) { SimpleGraphObjectCursor<T> cursorToModify = (cursor == null || !appendResults) ? new SimpleGraphObjectCursor<T>() : new SimpleGraphObjectCursor<T>(cursor); PagedResults result = response.getGraphObjectAs(PagedResults.class); boolean fromCache = response.getIsFromCache(); GraphObjectList<T> data = result.getData().castToListOf(graphObjectClass); boolean haveData = data.size() > 0; if (haveData) { nextRequest = response.getRequestForPagedResults(Response.PagingDirection.NEXT); cursorToModify.addGraphObjects(data, fromCache); if (nextRequest != null) { cursorToModify.setMoreObjectsAvailable(true); } else { cursorToModify.setMoreObjectsAvailable(false); } } if (!haveData) { cursorToModify.setMoreObjectsAvailable(false); cursorToModify.setFromCache(fromCache); nextRequest = null; } // Once we get any set of results NOT from the cache, stop trying to get any future ones // from it. if (!fromCache) { skipRoundtripIfCached = false; } deliverResult(cursorToModify); }
Example #17
Source File: Response.java From FacebookNewsfeedSample-Android with Apache License 2.0 | 5 votes |
private static Response createResponseFromObject(Request request, HttpURLConnection connection, Object object, boolean isFromCache, Object originalResult) throws JSONException { if (object instanceof JSONObject) { JSONObject jsonObject = (JSONObject) object; FacebookRequestError error = FacebookRequestError.checkResponseAndCreateError(jsonObject, originalResult, connection); if (error != null) { if (error.getErrorCode() == INVALID_SESSION_FACEBOOK_ERROR_CODE) { Session session = request.getSession(); if (session != null) { session.closeAndClearTokenInformation(); } } return new Response(request, connection, error); } Object body = Utility.getStringPropertyAsJSON(jsonObject, BODY_KEY, NON_JSON_RESPONSE_PROPERTY); if (body instanceof JSONObject) { GraphObject graphObject = GraphObject.Factory.create((JSONObject) body); return new Response(request, connection, graphObject, isFromCache); } else if (body instanceof JSONArray) { GraphObjectList<GraphObject> graphObjectList = GraphObject.Factory.createList( (JSONArray) body, GraphObject.class); return new Response(request, connection, graphObjectList, isFromCache); } // We didn't get a body we understand how to handle, so pretend we got nothing. object = JSONObject.NULL; } if (object == JSONObject.NULL) { return new Response(request, connection, (GraphObject)null, isFromCache); } else { throw new FacebookException("Got unexpected object type in response, class: " + object.getClass().getSimpleName()); } }
Example #18
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 #19
Source File: FacebookGraphAPIRequestTask.java From FacebookNewsfeedSample-Android with Apache License 2.0 | 5 votes |
/** * We "open" the given JSONObject and add its items to our internal list. */ private void processResponse(JSONObject data) { try { JSONArray dataArray = (JSONArray)data.get("data"); GraphObjectList<INewsfeedItem> newsFeedItems = GraphObject.Factory.createList(dataArray, INewsfeedItem.class); for (INewsfeedItem newsfeedItem : newsFeedItems) { mItems.add(newsfeedItem); } } catch (JSONException jsonException) { jsonException.printStackTrace(); } }
Example #20
Source File: GraphObjectPagingLoader.java From HypFacebook with BSD 2-Clause "Simplified" License | 5 votes |
private void addResults(Response response) { SimpleGraphObjectCursor<T> cursorToModify = (cursor == null || !appendResults) ? new SimpleGraphObjectCursor<T>() : new SimpleGraphObjectCursor<T>(cursor); PagedResults result = response.getGraphObjectAs(PagedResults.class); boolean fromCache = response.getIsFromCache(); GraphObjectList<T> data = result.getData().castToListOf(graphObjectClass); boolean haveData = data.size() > 0; if (haveData) { nextRequest = response.getRequestForPagedResults(Response.PagingDirection.NEXT); cursorToModify.addGraphObjects(data, fromCache); cursorToModify.setMoreObjectsAvailable(true); } if (!haveData) { cursorToModify.setMoreObjectsAvailable(false); cursorToModify.setFromCache(fromCache); nextRequest = null; } // Once we get any set of results NOT from the cache, stop trying to get any future ones // from it. if (!fromCache) { skipRoundtripIfCached = false; } deliverResult(cursorToModify); }
Example #21
Source File: Response.java From Abelana-Android with Apache License 2.0 | 5 votes |
private static Response createResponseFromObject(Request request, HttpURLConnection connection, Object object, boolean isFromCache, Object originalResult) throws JSONException { if (object instanceof JSONObject) { JSONObject jsonObject = (JSONObject) object; FacebookRequestError error = FacebookRequestError.checkResponseAndCreateError(jsonObject, originalResult, connection); if (error != null) { if (error.getErrorCode() == INVALID_SESSION_FACEBOOK_ERROR_CODE) { Session session = request.getSession(); if (session != null) { session.closeAndClearTokenInformation(); } } return new Response(request, connection, error); } Object body = Utility.getStringPropertyAsJSON(jsonObject, BODY_KEY, NON_JSON_RESPONSE_PROPERTY); if (body instanceof JSONObject) { GraphObject graphObject = GraphObject.Factory.create((JSONObject) body); return new Response(request, connection, body.toString(), graphObject, isFromCache); } else if (body instanceof JSONArray) { GraphObjectList<GraphObject> graphObjectList = GraphObject.Factory.createList( (JSONArray) body, GraphObject.class); return new Response(request, connection, body.toString(), graphObjectList, isFromCache); } // We didn't get a body we understand how to handle, so pretend we got nothing. object = JSONObject.NULL; } if (object == JSONObject.NULL) { return new Response(request, connection, object.toString(), (GraphObject)null, isFromCache); } else { throw new FacebookException("Got unexpected object type in response, class: " + object.getClass().getSimpleName()); } }
Example #22
Source File: Response.java From Abelana-Android with Apache License 2.0 | 5 votes |
Response(Request request, HttpURLConnection connection, String rawResponse, GraphObject graphObject, GraphObjectList<GraphObject> graphObjects, boolean isFromCache, FacebookRequestError error) { this.request = request; this.connection = connection; this.rawResponse = rawResponse; this.graphObject = graphObject; this.graphObjectList = graphObjects; this.isFromCache = isFromCache; this.error = error; }
Example #23
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); }
Example #24
Source File: Response.java From FacebookImageShareIntent with MIT License | 5 votes |
Response(Request request, HttpURLConnection connection, String rawResponse, GraphObject graphObject, GraphObjectList<GraphObject> graphObjects, boolean isFromCache, FacebookRequestError error) { this.request = request; this.connection = connection; this.rawResponse = rawResponse; this.graphObject = graphObject; this.graphObjectList = graphObjects; this.isFromCache = isFromCache; this.error = error; }
Example #25
Source File: Response.java From FacebookImageShareIntent with MIT License | 5 votes |
private static Response createResponseFromObject(Request request, HttpURLConnection connection, Object object, boolean isFromCache, Object originalResult) throws JSONException { if (object instanceof JSONObject) { JSONObject jsonObject = (JSONObject) object; FacebookRequestError error = FacebookRequestError.checkResponseAndCreateError(jsonObject, originalResult, connection); if (error != null) { if (error.getErrorCode() == INVALID_SESSION_FACEBOOK_ERROR_CODE) { Session session = request.getSession(); if (session != null) { session.closeAndClearTokenInformation(); } } return new Response(request, connection, error); } Object body = Utility.getStringPropertyAsJSON(jsonObject, BODY_KEY, NON_JSON_RESPONSE_PROPERTY); if (body instanceof JSONObject) { GraphObject graphObject = GraphObject.Factory.create((JSONObject) body); return new Response(request, connection, body.toString(), graphObject, isFromCache); } else if (body instanceof JSONArray) { GraphObjectList<GraphObject> graphObjectList = GraphObject.Factory.createList( (JSONArray) body, GraphObject.class); return new Response(request, connection, body.toString(), graphObjectList, isFromCache); } // We didn't get a body we understand how to handle, so pretend we got nothing. object = JSONObject.NULL; } if (object == JSONObject.NULL) { return new Response(request, connection, object.toString(), (GraphObject)null, isFromCache); } else { throw new FacebookException("Got unexpected object type in response, class: " + object.getClass().getSimpleName()); } }
Example #26
Source File: GraphObjectPagingLoader.java From FacebookImageShareIntent with MIT License | 5 votes |
private void addResults(Response response) { SimpleGraphObjectCursor<T> cursorToModify = (cursor == null || !appendResults) ? new SimpleGraphObjectCursor<T>() : new SimpleGraphObjectCursor<T>(cursor); PagedResults result = response.getGraphObjectAs(PagedResults.class); boolean fromCache = response.getIsFromCache(); GraphObjectList<T> data = result.getData().castToListOf(graphObjectClass); boolean haveData = data.size() > 0; if (haveData) { nextRequest = response.getRequestForPagedResults(Response.PagingDirection.NEXT); cursorToModify.addGraphObjects(data, fromCache); cursorToModify.setMoreObjectsAvailable(true); } if (!haveData) { cursorToModify.setMoreObjectsAvailable(false); cursorToModify.setFromCache(fromCache); nextRequest = null; } // Once we get any set of results NOT from the cache, stop trying to get any future ones // from it. if (!fromCache) { skipRoundtripIfCached = false; } deliverResult(cursorToModify); }
Example #27
Source File: GraphObjectPagingLoader.java From facebook-api-android-maven with Apache License 2.0 | 5 votes |
private void addResults(Response response) { SimpleGraphObjectCursor<T> cursorToModify = (cursor == null || !appendResults) ? new SimpleGraphObjectCursor<T>() : new SimpleGraphObjectCursor<T>(cursor); PagedResults result = response.getGraphObjectAs(PagedResults.class); boolean fromCache = response.getIsFromCache(); GraphObjectList<T> data = result.getData().castToListOf(graphObjectClass); boolean haveData = data.size() > 0; if (haveData) { nextRequest = response.getRequestForPagedResults(Response.PagingDirection.NEXT); cursorToModify.addGraphObjects(data, fromCache); if (nextRequest != null) { cursorToModify.setMoreObjectsAvailable(true); } else { cursorToModify.setMoreObjectsAvailable(false); } } if (!haveData) { cursorToModify.setMoreObjectsAvailable(false); cursorToModify.setFromCache(fromCache); nextRequest = null; } // Once we get any set of results NOT from the cache, stop trying to get any future ones // from it. if (!fromCache) { skipRoundtripIfCached = false; } deliverResult(cursorToModify); }
Example #28
Source File: Session.java From FacebookImageShareIntent with MIT License | 4 votes |
/** * This parses a server response to a call to me/permissions. It will return the list of granted permissions. * It will optionally update a session with the requested permissions. It also handles the distinction between * 1.0 and 2.0 calls to the endpoint. * * @param session An optional session to update the requested permission set * @param response The server response * @return A list of granted permissions or null if an error */ static List<String> handlePermissionResponse(Session session, Response response) { if (response.getError() != null) { return null; } GraphMultiResult result = response.getGraphObjectAs(GraphMultiResult.class); if (result == null) { return null; } GraphObjectList<GraphObject> data = result.getData(); if (data == null || data.size() == 0) { return null; } List<String> allPermissions = new ArrayList<String>(data.size()); List<String> grantedPermissions = new ArrayList<String>(data.size()); // Check if we are dealing with v2.0 or v1.0 behavior until the server is updated GraphObject firstObject = data.get(0); if (firstObject.getProperty("permission") != null) { // v2.0 for (GraphObject graphObject : data) { String permission = (String) graphObject.getProperty("permission"); String status = (String) graphObject.getProperty("status"); allPermissions.add(permission); if(status.equals("granted")) { grantedPermissions.add(permission); } } } else { // v1.0 Map<String, Object> permissionsMap = firstObject.asMap(); for (Map.Entry<String, Object> entry : permissionsMap.entrySet()) { if (entry.getKey().equals("installed")) { continue; } allPermissions.add(entry.getKey()); if ((Integer)entry.getValue() == 1) { grantedPermissions.add(entry.getKey()); } } } // If we have a session track all the permissions that were requested if (session != null) { session.addRequestedPermissions(allPermissions); } return grantedPermissions; }
Example #29
Source File: Response.java From android-skeleton-project with MIT License | 4 votes |
Response(Request request, HttpURLConnection connection, String rawResponse, GraphObjectList<GraphObject> graphObjects, boolean isFromCache) { this(request, connection, rawResponse, null, graphObjects, isFromCache, null); }
Example #30
Source File: Response.java From facebook-api-android-maven with Apache License 2.0 | 4 votes |
Response(Request request, HttpURLConnection connection, String rawResponse, GraphObjectList<GraphObject> graphObjects, boolean isFromCache) { this(request, connection, rawResponse, null, graphObjects, isFromCache, null); }