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

项目:AndroidBackendlessChat    文件:Utility.java   
public static FetchedAppSettings queryAppSettings(final String applicationId, final boolean forceRequery) {

        // Cache the last app checked results.
        if (!forceRequery && fetchedAppSettings.containsKey(applicationId)) {
            return fetchedAppSettings.get(applicationId);
        }

        Bundle appSettingsParams = new Bundle();
        appSettingsParams.putString(APPLICATION_FIELDS, TextUtils.join(",", APP_SETTING_FIELDS));

        Request request = Request.newGraphPathRequest(null, applicationId, null);
        request.setParameters(appSettingsParams);

        GraphObject supportResponse = request.executeAndWait().getGraphObject();
        FetchedAppSettings result = new FetchedAppSettings(
                safeGetBooleanFromResponse(supportResponse, SUPPORTS_ATTRIBUTION),
                safeGetBooleanFromResponse(supportResponse, SUPPORTS_IMPLICIT_SDK_LOGGING),
                safeGetStringFromResponse(supportResponse, NUX_CONTENT),
                safeGetBooleanFromResponse(supportResponse, NUX_ENABLED)
                );

        fetchedAppSettings.put(applicationId, result);

        return result;
    }
项目:AndroidBackendlessChat    文件:Utility.java   
public static void setAppEventAttributionParameters(GraphObject params,
        AttributionIdentifiers attributionIdentifiers, String hashedDeviceAndAppId, boolean limitEventUsage) {
    // Send attributionID if it exists, otherwise send a hashed device+appid specific value as the advertiser_id.
    if (attributionIdentifiers != null && attributionIdentifiers.getAttributionId() != null) {
        params.setProperty("attribution", attributionIdentifiers.getAttributionId());
    }

    if (attributionIdentifiers != null && attributionIdentifiers.getAndroidAdvertiserId() != null) {
        params.setProperty("advertiser_id", attributionIdentifiers.getAndroidAdvertiserId());
        params.setProperty("advertiser_tracking_enabled", !attributionIdentifiers.isTrackingLimited());
    } else if (hashedDeviceAndAppId != null) {
        params.setProperty("advertiser_id", hashedDeviceAndAppId);
    }

    params.setProperty("application_tracking_enabled", !limitEventUsage);
}
项目:AndroidBackendlessChat    文件:GraphObjectAdapter.java   
protected URI getPictureUriOfGraphObject(T graphObject) {
    String uri = null;
    Object o = graphObject.getProperty(PICTURE);
    if (o instanceof String) {
        uri = (String) o;
    } else if (o instanceof JSONObject) {
        ItemPicture itemPicture = GraphObject.Factory.create((JSONObject) o).cast(ItemPicture.class);
        ItemPictureData data = itemPicture.getData();
        if (data != null) {
            uri = data.getUrl();
        }
    }

    if (uri != null) {
        try {
            return new URI(uri);
        } catch (URISyntaxException e) {
        }
    }
    return null;
}
项目:AndroidBackendlessChat    文件:GraphObjectAdapter.java   
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;
}
项目:chat-sdk-android-push-firebase    文件:Utility.java   
public static FetchedAppSettings queryAppSettings(final String applicationId, final boolean forceRequery) {

        // Cache the last app checked results.
        if (!forceRequery && fetchedAppSettings.containsKey(applicationId)) {
            return fetchedAppSettings.get(applicationId);
        }

        Bundle appSettingsParams = new Bundle();
        appSettingsParams.putString(APPLICATION_FIELDS, TextUtils.join(",", APP_SETTING_FIELDS));

        Request request = Request.newGraphPathRequest(null, applicationId, null);
        request.setParameters(appSettingsParams);

        GraphObject supportResponse = request.executeAndWait().getGraphObject();
        FetchedAppSettings result = new FetchedAppSettings(
                safeGetBooleanFromResponse(supportResponse, SUPPORTS_ATTRIBUTION),
                safeGetBooleanFromResponse(supportResponse, SUPPORTS_IMPLICIT_SDK_LOGGING),
                safeGetStringFromResponse(supportResponse, NUX_CONTENT),
                safeGetBooleanFromResponse(supportResponse, NUX_ENABLED)
                );

        fetchedAppSettings.put(applicationId, result);

        return result;
    }
