Search in sources :

Example 26 with GraphRequest

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

the class Utility method awaitGetGraphMeRequestWithCache.

public static JSONObject awaitGetGraphMeRequestWithCache(final String accessToken) {
    JSONObject cachedValue = ProfileInformationCache.getProfileInformation(accessToken);
    if (cachedValue != null) {
        return cachedValue;
    }
    GraphRequest graphRequest = getGraphMeRequestWithCache(accessToken);
    GraphResponse response = graphRequest.executeAndWait();
    if (response.getError() != null) {
        return null;
    }
    return response.getJSONObject();
}
Also used : GraphRequest(com.facebook.GraphRequest) JSONObject(org.json.JSONObject) GraphResponse(com.facebook.GraphResponse)

Example 27 with GraphRequest

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

the class FetchedAppSettingsManager method getAppSettingsQueryResponse.

// Note that this method makes a synchronous Graph API call, so should not be called from the
// main thread.
private static JSONObject getAppSettingsQueryResponse(String applicationId) {
    Bundle appSettingsParams = new Bundle();
    appSettingsParams.putString(APPLICATION_FIELDS, TextUtils.join(",", APP_SETTING_FIELDS));
    GraphRequest request = GraphRequest.newGraphPathRequest(null, applicationId, null);
    request.setSkipClientToken(true);
    request.setParameters(appSettingsParams);
    return request.executeAndWait().getJSONObject();
}
Also used : GraphRequest(com.facebook.GraphRequest) Bundle(android.os.Bundle)

Example 28 with GraphRequest

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

the class UserSettingsFragment method fetchUserInfo.

private void fetchUserInfo() {
    final AccessToken accessToken = AccessToken.getCurrentAccessToken();
    if (accessToken != null) {
        GraphRequest request = GraphRequest.newMeRequest(accessToken, new GraphRequest.GraphJSONObjectCallback() {

            @Override
            public void onCompleted(JSONObject me, GraphResponse response) {
                user = me;
                updateUI();
            }
        });
        Bundle parameters = new Bundle();
        parameters.putString(FIELDS, REQUEST_FIELDS);
        request.setParameters(parameters);
        GraphRequest.executeBatchAsync(request);
    } else {
        user = null;
    }
}
Also used : GraphRequest(com.facebook.GraphRequest) JSONObject(org.json.JSONObject) GraphResponse(com.facebook.GraphResponse) AccessToken(com.facebook.AccessToken) Bundle(android.os.Bundle)

Example 29 with GraphRequest

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

the class PickerFragment method loadData.

/**
     * Causes the picker to load data from the service and display it to the user.
     *
     * @param forceReload if true, data will be loaded even if there is already data being displayed (or loading);
     *                    if false, data will not be re-loaded if it is already displayed (or loading)
     * @param selectIds ids to select, if they are present in the loaded data
     */
public void loadData(boolean forceReload, Set<String> selectIds) {
    if (!forceReload && loadingStrategy.isDataPresentOrLoading()) {
        return;
    }
    selectionHint = selectIds;
    clearResults();
    GraphRequest request = getRequestForLoadData();
    if (request != null) {
        onLoadingData();
        loadingStrategy.startLoading(request);
    }
}
Also used : GraphRequest(com.facebook.GraphRequest)

Aggregations

GraphRequest (com.facebook.GraphRequest)29 Bundle (android.os.Bundle)22 GraphResponse (com.facebook.GraphResponse)17 JSONObject (org.json.JSONObject)16 JSONException (org.json.JSONException)12 FacebookException (com.facebook.FacebookException)9 AccessToken (com.facebook.AccessToken)5 FacebookCallback (com.facebook.FacebookCallback)5 FacebookRequestError (com.facebook.FacebookRequestError)5 Uri (android.net.Uri)3 CollectionMapper (com.facebook.internal.CollectionMapper)2 UnsupportedEncodingException (java.io.UnsupportedEncodingException)2 ArrayList (java.util.ArrayList)2 JSONArray (org.json.JSONArray)2 Context (android.content.Context)1 Intent (android.content.Intent)1 Bitmap (android.graphics.Bitmap)1 ParcelFileDescriptor (android.os.ParcelFileDescriptor)1 View (android.view.View)1 Button (android.widget.Button)1