use of com.facebook.GraphResponse in project facebook-android-sdk by facebook.
the class Utility method getGraphMeRequestWithCacheAsync.
public static void getGraphMeRequestWithCacheAsync(final String accessToken, final GraphMeRequestWithCacheCallback callback) {
JSONObject cachedValue = ProfileInformationCache.getProfileInformation(accessToken);
if (cachedValue != null) {
callback.onSuccess(cachedValue);
return;
}
GraphRequest.Callback graphCallback = new GraphRequest.Callback() {
@Override
public void onCompleted(GraphResponse response) {
if (response.getError() != null) {
callback.onFailure(response.getError().getException());
} else {
ProfileInformationCache.putProfileInformation(accessToken, response.getJSONObject());
callback.onSuccess(response.getJSONObject());
}
}
};
GraphRequest graphRequest = getGraphMeRequestWithCache(accessToken);
graphRequest.setCallback(graphCallback);
graphRequest.executeAsync();
}
use of com.facebook.GraphResponse 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();
}
use of com.facebook.GraphResponse in project facebook-android-sdk by facebook.
the class UpdateUserPropertiesTests method testUserUpdateProperties.
public void testUserUpdateProperties() throws Exception {
final TestBlocker blocker = getTestBlocker();
Bundle parameters = new Bundle();
parameters.putString("custom_value", "1");
AppEventsLogger.setUserID("1");
AppEventsLogger.updateUserProperties(parameters, getApplicationId(), new GraphRequest.Callback() {
@Override
public void onCompleted(GraphResponse response) {
if (response.getError() != null) {
blocker.setException(response.getError().getException());
}
blocker.signal();
}
});
blocker.waitForSignals(1);
if (blocker.getException() != null) {
throw blocker.getException();
}
}
use of com.facebook.GraphResponse 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;
}
}
Aggregations