项目:chat-sdk-android-push-firebase    文件:Utility.java   
public static void setAppEventAttributionParameters(GraphObject params,
        AttributionIdentifiers attributionIdentifiers, String hashedDeviceAndAppId, boolean limitEventUsage) {
    // Send attributionID if it exists, otherwise send a hashed device+appid specific value as the advertiser_id.
    if (attributionIdentifiers != null && attributionIdentifiers.getAttributionId() != null) {
        params.setProperty("attribution", attributionIdentifiers.getAttributionId());
    }

    if (attributionIdentifiers != null && attributionIdentifiers.getAndroidAdvertiserId() != null) {
        params.setProperty("advertiser_id", attributionIdentifiers.getAndroidAdvertiserId());
        params.setProperty("advertiser_tracking_enabled", !attributionIdentifiers.isTrackingLimited());
    } else if (hashedDeviceAndAppId != null) {
        params.setProperty("advertiser_id", hashedDeviceAndAppId);
    }

    params.setProperty("application_tracking_enabled", !limitEventUsage);
}
项目:chat-sdk-android-push-firebase    文件:GraphObjectAdapter.java   
protected URI getPictureUriOfGraphObject(T graphObject) {
    String uri = null;
    Object o = graphObject.getProperty(PICTURE);
    if (o instanceof String) {
        uri = (String) o;
    } else if (o instanceof JSONObject) {
        ItemPicture itemPicture = GraphObject.Factory.create((JSONObject) o).cast(ItemPicture.class);
        ItemPictureData data = itemPicture.getData();
        if (data != null) {
            uri = data.getUrl();
        }
    }

    if (uri != null) {
        try {
            return new URI(uri);
        } catch (URISyntaxException e) {
        }
    }
    return null;
}
项目:chat-sdk-android-push-firebase    文件:GraphObjectAdapter.java   
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;
}
项目:yelo-android    文件:Utility.java   
public static FetchedAppSettings queryAppSettings(final String applicationId, final boolean forceRequery) {

        // Cache the last app checked results.
        if (!forceRequery && fetchedAppSettings.containsKey(applicationId)) {
            return fetchedAppSettings.get(applicationId);
        }

        Bundle appSettingsParams = new Bundle();
        appSettingsParams.putString(APPLICATION_FIELDS, TextUtils.join(",", APP_SETTING_FIELDS));

        Request request = Request.newGraphPathRequest(null, applicationId, null);
        request.setParameters(appSettingsParams);

        GraphObject supportResponse = request.executeAndWait().getGraphObject();
        FetchedAppSettings result = new FetchedAppSettings(
                safeGetBooleanFromResponse(supportResponse, SUPPORTS_ATTRIBUTION),
                safeGetBooleanFromResponse(supportResponse, SUPPORTS_IMPLICIT_SDK_LOGGING));

        fetchedAppSettings.put(applicationId, result);

        return result;
    }
