本文整理匯總了Java中com.facebook.model.GraphObjectList.size方法的典型用法代碼示例。如果您正苦於以下問題:Java GraphObjectList.size方法的具體用法?Java GraphObjectList.size怎麽用?Java GraphObjectList.size使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類com.facebook.model.GraphObjectList
的用法示例。
在下文中一共展示了GraphObjectList.size方法的6個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: addResults
import com.facebook.model.GraphObjectList; //導入方法依賴的package包/類
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);
}
示例2: addResults
import com.facebook.model.GraphObjectList; //導入方法依賴的package包/類
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);
}
示例3: handlePermissionResponse
import com.facebook.model.GraphObjectList; //導入方法依賴的package包/類
/**
* 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;
}
示例4: retrieveTestAccountsForAppIfNeeded
import com.facebook.model.GraphObjectList; //導入方法依賴的package包/類
private static synchronized void retrieveTestAccountsForAppIfNeeded() {
if (appTestAccounts != null) {
return;
}
appTestAccounts = new HashMap<String, TestAccount>();
// The data we need is split across two different FQL tables. We construct two queries, submit them
// together (the second one refers to the first one), then cross-reference the results.
// Get the test accounts for this app.
String testAccountQuery = String.format("SELECT id,access_token FROM test_account WHERE app_id = %s",
testApplicationId);
// Get the user names for those accounts.
String userQuery = "SELECT uid,name FROM user WHERE uid IN (SELECT id FROM #test_accounts)";
Bundle parameters = new Bundle();
// Build a JSON string that contains our queries and pass it as the 'q' parameter of the query.
JSONObject multiquery;
try {
multiquery = new JSONObject();
multiquery.put("test_accounts", testAccountQuery);
multiquery.put("users", userQuery);
} catch (JSONException exception) {
throw new FacebookException(exception);
}
parameters.putString("q", multiquery.toString());
// We need to authenticate as this app.
parameters.putString("access_token", getAppAccessToken());
Request request = new Request(null, "fql", parameters, null);
Response response = request.executeAndWait();
if (response.getError() != null) {
throw response.getError().getException();
}
FqlResponse fqlResponse = response.getGraphObjectAs(FqlResponse.class);
GraphObjectList<FqlResult> fqlResults = fqlResponse.getData();
if (fqlResults == null || fqlResults.size() != 2) {
throw new FacebookException("Unexpected number of results from FQL query");
}
// We get back two sets of results. The first is from the test_accounts query, the second from the users query.
Collection<TestAccount> testAccounts = fqlResults.get(0).getFqlResultSet().castToListOf(TestAccount.class);
Collection<UserAccount> userAccounts = fqlResults.get(1).getFqlResultSet().castToListOf(UserAccount.class);
// Use both sets of results to populate our static array of accounts.
populateTestAccounts(testAccounts, userAccounts);
return;
}
示例5: handlePermissionResponse
import com.facebook.model.GraphObjectList; //導入方法依賴的package包/類
/**
* 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 response The server response
* @return A list of granted permissions or null if an error
*/
static PermissionsPair handlePermissionResponse(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> grantedPermissions = new ArrayList<String>(data.size());
List<String> declinedPermissions = 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");
if (permission.equals("installed")) {
continue;
}
String status = (String) graphObject.getProperty("status");
if(status.equals("granted")) {
grantedPermissions.add(permission);
} else if (status.equals("declined")) {
declinedPermissions.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;
}
if ((Integer)entry.getValue() == 1) {
grantedPermissions.add(entry.getKey());
}
}
}
return new PermissionsPair(grantedPermissions, declinedPermissions);
}
示例6: handlePermissionResponse
import com.facebook.model.GraphObjectList; //導入方法依賴的package包/類
static List<String> handlePermissionResponse(Session paramSession, Response paramResponse)
{
if (paramResponse.getError() != null)
return null;
GraphMultiResult localGraphMultiResult = (GraphMultiResult)paramResponse.getGraphObjectAs(GraphMultiResult.class);
if (localGraphMultiResult == null)
return null;
GraphObjectList localGraphObjectList = localGraphMultiResult.getData();
if ((localGraphObjectList == null) || (localGraphObjectList.size() == 0))
return null;
ArrayList localArrayList1 = new ArrayList(localGraphObjectList.size());
ArrayList localArrayList2 = new ArrayList(localGraphObjectList.size());
GraphObject localGraphObject1 = (GraphObject)localGraphObjectList.get(0);
if (localGraphObject1.getProperty("permission") != null)
{
Iterator localIterator2 = localGraphObjectList.iterator();
while (localIterator2.hasNext())
{
GraphObject localGraphObject2 = (GraphObject)localIterator2.next();
String str1 = (String)localGraphObject2.getProperty("permission");
String str2 = (String)localGraphObject2.getProperty("status");
localArrayList1.add(str1);
if (str2.equals("granted"))
localArrayList2.add(str1);
}
}
else
{
Iterator localIterator1 = localGraphObject1.asMap().entrySet().iterator();
while (localIterator1.hasNext())
{
Map.Entry localEntry = (Map.Entry)localIterator1.next();
if (!((String)localEntry.getKey()).equals("installed"))
{
localArrayList1.add(localEntry.getKey());
if (((Integer)localEntry.getValue()).intValue() == 1)
localArrayList2.add(localEntry.getKey());
}
}
}
if (paramSession != null)
paramSession.addRequestedPermissions(localArrayList1);
return localArrayList2;
}