Java Code Examples for com.facebook.internal.Utility#readStreamToString()

The following examples show how to use com.facebook.internal.Utility#readStreamToString() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: LikeActionController.java    From kognitivo with Apache License 2.0 6 votes vote down vote up
/**
 * NOTE: This MUST be called ONLY via the CreateLikeActionControllerWorkItem class to ensure
 * that it happens on the right thread, at the right time.
 */
private static LikeActionController deserializeFromDiskSynchronously(String objectId) {
    LikeActionController controller = null;

    InputStream inputStream = null;
    try {
        String cacheKey = getCacheKeyForObjectId(objectId);
        inputStream = controllerDiskCache.get(cacheKey);
        if (inputStream != null) {
            String controllerJsonString = Utility.readStreamToString(inputStream);
            if (!Utility.isNullOrEmpty(controllerJsonString)) {
                controller = deserializeFromJson(controllerJsonString);
            }
        }
    } catch (IOException e) {
        Log.e(TAG, "Unable to deserialize controller from disk", e);
        controller = null;
    } finally {
        if (inputStream != null) {
            Utility.closeQuietly(inputStream);
        }
    }

    return controller;
}
 
Example 2
Source File: GraphResponse.java    From kognitivo with Apache License 2.0 5 votes vote down vote up
static List<GraphResponse> createResponsesFromStream(
        InputStream stream,
        HttpURLConnection connection,
        GraphRequestBatch requests
) throws FacebookException, JSONException, IOException {

    String responseString = Utility.readStreamToString(stream);
    Logger.log(LoggingBehavior.INCLUDE_RAW_RESPONSES, RESPONSE_LOG_TAG,
            "Response (raw)\n  Size: %d\n  Response:\n%s\n", responseString.length(),
            responseString);

    return createResponsesFromString(responseString, connection, requests);
}
 
Example 3
Source File: Response.java    From Abelana-Android with Apache License 2.0 5 votes vote down vote up
static List<Response> createResponsesFromStream(InputStream stream, HttpURLConnection connection,
        RequestBatch requests, boolean isFromCache) throws FacebookException, JSONException, IOException {

    String responseString = Utility.readStreamToString(stream);
    Logger.log(LoggingBehavior.INCLUDE_RAW_RESPONSES, RESPONSE_LOG_TAG,
            "Response (raw)\n  Size: %d\n  Response:\n%s\n", responseString.length(),
            responseString);

    return createResponsesFromString(responseString, connection, requests, isFromCache);
}
 
Example 4
Source File: Response.java    From facebook-api-android-maven with Apache License 2.0 5 votes vote down vote up
static List<Response> createResponsesFromStream(InputStream stream, HttpURLConnection connection,
        RequestBatch requests, boolean isFromCache) throws FacebookException, JSONException, IOException {

    String responseString = Utility.readStreamToString(stream);
    Logger.log(LoggingBehavior.INCLUDE_RAW_RESPONSES, RESPONSE_LOG_TAG,
            "Response (raw)\n  Size: %d\n  Response:\n%s\n", responseString.length(),
            responseString);

    return createResponsesFromString(responseString, connection, requests, isFromCache);
}