项目:AutoTimeHelper    文件:TestSession.java   
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));
    }
}
项目:AutoTimeHelper    文件:Utility.java   
public static void setAppEventAttributionParameters(GraphObject params,
                                                    AttributionIdentifiers attributionIdentifiers, String hashedDeviceAndAppId, boolean limitEventUsage) {
    // Send attributionID if it exists, otherwise send a hashed device+appid specific value as the advertiser_id.
    if (attributionIdentifiers != null && attributionIdentifiers.getAttributionId() != null) {
        params.setProperty("attribution", attributionIdentifiers.getAttributionId());
    }

    if (attributionIdentifiers != null && attributionIdentifiers.getAndroidAdvertiserId() != null) {
        params.setProperty("advertiser_id", attributionIdentifiers.getAndroidAdvertiserId());
        params.setProperty("advertiser_tracking_enabled", !attributionIdentifiers.isTrackingLimited());
    } else if (hashedDeviceAndAppId != null) {
        params.setProperty("advertiser_id", hashedDeviceAndAppId);
    }

    params.setProperty("application_tracking_enabled", !limitEventUsage);
}
项目:yelo-android    文件:GraphObjectAdapter.java   
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;
}
项目:BrillaMXAndroid    文件:Utility.java   
public static void setAppEventAttributionParameters(
        GraphObject params,
        AttributionIdentifiers attributionIdentifiers,
        String anonymousAppDeviceGUID,
        boolean limitEventUsage) {
    if (attributionIdentifiers != null && attributionIdentifiers.getAttributionId() != null) {
        params.setProperty("attribution", attributionIdentifiers.getAttributionId());
    }

    if (attributionIdentifiers != null && attributionIdentifiers.getAndroidAdvertiserId() != null) {
        params.setProperty("advertiser_id", attributionIdentifiers.getAndroidAdvertiserId());
        params.setProperty("advertiser_tracking_enabled", !attributionIdentifiers.isTrackingLimited());
    }

    params.setProperty("anon_id", anonymousAppDeviceGUID);
    params.setProperty("application_tracking_enabled", !limitEventUsage);
}
项目:BrillaMXAndroid    文件:Utility.java   
public static void setAppEventExtendedDeviceInfoParameters(GraphObject params, Context appContext) {
    JSONArray extraInfoArray = new JSONArray();
    extraInfoArray.put(EXTRA_APP_EVENTS_INFO_FORMAT_VERSION);

    // Application Manifest info:
    String pkgName = appContext.getPackageName();
    int versionCode = -1;
    String versionName = "";

    try {
        PackageInfo pi = appContext.getPackageManager().getPackageInfo(pkgName, 0);
        versionCode = pi.versionCode;
        versionName = pi.versionName;
    } catch (PackageManager.NameNotFoundException e) {
        // Swallow
    }

    // Application Manifest info:
    extraInfoArray.put(pkgName);
    extraInfoArray.put(versionCode);
    extraInfoArray.put(versionName);

    params.setProperty("extinfo", extraInfoArray.toString());
}
项目:BrillaMXAndroid    文件:GraphObjectAdapter.java   
protected URI getPictureUriOfGraphObject(T graphObject) {
    String uri = null;
    Object o = graphObject.getProperty(PICTURE);
    if (o instanceof String) {
        uri = (String) o;
    } else if (o instanceof JSONObject) {
        ItemPicture itemPicture = GraphObject.Factory.create((JSONObject) o).cast(ItemPicture.class);
        ItemPictureData data = itemPicture.getData();
        if (data != null) {
            uri = data.getUrl();
        }
    }

    if (uri != null) {
        try {
            return new URI(uri);
        } catch (URISyntaxException e) {
        }
    }
    return null;
}
项目:BrillaMXAndroid    文件:GraphObjectAdapter.java   
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;
}
项目:BrainStudio    文件:GraphObjectAdapter.java   
protected URI getPictureUriOfGraphObject(T graphObject) {
    String uri = null;
    Object o = graphObject.getProperty(PICTURE);
    if (o instanceof String) {
        uri = (String) o;
    } else if (o instanceof JSONObject) {
        ItemPicture itemPicture = GraphObject.Factory.create((JSONObject) o).cast(ItemPicture.class);
        ItemPictureData data = itemPicture.getData();
        if (data != null) {
            uri = data.getUrl();
        }
    }

    if (uri != null) {
        try {
            return new URI(uri);
        } catch (URISyntaxException e) {
        }
    }
    return null;
}
项目:aquaplay    文件:Utility.java   
public static FetchedAppSettings queryAppSettings(final String applicationId, final boolean forceRequery) {

        // Cache the last app checked results.
        if (!forceRequery && fetchedAppSettings.containsKey(applicationId)) {
            return fetchedAppSettings.get(applicationId);
        }

        Bundle appSettingsParams = new Bundle();
        appSettingsParams.putString(APPLICATION_FIELDS, TextUtils.join(",", APP_SETTING_FIELDS));

        Request request = Request.newGraphPathRequest(null, applicationId, null);
        request.setParameters(appSettingsParams);

        GraphObject supportResponse = request.executeAndWait().getGraphObject();
        FetchedAppSettings result = new FetchedAppSettings(
                safeGetBooleanFromResponse(supportResponse, SUPPORTS_ATTRIBUTION),
                safeGetBooleanFromResponse(supportResponse, SUPPORTS_IMPLICIT_SDK_LOGGING));

        fetchedAppSettings.put(applicationId, result);

        return result;
    }
