use of com.facebook.Request in project openkit-android by OpenKit.
the class FriendPickerFragment method createRequest.
private Request createRequest(String userID, Set<String> extraFields, Session session) {
Request request = Request.newGraphPathRequest(session, userID + "/friends", null);
Set<String> fields = new HashSet<String>(extraFields);
String[] requiredFields = new String[] { ID, NAME };
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;
}
use of com.facebook.Request in project openkit-android by OpenKit.
the class ScoreCreator method CreateGlobalScores.
public static void CreateGlobalScores(int aNumScores, int aLeaderboardID, final int maxScoreValue) {
final int numScores = aNumScores;
final int leaderboardID = aLeaderboardID;
OKLog.d("Getting list of FB friends");
Session session = Session.getActiveSession();
if (session != null && session.isOpened()) {
Request friendsRequest = Request.newMyFriendsRequest(session, new GraphUserListCallback() {
@Override
public void onCompleted(List<GraphUser> users, Response response) {
FacebookRequestError error = response.getError();
if (error != null) {
OKLog.d("Error getting Facebook friends");
//requestHandler.onFail(error);
} else {
OKLog.d("Got %d facebook friends", users.size());
Random generator = new Random();
for (int x = 0; x < numScores; x++) {
int friendIndex = generator.nextInt(users.size());
CreateScoreForFBUser(users.get(friendIndex), leaderboardID, x, maxScoreValue);
}
}
}
});
friendsRequest.executeAsync();
} else {
OKLog.v("FB session not open");
}
}
use of com.facebook.Request in project openkit-android by OpenKit.
the class ScoreCreator method CreateFriendsScores.
public static void CreateFriendsScores(int aNumScores, int aLeaderboardID, int maxScoreValue) {
final int numScores = aNumScores;
final int leaderboardID = aLeaderboardID;
OKLog.d("Getting list of FB friends");
Session session = Session.getActiveSession();
if (session != null && session.isOpened()) {
Request friendsRequest = Request.newMyFriendsRequest(session, new GraphUserListCallback() {
@Override
public void onCompleted(List<GraphUser> users, Response response) {
FacebookRequestError error = response.getError();
if (error != null) {
OKLog.d("Error getting Facebook friends");
} else {
OKLog.d("Got %d facebook friends", users.size());
Random generator = new Random();
for (int x = 0; x < numScores; x++) {
int friendIndex = generator.nextInt(users.size());
CreateFriendScore(users.get(friendIndex), leaderboardID, x);
}
}
}
});
friendsRequest.executeAsync();
} else {
OKLog.v("FB session not open");
}
}
Aggregations