Search in sources :

Example 51 with GraphRequest

use of com.facebook.GraphRequest in project facebook-android-sdk by facebook.

the class PlacePickerFragment method createRequest.

private GraphRequest createRequest(Location location, int radiusInMeters, int resultsLimit, String searchText, Set<String> extraFields) {
    AccessToken accessToken = AccessToken.getCurrentAccessToken();
    GraphRequest request = GraphRequest.newPlacesSearchRequest(accessToken, location, radiusInMeters, resultsLimit, searchText, null);
    Set<String> fields = new HashSet<String>(extraFields);
    String[] requiredFields = new String[] { ID, NAME, LOCATION, CATEGORY, WERE_HERE_COUNT };
    fields.addAll(Arrays.asList(requiredFields));
    String pictureField = adapter.getPictureFieldSpecifier();
    if (pictureField != null) {
        fields.add(pictureField);
    }
    Bundle parameters = request.getParameters();
    parameters.putString("fields", TextUtils.join(",", fields));
    request.setParameters(parameters);
    return request;
}
Also used : GraphRequest(com.facebook.GraphRequest) AccessToken(com.facebook.AccessToken) Bundle(android.os.Bundle)

Example 52 with GraphRequest

use of com.facebook.GraphRequest in project facebook-android-sdk by facebook.

the class GraphObjectPagingLoader method requestCompleted.

private void requestCompleted(GraphResponse response) {
    GraphRequest request = response.getRequest();
    if (request != currentRequest) {
        return;
    }
    loading = false;
    currentRequest = null;
    FacebookRequestError requestError = response.getError();
    FacebookException exception = (requestError == null) ? null : requestError.getException();
    if (response.getJSONObject() == null && exception == null) {
        exception = new FacebookException("GraphObjectPagingLoader received neither a result nor an error.");
    }
    if (exception != null) {
        nextRequest = null;
        if (onErrorListener != null) {
            onErrorListener.onError(exception, this);
        }
    } else {
        addResults(response);
    }
}
Also used : GraphRequest(com.facebook.GraphRequest) FacebookException(com.facebook.FacebookException) FacebookRequestError(com.facebook.FacebookRequestError)

Aggregations

GraphRequest (com.facebook.GraphRequest)52 Bundle (android.os.Bundle)39 GraphResponse (com.facebook.GraphResponse)25 JSONObject (org.json.JSONObject)22 FacebookException (com.facebook.FacebookException)15 JSONException (org.json.JSONException)15 FacebookRequestError (com.facebook.FacebookRequestError)8 AccessToken (com.facebook.AccessToken)7 FacebookCallback (com.facebook.FacebookCallback)5 Uri (android.net.Uri)4 JSONArray (org.json.JSONArray)4 Test (org.junit.Test)3 Intent (android.content.Intent)2 Location (android.location.Location)2 GraphRequestBatch (com.facebook.GraphRequestBatch)2 Profile (com.facebook.Profile)2 CollectionMapper (com.facebook.internal.CollectionMapper)2 CurrentPlaceFeedbackRequestParams (com.facebook.places.model.CurrentPlaceFeedbackRequestParams)2 PlaceInfoRequestParams (com.facebook.places.model.PlaceInfoRequestParams)2 UnsupportedEncodingException (java.io.UnsupportedEncodingException)2