项目:aquaplay    文件:GraphObjectAdapter.java   
protected URI getPictureUriOfGraphObject(T graphObject) {
    String uri = null;
    Object o = graphObject.getProperty(PICTURE);
    if (o instanceof String) {
        uri = (String) o;
    } else if (o instanceof JSONObject) {
        ItemPicture itemPicture = GraphObject.Factory.create((JSONObject) o).cast(ItemPicture.class);
        ItemPictureData data = itemPicture.getData();
        if (data != null) {
            uri = data.getUrl();
        }
    }

    if (uri != null) {
        try {
            return new URI(uri);
        } catch (URISyntaxException e) {
        }
    }
    return null;
}
项目:TP-Formation-Android    文件:TestFacebookActivity.java   
private void showPublishResult(String message, GraphObject result, FacebookRequestError error) {
    String title = null;
    String alertMessage = null;
    if (error == null) {
        title = getString(R.string.success);
        alertMessage = getString(R.string.successfully_posted_post, message);
    } else {
        title = getString(R.string.error);
        alertMessage = error.getErrorMessage();
    }

    new AlertDialog.Builder(this)
            .setTitle(title)
            .setMessage(alertMessage)
            .setPositiveButton(R.string.ok, null)
            .show();
}
项目:BrainStudio    文件:GraphObjectAdapter.java   
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;
}
项目:BrainStudio    文件:Utility.java   
public static void setAppEventAttributionParameters(
        GraphObject params,
        AttributionIdentifiers attributionIdentifiers,
        String anonymousAppDeviceGUID,
        boolean limitEventUsage) {
    if (attributionIdentifiers != null && attributionIdentifiers.getAttributionId() != null) {
        params.setProperty("attribution", attributionIdentifiers.getAttributionId());
    }

    if (attributionIdentifiers != null && attributionIdentifiers.getAndroidAdvertiserId() != null) {
        params.setProperty("advertiser_id", attributionIdentifiers.getAndroidAdvertiserId());
        params.setProperty("advertiser_tracking_enabled", !attributionIdentifiers.isTrackingLimited());
    }

    params.setProperty("anon_id", anonymousAppDeviceGUID);
    params.setProperty("application_tracking_enabled", !limitEventUsage);
}
项目:TP-Formation-Android    文件:Utility.java   
public static void setAppEventExtendedDeviceInfoParameters(GraphObject params, Context appContext) {
    JSONArray extraInfoArray = new JSONArray();
    extraInfoArray.put(EXTRA_APP_EVENTS_INFO_FORMAT_VERSION);

    // Application Manifest info:
    String pkgName = appContext.getPackageName();
    int versionCode = -1;
    String versionName = "";

    try {
        PackageInfo pi = appContext.getPackageManager().getPackageInfo(pkgName, 0);
        versionCode = pi.versionCode;
        versionName = pi.versionName;
    } catch (PackageManager.NameNotFoundException e) {
        // Swallow
    }

    // Application Manifest info:
    extraInfoArray.put(pkgName);
    extraInfoArray.put(versionCode);
    extraInfoArray.put(versionName);

    params.setProperty("extinfo", extraInfoArray.toString());
}
项目:snake-game-aws    文件:GraphObjectAdapter.java   
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;
}
项目:AndroidBackendlessChat    文件:TestSession.java   
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));
    }
}
项目:AndroidBackendlessChat    文件:Response.java   
Response(Request request, HttpURLConnection connection, String rawResponse, GraphObject graphObject, GraphObjectList<GraphObject> graphObjects, boolean isFromCache, FacebookRequestError error) {
    this.request = request;
    this.connection = connection;
    this.rawResponse = rawResponse;
    this.graphObject = graphObject;
    this.graphObjectList = graphObjects;
    this.isFromCache = isFromCache;
    this.error = error;
}
项目:AndroidBackendlessChat    文件:Response.java   
/**
 * The single graph object returned for this request, if any, cast into a particular type of GraphObject.
 *
 * @param graphObjectClass the GraphObject-derived interface to cast the graph object into
 * @return the graph object returned, or null if none was returned (or if the result was a list)
 * @throws FacebookException If the passed in Class is not a valid GraphObject interface
 */
