當前位置: 首頁>>代碼示例>>Java>>正文


Java GraphObject.getProperty方法代碼示例

本文整理匯總了Java中com.facebook.model.GraphObject.getProperty方法的典型用法代碼示例。如果您正苦於以下問題:Java GraphObject.getProperty方法的具體用法?Java GraphObject.getProperty怎麽用?Java GraphObject.getProperty使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在com.facebook.model.GraphObject的用法示例。


在下文中一共展示了GraphObject.getProperty方法的10個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: compareGraphObjects

import com.facebook.model.GraphObject; //導入方法依賴的package包/類
private static int compareGraphObjects(GraphObject a, GraphObject b, Collection<String> sortFields,
        Collator collator) {
    for (String sortField : sortFields) {
        String sa = (String) a.getProperty(sortField);
        String sb = (String) b.getProperty(sortField);

        if (sa != null && sb != null) {
            int result = collator.compare(sa, sb);
            if (result != 0) {
                return result;
            }
        } else if (!(sa == null && sb == null)) {
            return (sa == null) ? -1 : 1;
        }
    }
    return 0;
}
 
開發者ID:MobileDev418,項目名稱:AndroidBackendlessChat,代碼行數:18,代碼來源:GraphObjectAdapter.java

示例2: deleteTestAccount

import com.facebook.model.GraphObject; //導入方法依賴的package包/類
private void deleteTestAccount(String testAccountId, String appAccessToken) {
    Bundle parameters = new Bundle();
    parameters.putString("access_token", appAccessToken);

    Request request = new Request(null, testAccountId, parameters, HttpMethod.DELETE);
    Response response = request.executeAndWait();

    FacebookRequestError error = response.getError();
    GraphObject graphObject = response.getGraphObject();
    if (error != null) {
        Log.w(LOG_TAG, String.format("Could not delete test account %s: %s", testAccountId, error.getException().toString()));
    } else if (graphObject.getProperty(Response.NON_JSON_RESPONSE_PROPERTY) == (Boolean) false
               || graphObject.getProperty(Response.SUCCESS_KEY) == (Boolean) false) {
        Log.w(LOG_TAG, String.format("Could not delete test account %s: unknown reason", testAccountId));
    }
}
 
開發者ID:dannegm,項目名稱:BrillaMXAndroid,代碼行數:17,代碼來源:TestSession.java

示例3: deleteTestAccount

import com.facebook.model.GraphObject; //導入方法依賴的package包/類
private void deleteTestAccount(String testAccountId, String appAccessToken) {
    Bundle parameters = new Bundle();
    parameters.putString("access_token", appAccessToken);

    Request request = new Request(null, testAccountId, parameters, HttpMethod.DELETE);
    Response response = request.executeAndWait();

    FacebookRequestError error = response.getError();
    GraphObject graphObject = response.getGraphObject();
    if (error != null) {
        Log.w(LOG_TAG, String.format("Could not delete test account %s: %s", testAccountId, error.getException().toString()));
    } else if (graphObject.getProperty(Response.NON_JSON_RESPONSE_PROPERTY) == (Boolean) false) {
        Log.w(LOG_TAG, String.format("Could not delete test account %s: unknown reason", testAccountId));
    }
}
 
開發者ID:MobileDev418,項目名稱:AndroidBackendlessChat,代碼行數:16,代碼來源:TestSession.java

示例4: safeGetBooleanFromResponse

import com.facebook.model.GraphObject; //導入方法依賴的package包/類
private static boolean safeGetBooleanFromResponse(GraphObject response, String propertyName) {
    Object result = false;
    if (response != null) {
        result = response.getProperty(propertyName);
    }
    if (!(result instanceof Boolean)) {
        result = false;
    }
    return (Boolean) result;
}
 
開發者ID:MobileDev418,項目名稱:AndroidBackendlessChat,代碼行數:11,代碼來源:Utility.java

示例5: safeGetStringFromResponse

import com.facebook.model.GraphObject; //導入方法依賴的package包/類
private static String safeGetStringFromResponse(GraphObject response, String propertyName) {
    Object result = "";
    if (response != null) {
        result = response.getProperty(propertyName);
    }
    if (!(result instanceof String)) {
        result = "";
    }
    return (String) result;
}
 
開發者ID:MobileDev418,項目名稱:AndroidBackendlessChat,代碼行數:11,代碼來源:Utility.java

示例6: safeGetStringFromResponse

import com.facebook.model.GraphObject; //導入方法依賴的package包/類
public static String safeGetStringFromResponse(GraphObject response, String propertyName) {
    Object result = "";
    if (response != null) {
        result = response.getProperty(propertyName);
    }
    if (!(result instanceof String)) {
        result = "";
    }
    return (String) result;
}
 
開發者ID:dannegm,項目名稱:BrillaMXAndroid,代碼行數:11,代碼來源:Utility.java

示例7: safeGetBooleanFromResponse

import com.facebook.model.GraphObject; //導入方法依賴的package包/類
public static boolean safeGetBooleanFromResponse(GraphObject response, String propertyName) {
    Object result = false;
    if (response != null) {
        result = response.getProperty(propertyName);
    }
    if (!(result instanceof Boolean)) {
        result = false;
    }
    return (Boolean) result;
}
 
開發者ID:maxml,項目名稱:AutoTimeHelper,代碼行數:11,代碼來源:Utility.java

示例8: tryGetJSONArrayFromResponse

import com.facebook.model.GraphObject; //導入方法依賴的package包/類
public static JSONArray tryGetJSONArrayFromResponse(GraphObject response, String propertyKey) {
    if (response == null) {
        return null;
    }
    Object property = response.getProperty(propertyKey);
    if (!(property instanceof JSONArray)) {
        return null;
    }
    return (JSONArray) property;
}
 
開發者ID:dannegm,項目名稱:BrillaMXAndroid,代碼行數:11,代碼來源:Utility.java

示例9: handlePermissionResponse

import com.facebook.model.GraphObject; //導入方法依賴的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;
}
 
開發者ID:MobileDev418,項目名稱:AndroidBackendlessChat,代碼行數:57,代碼來源:Session.java

示例10: handlePermissionResponse

import com.facebook.model.GraphObject; //導入方法依賴的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);
}
 
開發者ID:dannegm,項目名稱:BrillaMXAndroid,代碼行數:55,代碼來源:Session.java


注:本文中的com.facebook.model.GraphObject.getProperty方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。