Java 类com.facebook.model.GraphMultiResult 实例源码

项目:LostAndFound    文件:AuthorizationClientTests.java   
@Override
Request createGetPermissionsRequest(String accessToken) {
    final List<String> permissions = permissionsToReport;
    return new MockRequest() {
        @Override
        public Response createResponse() {
            GraphObject permissionsObject = GraphObject.Factory.create();
            if (permissions != null) {
                for (String permission : permissions) {
                    permissionsObject.setProperty(permission, 1);
                }
            }
            GraphObjectList<GraphObject> data = GraphObject.Factory.createList(GraphObject.class);
            data.add(permissionsObject);

            GraphMultiResult result = GraphObject.Factory.create(GraphMultiResult.class);
            result.setProperty("data", data);

            return new Response(this, null, result, false);
        }
    };
}
项目:FacebookImageShareIntent    文件:AuthorizationClientTests.java   
@Override
Request createGetPermissionsRequest(String accessToken) {
    final List<String> permissions = permissionsToReport;
    return new MockRequest() {
        @Override
        public Response createResponse() {
            GraphObject permissionsObject = GraphObject.Factory.create();
            if (permissions != null) {
                for (String permission : permissions) {
                    permissionsObject.setProperty(permission, 1);
                }
            }
            GraphObjectList<GraphObject> data = GraphObject.Factory.createList(GraphObject.class);
            data.add(permissionsObject);

            GraphMultiResult result = GraphObject.Factory.create(GraphMultiResult.class);
            result.setProperty("data", data);

            return new Response(this, null, null, result, false);
        }
    };
}
项目:facebook-android-sdk    文件:AuthorizationClientTests.java   
@Override
Request createGetPermissionsRequest(String accessToken) {
    final List<String> permissions = permissionsToReport;
    return new MockRequest() {
        @Override
        public Response createResponse() {
            GraphObject permissionsObject = GraphObject.Factory.create();
            if (permissions != null) {
                for (String permission : permissions) {
                    permissionsObject.setProperty(permission, 1);
                }
            }
            GraphObjectList<GraphObject> data = GraphObject.Factory.createList(GraphObject.class);
            data.add(permissionsObject);

            GraphMultiResult result = GraphObject.Factory.create(GraphMultiResult.class);
            result.setProperty("data", data);

            return new Response(this, null, result, false);
        }
    };
}
项目:yelo-android    文件:Request.java   
private static <T extends GraphObject> List<T> typedListFromResponse(Response response, Class<T> clazz) {
    GraphMultiResult multiResult = response.getGraphObjectAs(GraphMultiResult.class);
    if (multiResult == null) {
        return null;
    }

    GraphObjectList<GraphObject> data = multiResult.getData();
    if (data == null) {
        return null;
    }

    return data.castToListOf(clazz);
}
项目:QuizUpWinner    文件:Request.java   
private static <T extends GraphObject> List<T> typedListFromResponse(Response paramResponse, Class<T> paramClass)
{
  GraphMultiResult localGraphMultiResult = (GraphMultiResult)paramResponse.getGraphObjectAs(GraphMultiResult.class);
  if (localGraphMultiResult == null)
    return null;
  GraphObjectList localGraphObjectList = localGraphMultiResult.getData();
  if (localGraphObjectList == null)
    return null;
  return localGraphObjectList.castToListOf(paramClass);
}
项目:p2psafety    文件:Request.java   
private static <T extends GraphObject> List<T> typedListFromResponse(Response response, Class<T> clazz) {
    GraphMultiResult multiResult = response.getGraphObjectAs(GraphMultiResult.class);
    if (multiResult == null) {
        return null;
    }

    GraphObjectList<GraphObject> data = multiResult.getData();
    if (data == null) {
        return null;
    }

    return data.castToListOf(clazz);
}
项目:AndroidBackendlessChat    文件:Session.java   
/**
 * 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;
}
项目:chat-sdk-android-push-firebase    文件:Session.java   
/**
 * 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;
}
项目:BrillaMXAndroid    文件:Session.java   
/**
 * 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);
}
项目:TP-Formation-Android    文件:Session.java   
/**
 * 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);
}
项目:AutoTimeHelper    文件:Session.java   
/**
 * 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);
}
项目:snake-game-aws    文件:Session.java   
/**
 * 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);
}
项目:BrainStudio    文件:Session.java   
/**
 * 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);
}
项目:QuizUpWinner    文件:Session.java   
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;
}
项目:Team-Alice    文件:Session.java   
/**
 * 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;
}
项目:WatsiAndroidApp    文件:Session.java   
/**
 * 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);
}
项目:Qtino.SharingKit    文件:Session.java   
/**
 * 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);
}
项目:smartenit    文件:Session.java   
/**
 * 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);
}
项目:DualRunner    文件:Session.java   
/**
 * 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);
}
项目:facebook-friends    文件:FriendsActivity.java   
private List<GraphUser> getResults(Response response) {
    GraphMultiResult multiResult = response.getGraphObjectAs(GraphMultiResult.class);
    GraphObjectList<GraphObject> data = multiResult.getData();
    return data.castToListOf(GraphUser.class);
}
项目:ShopAfter    文件:Session.java   
/**
 * 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;
}
项目:MeNextAndroid    文件:Session.java   
/**
 * 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);
}
项目:ClassParticipation2    文件:Session.java   
/**
 * 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);
}
项目:Nefete    文件:Session.java   
/**
 * 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;
}
项目:PetTinder    文件:Session.java   
/**
 * 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);
}
项目:StoryTeller    文件:Session.java   
/**
 * 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);
}
项目:HereAStory-Android    文件:Session.java   
/**
 * 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);
}
项目:android-skeleton-project    文件:Session.java   
/**
 * 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;
}
项目:FacebookImageShareIntent    文件:Session.java   
/**
 * 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;
}
项目:stepout    文件:Session.java   
/**
 * 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);
}
项目:Abelana-Android    文件:Session.java   
/**
 * 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);
}
项目:localhost-android    文件:Session.java   
/**
 * 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);
}
项目:facebook-api-android-maven    文件:Session.java   
/**
 * 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);
}