public final <T extends GraphObject> T getGraphObjectAs(Class<T> graphObjectClass) {
    if (graphObject == null) {
        return null;
    }
    if (graphObjectClass == null) {
        throw new NullPointerException("Must pass in a valid interface that extends GraphObject");
    }
    return graphObject.cast(graphObjectClass);
}
项目:AndroidBackendlessChat    文件:Response.java   
private static Response createResponseFromObject(Request request, HttpURLConnection connection, Object object,
        boolean isFromCache, Object originalResult) throws JSONException {
    if (object instanceof JSONObject) {
        JSONObject jsonObject = (JSONObject) object;

        FacebookRequestError error =
                FacebookRequestError.checkResponseAndCreateError(jsonObject, originalResult, connection);
        if (error != null) {
            if (error.getErrorCode() == INVALID_SESSION_FACEBOOK_ERROR_CODE) {
                Session session = request.getSession();
                if (session != null) {
                    session.closeAndClearTokenInformation();
                }
            }
            return new Response(request, connection, error);
        }

        Object body = Utility.getStringPropertyAsJSON(jsonObject, BODY_KEY, NON_JSON_RESPONSE_PROPERTY);

        if (body instanceof JSONObject) {
            GraphObject graphObject = GraphObject.Factory.create((JSONObject) body);
            return new Response(request, connection, body.toString(), graphObject, isFromCache);
        } else if (body instanceof JSONArray) {
            GraphObjectList<GraphObject> graphObjectList = GraphObject.Factory.createList(
                    (JSONArray) body, GraphObject.class);
            return new Response(request, connection, body.toString(), graphObjectList, isFromCache);
        }
        // We didn't get a body we understand how to handle, so pretend we got nothing.
        object = JSONObject.NULL;
    }

    if (object == JSONObject.NULL) {
        return new Response(request, connection, object.toString(), (GraphObject)null, isFromCache);
    } else {
        throw new FacebookException("Got unexpected object type in response, class: "
                + object.getClass().getSimpleName());
    }
}
项目:AndroidBackendlessChat    文件:Utility.java   
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;
}
项目:AndroidBackendlessChat    文件:Utility.java   
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;
}
项目:AndroidBackendlessChat    文件:GraphObjectAdapter.java   
int getPosition(String sectionKey, T graphObject) {
    int position = 0;
    boolean found = false;

    // First find the section key and increment position one for each header we will render;
    // increment by the size of each section prior to the one we want.
    for (String key : sectionKeys) {
        if (displaySections) {
            position++;
        }
        if (key.equals(sectionKey)) {
            found = true;
            break;
        } else {
            position += graphObjectsBySection.get(key).size();
        }
    }

    if (!found) {
        return -1;
    } else if (graphObject == null) {
        // null represents the header for a section; we counted this header in position earlier,
        // so subtract it back out.
        return position - (displaySections ? 1 : 0);
    }

    // Now find index of this item within that section.
    for (T t : graphObjectsBySection.get(sectionKey)) {
        if (GraphObject.Factory.hasSameId(t, graphObject)) {
            return position;
        }
        position++;
    }
    return -1;
}
项目:AndroidBackendlessChat    文件:BFacebookManager.java   
public static Promise<GraphObject, BError, Void> getUserDetails(){

        final Deferred<GraphObject, BError, Void> deferred = new DeferredObject<>();

        if (Session.getActiveSession().getState().isOpened())
        {
            // Request user data and show the results
            Request.newMeRequest(Session.getActiveSession(), new Request.GraphUserCallback()
            {
                @Override
                public void onCompleted(GraphUser user, Response response)
                {
                    if (response != null)
                    {
                        try
                        {
                            deferred.resolve(user);
                        }
                        catch (Exception e)
                        {
                            deferred.reject(BError.getExceptionError(e));
                        }

                    }
                }
            }).executeAsync();
        } else deferred.reject(new BError(BError.Code.SESSION_CLOSED));

        return deferred.promise();
    }
项目:chat-sdk-android-push-firebase    文件:TestSession.java   
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));
    }
}
项目:chat-sdk-android-push-firebase    文件:Response.java   
Response(Request request, HttpURLConnection connection, String rawResponse, GraphObject graphObject, GraphObjectList<GraphObject> graphObjects, boolean isFromCache, FacebookRequestError error) {
    this.request = request;
    this.connection = connection;
    this.rawResponse = rawResponse;
    this.graphObject = graphObject;
    this.graphObjectList = graphObjects;
    this.isFromCache = isFromCache;
    this.error = error;
}
项目:chat-sdk-android-push-firebase    文件:Response.java   
/**
 * The single graph object returned for this request, if any, cast into a particular type of GraphObject.
 *
 * @param graphObjectClass the GraphObject-derived interface to cast the graph object into
 * @return the graph object returned, or null if none was returned (or if the result was a list)
 * @throws FacebookException If the passed in Class is not a valid GraphObject interface
 */
public final <T extends GraphObject> T getGraphObjectAs(Class<T> graphObjectClass) {
    if (graphObject == null) {
        return null;
    }
    if (graphObjectClass == null) {
        throw new NullPointerException("Must pass in a valid interface that extends GraphObject");
    }
    return graphObject.cast(graphObjectClass);
}
项目:chat-sdk-android-push-firebase    文件:Response.java   
private static Response createResponseFromObject(Request request, HttpURLConnection connection, Object object,
        boolean isFromCache, Object originalResult) throws JSONException {
    if (object instanceof JSONObject) {
        JSONObject jsonObject = (JSONObject) object;

        FacebookRequestError error =
                FacebookRequestError.checkResponseAndCreateError(jsonObject, originalResult, connection);
        if (error != null) {
            if (error.getErrorCode() == INVALID_SESSION_FACEBOOK_ERROR_CODE) {
                Session session = request.getSession();
                if (session != null) {
                    session.closeAndClearTokenInformation();
                }
            }
            return new Response(request, connection, error);
        }

        Object body = Utility.getStringPropertyAsJSON(jsonObject, BODY_KEY, NON_JSON_RESPONSE_PROPERTY);

        if (body instanceof JSONObject) {
            GraphObject graphObject = GraphObject.Factory.create((JSONObject) body);
            return new Response(request, connection, body.toString(), graphObject, isFromCache);
        } else if (body instanceof JSONArray) {
            GraphObjectList<GraphObject> graphObjectList = GraphObject.Factory.createList(
                    (JSONArray) body, GraphObject.class);
            return new Response(request, connection, body.toString(), graphObjectList, isFromCache);
        }
        // We didn't get a body we understand how to handle, so pretend we got nothing.
        object = JSONObject.NULL;
    }

    if (object == JSONObject.NULL) {
        return new Response(request, connection, object.toString(), (GraphObject)null, isFromCache);
    } else {
        throw new FacebookException("Got unexpected object type in response, class: "
                + object.getClass().getSimpleName());
    }
}
项目:chat-sdk-android-push-firebase    文件:Utility.java   
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;
}
项目:chat-sdk-android-push-firebase    文件:Utility.java   
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;
}
项目:chat-sdk-android-push-firebase    文件:GraphObjectAdapter.java   
int getPosition(String sectionKey, T graphObject) {
    int position = 0;
    boolean found = false;

    // First find the section key and increment position one for each header we will render;
    // increment by the size of each section prior to the one we want.
    for (String key : sectionKeys) {
        if (displaySections) {
            position++;
        }
        if (key.equals(sectionKey)) {
            found = true;
            break;
        } else {
            position += graphObjectsBySection.get(key).size();
        }
    }

    if (!found) {
        return -1;
    } else if (graphObject == null) {
        // null represents the header for a section; we counted this header in position earlier,
        // so subtract it back out.
        return position - (displaySections ? 1 : 0);
    }

    // Now find index of this item within that section.
    for (T t : graphObjectsBySection.get(sectionKey)) {
        if (GraphObject.Factory.hasSameId(t, graphObject)) {
            return position;
        }
        position++;
    }
    return -1;
}
项目:chat-sdk-android-push-firebase    文件:BFacebookManager.java   
public static Promise<GraphObject, BError, Void> getUserDetails(){

        final Deferred<GraphObject, BError, Void> deferred = new DeferredObject<>();

        if (Session.getActiveSession().getState().isOpened())
        {
            // Request user data and show the results
            Request.newMeRequest(Session.getActiveSession(), new Request.GraphUserCallback()
            {
                @Override
                public void onCompleted(GraphUser user, Response response)
                {
                    if (response != null)
                    {
                        try
                        {
                            deferred.resolve(user);
                        }
                        catch (Exception e)
                        {
                            deferred.reject(BError.getExceptionError(e));
                        }

                    }
                }
            }).executeAsync();
        } else deferred.reject(new BError(BError.Code.SESSION_CLOSED));

        return deferred.promise();
    }