Java 类com.facebook.GraphRequest.Callback 实例源码

项目:kognitivo    文件:ShareInternalUtility.java   
public static void registerStaticShareCallback(
        final int requestCode) {
    CallbackManagerImpl.registerStaticCallback(
            requestCode,
            new CallbackManagerImpl.Callback() {
                @Override
                public boolean onActivityResult(int resultCode, Intent data) {
                    return handleActivityResult(
                            requestCode,
                            resultCode,
                            data,
                            getShareResultProcessor(null));
                }
            }
    );
}
项目:kognitivo    文件:ShareInternalUtility.java   
public static void registerSharerCallback(
        final int requestCode,
        final CallbackManager callbackManager,
        final FacebookCallback<Sharer.Result> callback) {
    if (!(callbackManager instanceof CallbackManagerImpl)) {
        throw new FacebookException("Unexpected CallbackManager, " +
                "please use the provided Factory.");
    }

    ((CallbackManagerImpl) callbackManager).registerCallback(
            requestCode,
            new CallbackManagerImpl.Callback() {
                @Override
                public boolean onActivityResult(int resultCode, Intent data) {
                    return handleActivityResult(
                            requestCode,
                            resultCode,
                            data,
                            getShareResultProcessor(callback));
                }
            });
}
项目:kognitivo    文件:ShareInternalUtility.java   
/**
 * Creates a new Request configured to upload an image to create a staging resource. Staging
 * resources allow you to post binary data such as images, in preparation for a post of an Open
 * Graph object or action which references the image. The URI returned when uploading a staging
 * resource may be passed as the image property for an Open Graph object or action.
 *
 * @param accessToken the access token to use, or null
 * @param file        the file containing the image to upload
 * @param callback    a callback that will be called when the request is completed to handle
 *                    success or error conditions
 * @return a Request that is ready to execute
 * @throws FileNotFoundException
 */
public static GraphRequest newUploadStagingResourceWithImageRequest(
        AccessToken accessToken,
        File file,
        Callback callback
) throws FileNotFoundException {
    ParcelFileDescriptor descriptor =
            ParcelFileDescriptor.open(file, ParcelFileDescriptor.MODE_READ_ONLY);
    GraphRequest.ParcelableResourceWithMimeType<ParcelFileDescriptor> resourceWithMimeType =
            new GraphRequest.ParcelableResourceWithMimeType<>(descriptor, "image/png");
    Bundle parameters = new Bundle(1);
    parameters.putParcelable(STAGING_PARAM, resourceWithMimeType);

    return new GraphRequest(
            accessToken,
            MY_STAGING_RESOURCES,
            parameters,
            HttpMethod.POST,
            callback);
}
项目:Move-Alarm_ORCA    文件:ShareInternalUtility.java   
public static void registerStaticShareCallback(
        final int requestCode) {
    CallbackManagerImpl.registerStaticCallback(
            requestCode,
            new CallbackManagerImpl.Callback() {
                @Override
                public boolean onActivityResult(int resultCode, Intent data) {
                    return handleActivityResult(
                            requestCode,
                            resultCode,
                            data,
                            getShareResultProcessor(null));
                }
            }
    );
}
项目:Move-Alarm_ORCA    文件:ShareInternalUtility.java   
public static void registerSharerCallback(
        final int requestCode,
        final CallbackManager callbackManager,
        final FacebookCallback<Sharer.Result> callback) {
    if (!(callbackManager instanceof CallbackManagerImpl)) {
        throw new FacebookException("Unexpected CallbackManager, " +
                "please use the provided Factory.");
    }

    ((CallbackManagerImpl) callbackManager).registerCallback(
            requestCode,
            new CallbackManagerImpl.Callback() {
                @Override
                public boolean onActivityResult(int resultCode, Intent data) {
                    return handleActivityResult(
                            requestCode,
                            resultCode,
                            data,
                            getShareResultProcessor(callback));
                }
            });
}
项目:Move-Alarm_ORCA    文件:ShareInternalUtility.java   
/**
 * Creates a new Request configured to create a user owned Open Graph object.
 *
 * @param accessToken     the accessToken to use, or null
 * @param openGraphObject the Open Graph object to create; must not be null, and must have a
 *                        non-empty type and title
 * @param callback        a callback that will be called when the request is completed to handle
 *                        success or error conditions
 * @return a Request that is ready to execute
 */
public static GraphRequest newPostOpenGraphObjectRequest(
        AccessToken accessToken,
        JSONObject openGraphObject,
        Callback callback) {
    if (openGraphObject == null) {
        throw new FacebookException("openGraphObject cannot be null");
    }
    if (Utility.isNullOrEmpty(openGraphObject.optString("type"))) {
        throw new FacebookException("openGraphObject must have non-null 'type' property");
    }
    if (Utility.isNullOrEmpty(openGraphObject.optString("title"))) {
        throw new FacebookException("openGraphObject must have non-null 'title' property");
    }

    String path = String.format(MY_OBJECTS_FORMAT, openGraphObject.optString("type"));
    Bundle bundle = new Bundle();
    bundle.putString(OBJECT_PARAM, openGraphObject.toString());
    return new GraphRequest(accessToken, path, bundle, HttpMethod.POST, callback);
}
项目:Move-Alarm_ORCA    文件:ShareInternalUtility.java   
/**
 * Creates a new Request configured to publish an Open Graph action.
 *
 * @param accessToken     the access token to use, or null
 * @param openGraphAction the Open Graph action to create; must not be null, and must have a
 *                        non-empty 'type'
 * @param callback        a callback that will be called when the request is completed to handle
 *                        success or error conditions
 * @return a Request that is ready to execute
 */
public static GraphRequest newPostOpenGraphActionRequest(
        AccessToken accessToken,
        JSONObject openGraphAction,
        Callback callback) {
    if (openGraphAction == null) {
        throw new FacebookException("openGraphAction cannot be null");
    }
    String type = openGraphAction.optString("type");
    if (Utility.isNullOrEmpty(type)) {
        throw new FacebookException("openGraphAction must have non-null 'type' property");
    }

    String path = String.format(MY_ACTION_FORMAT, type);
    return GraphRequest.newPostRequest(accessToken, path, openGraphAction, callback);
}
项目:Move-Alarm_ORCA    文件:ShareInternalUtility.java   
/**
 * Creates a new Request configured to update a user owned Open Graph object.
 *
 * @param accessToken     the access token to use, or null
 * @param openGraphObject the Open Graph object to update, which must have a valid 'id'
 *                        property
 * @param callback        a callback that will be called when the request is completed to handle
 *                        success or error conditions
 * @return a Request that is ready to execute
 */
public static GraphRequest newUpdateOpenGraphObjectRequest(
        AccessToken accessToken,
        JSONObject openGraphObject,
        Callback callback) {
    if (openGraphObject == null) {
        throw new FacebookException("openGraphObject cannot be null");
    }

    String path = openGraphObject.optString("id");
    if (path == null) {
        throw new FacebookException("openGraphObject must have an id");
    }

    Bundle bundle = new Bundle();
    bundle.putString(OBJECT_PARAM, openGraphObject.toString());
    return new GraphRequest(accessToken, path, bundle, HttpMethod.POST, callback);
}
项目:Move-Alarm_ORCA    文件:ShareInternalUtility.java   
/**
 * Creates a new Request configured to upload a photo to the user's default photo album. The
 * photo will be read from the specified Uri.

 * @param accessToken the access token to use, or null
 * @param photoUri    the file:// or content:// Uri to the photo on device.
 * @param callback    a callback that will be called when the request is completed to handle
 *                    success or error conditions
 * @return a Request that is ready to execute
 * @throws FileNotFoundException
 */
public static GraphRequest newUploadPhotoRequest(
        AccessToken accessToken,
        Uri photoUri,
        Callback callback)
        throws FileNotFoundException {
    if (Utility.isFileUri(photoUri)) {
        return newUploadPhotoRequest(accessToken, new File(photoUri.getPath()), callback);
    } else if (!Utility.isContentUri(photoUri)) {
        throw new FacebookException("The photo Uri must be either a file:// or content:// Uri");
    }

    Bundle parameters = new Bundle(1);
    parameters.putParcelable(PICTURE_PARAM, photoUri);

    return new GraphRequest(accessToken, MY_PHOTOS, parameters, HttpMethod.POST, callback);
}
项目:Move-Alarm_ORCA    文件:ShareInternalUtility.java   
/**
 * Creates a new Request configured to upload a photo to the user's default photo album. The
 * photo will be read from the specified Uri.

 * @param accessToken the access token to use, or null
 * @param videoUri    the file:// or content:// Uri to the video on device.
 * @param callback    a callback that will be called when the request is completed to handle
 *                    success or error conditions
 * @return a Request that is ready to execute
 * @throws FileNotFoundException
 */
public static GraphRequest newUploadVideoRequest(
        AccessToken accessToken,
        Uri videoUri,
        Callback callback)
        throws FileNotFoundException {
    if (Utility.isFileUri(videoUri)) {
        return newUploadVideoRequest(accessToken, new File(videoUri.getPath()), callback);
    } else if (!Utility.isContentUri(videoUri)) {
        throw new FacebookException("The video Uri must be either a file:// or content:// Uri");
    }

    Bundle parameters = new Bundle(1);
    parameters.putParcelable(PICTURE_PARAM, videoUri);

    return new GraphRequest(accessToken, MY_PHOTOS, parameters, HttpMethod.POST, callback);
}
项目:Move-Alarm_ORCA    文件:ShareInternalUtility.java   
/**
 * Creates a new Request configured to post a status update to a user's feed.
 *
 * @param accessToken the access token to use, or null
 * @param message     the text of the status update
 * @param placeId     an optional place id to associate with the post
 * @param tagIds      an optional list of user ids to tag in the post
 * @param callback    a callback that will be called when the request is completed to handle
 *                    success or error conditions
 * @return a Request that is ready to execute
 */
private static GraphRequest newStatusUpdateRequest(
        AccessToken accessToken,
        String message,
        String placeId,
        List<String> tagIds,
        Callback callback) {

    Bundle parameters = new Bundle();
    parameters.putString("message", message);

    if (placeId != null) {
        parameters.putString("place", placeId);
    }

    if (tagIds != null && tagIds.size() > 0) {
        String tags = TextUtils.join(",", tagIds);
        parameters.putString("tags", tags);
    }

    return new GraphRequest(accessToken, MY_FEED, parameters, HttpMethod.POST, callback);
}
项目:Move-Alarm_ORCA    文件:ShareInternalUtility.java   
/**
 * Creates a new Request configured to post a status update to a user's feed.
 *
 * @param accessToken the access token to use, or null
 * @param message     the text of the status update
 * @param place       an optional place to associate with the post
 * @param tags        an optional list of users to tag in the post
 * @param callback    a callback that will be called when the request is completed to handle
 *                    success or error conditions
 * @return a Request that is ready to execute
 */
public static GraphRequest newStatusUpdateRequest(
        AccessToken accessToken,
        String message,
        JSONObject place,
        List<JSONObject> tags,
        Callback callback) {

    List<String> tagIds = null;
    if (tags != null) {
        tagIds = new ArrayList<String>(tags.size());
        for (JSONObject tag: tags) {
            tagIds.add(tag.optString("id"));
        }
    }
    String placeId = place == null ? null : place.optString("id");
    return newStatusUpdateRequest(accessToken, message, placeId, tagIds, callback);
}
项目:Move-Alarm_ORCA    文件:ShareInternalUtility.java   
/**
 * Creates a new Request configured to upload an image to create a staging resource. Staging
 * resources allow you to post binary data such as images, in preparation for a post of an Open
 * Graph object or action which references the image. The URI returned when uploading a staging
 * resource may be passed as the image property for an Open Graph object or action.
 *
 * @param accessToken the access token to use, or null
 * @param file        the file containing the image to upload
 * @param callback    a callback that will be called when the request is completed to handle
 *                    success or error conditions
 * @return a Request that is ready to execute
 * @throws FileNotFoundException
 */
public static GraphRequest newUploadStagingResourceWithImageRequest(
        AccessToken accessToken,
        File file,
        Callback callback
) throws FileNotFoundException {
    ParcelFileDescriptor descriptor =
            ParcelFileDescriptor.open(file, ParcelFileDescriptor.MODE_READ_ONLY);
    GraphRequest.ParcelableResourceWithMimeType<ParcelFileDescriptor> resourceWithMimeType =
            new GraphRequest.ParcelableResourceWithMimeType<>(descriptor, "image/png");
    Bundle parameters = new Bundle(1);
    parameters.putParcelable(STAGING_PARAM, resourceWithMimeType);

    return new GraphRequest(
            accessToken,
            MY_STAGING_RESOURCES,
            parameters,
            HttpMethod.POST,
            callback);
}
项目:SocioBlood    文件:ShareInternalUtility.java   
public static void registerStaticShareCallback(
        final int requestCode) {
    CallbackManagerImpl.registerStaticCallback(
            requestCode,
            new CallbackManagerImpl.Callback() {
                @Override
                public boolean onActivityResult(int resultCode, Intent data) {
                    return handleActivityResult(
                            requestCode,
                            resultCode,
                            data,
                            getShareResultProcessor(null));
                }
            }
    );
}
项目:SocioBlood    文件:ShareInternalUtility.java   
public static void registerSharerCallback(
        final int requestCode,
        final CallbackManager callbackManager,
        final FacebookCallback<Sharer.Result> callback) {
    if (!(callbackManager instanceof CallbackManagerImpl)) {
        throw new FacebookException("Unexpected CallbackManager, " +
                "please use the provided Factory.");
    }

    ((CallbackManagerImpl) callbackManager).registerCallback(
            requestCode,
            new CallbackManagerImpl.Callback() {
                @Override
                public boolean onActivityResult(int resultCode, Intent data) {
                    return handleActivityResult(
                            requestCode,
                            resultCode,
                            data,
                            getShareResultProcessor(callback));
                }
            });
}
项目:SocioBlood    文件:ShareInternalUtility.java   
/**
 * Creates a new Request configured to create a user owned Open Graph object.
 *
 * @param accessToken     the accessToken to use, or null
 * @param openGraphObject the Open Graph object to create; must not be null, and must have a
 *                        non-empty type and title
 * @param callback        a callback that will be called when the request is completed to handle
 *                        success or error conditions
 * @return a Request that is ready to execute
 */
public static GraphRequest newPostOpenGraphObjectRequest(
        AccessToken accessToken,
        JSONObject openGraphObject,
        Callback callback) {
    if (openGraphObject == null) {
        throw new FacebookException("openGraphObject cannot be null");
    }
    if (Utility.isNullOrEmpty(openGraphObject.optString("type"))) {
        throw new FacebookException("openGraphObject must have non-null 'type' property");
    }
    if (Utility.isNullOrEmpty(openGraphObject.optString("title"))) {
        throw new FacebookException("openGraphObject must have non-null 'title' property");
    }

    String path = String.format(MY_OBJECTS_FORMAT, openGraphObject.optString("type"));
    Bundle bundle = new Bundle();
    bundle.putString(OBJECT_PARAM, openGraphObject.toString());
    return new GraphRequest(accessToken, path, bundle, HttpMethod.POST, callback);
}
项目:SocioBlood    文件:ShareInternalUtility.java   
/**
 * Creates a new Request configured to publish an Open Graph action.
 *
 * @param accessToken     the access token to use, or null
 * @param openGraphAction the Open Graph action to create; must not be null, and must have a
 *                        non-empty 'type'
 * @param callback        a callback that will be called when the request is completed to handle
 *                        success or error conditions
 * @return a Request that is ready to execute
 */
public static GraphRequest newPostOpenGraphActionRequest(
        AccessToken accessToken,
        JSONObject openGraphAction,
        Callback callback) {
    if (openGraphAction == null) {
        throw new FacebookException("openGraphAction cannot be null");
    }
    String type = openGraphAction.optString("type");
    if (Utility.isNullOrEmpty(type)) {
        throw new FacebookException("openGraphAction must have non-null 'type' property");
    }

    String path = String.format(MY_ACTION_FORMAT, type);
    return GraphRequest.newPostRequest(accessToken, path, openGraphAction, callback);
}
项目:SocioBlood    文件:ShareInternalUtility.java   
/**
 * Creates a new Request configured to update a user owned Open Graph object.
 *
 * @param accessToken     the access token to use, or null
 * @param openGraphObject the Open Graph object to update, which must have a valid 'id'
 *                        property
 * @param callback        a callback that will be called when the request is completed to handle
 *                        success or error conditions
 * @return a Request that is ready to execute
 */
public static GraphRequest newUpdateOpenGraphObjectRequest(
        AccessToken accessToken,
        JSONObject openGraphObject,
        Callback callback) {
    if (openGraphObject == null) {
        throw new FacebookException("openGraphObject cannot be null");
    }

    String path = openGraphObject.optString("id");
    if (path == null) {
        throw new FacebookException("openGraphObject must have an id");
    }

    Bundle bundle = new Bundle();
    bundle.putString(OBJECT_PARAM, openGraphObject.toString());
    return new GraphRequest(accessToken, path, bundle, HttpMethod.POST, callback);
}
项目:SocioBlood    文件:ShareInternalUtility.java   
/**
 * Creates a new Request configured to upload a photo to the user's default photo album. The
 * photo will be read from the specified file.
 *
 * @param accessToken the access token to use, or null
 * @param file        the file containing the photo to upload
 * @param caption     the user generated caption for the photo.
 * @param callback    a callback that will be called when the request is completed to handle
 *                    success or error conditions
 * @return a Request that is ready to execute
 * @throws java.io.FileNotFoundException
 */
public static GraphRequest newUploadPhotoRequest(
        AccessToken accessToken,
        File file,
        String caption,
        Callback callback
) throws FileNotFoundException {
    ParcelFileDescriptor descriptor =
            ParcelFileDescriptor.open(file, ParcelFileDescriptor.MODE_READ_ONLY);
    Bundle parameters = new Bundle(1);
    parameters.putParcelable(PICTURE_PARAM, descriptor);
    if (caption != null && !caption.isEmpty()) {
        parameters.putString(CAPTION_PARAM, caption);
    }

    return new GraphRequest(accessToken, MY_PHOTOS, parameters, HttpMethod.POST, callback);
}
项目:SocioBlood    文件:ShareInternalUtility.java   
/**
 * Creates a new Request configured to upload a photo to the user's default photo album. The
 * photo will be read from the specified Uri.
 *
 * @param accessToken the access token to use, or null
 * @param photoUri    the file:// or content:// Uri to the photo on device.
 * @param caption     the user generated caption for the photo.
 * @param callback    a callback that will be called when the request is completed to handle
 *                    success or error conditions
 * @return a Request that is ready to execute
 * @throws FileNotFoundException
 */
public static GraphRequest newUploadPhotoRequest(
        AccessToken accessToken,
        Uri photoUri,
        String caption,
        Callback callback)
        throws FileNotFoundException {
    if (Utility.isFileUri(photoUri)) {
        return newUploadPhotoRequest(
                accessToken,
                new File(photoUri.getPath()),
                caption,
                callback);
    } else if (!Utility.isContentUri(photoUri)) {
        throw new FacebookException("The photo Uri must be either a file:// or content:// Uri");
    }

    Bundle parameters = new Bundle(1);
    parameters.putParcelable(PICTURE_PARAM, photoUri);

    return new GraphRequest(accessToken, MY_PHOTOS, parameters, HttpMethod.POST, callback);
}
项目:SocioBlood    文件:ShareInternalUtility.java   
/**
 * Creates a new Request configured to post a status update to a user's feed.
 *
 * @param accessToken the access token to use, or null
 * @param message     the text of the status update
 * @param placeId     an optional place id to associate with the post
 * @param tagIds      an optional list of user ids to tag in the post
 * @param callback    a callback that will be called when the request is completed to handle
 *                    success or error conditions
 * @return a Request that is ready to execute
 */
private static GraphRequest newStatusUpdateRequest(
        AccessToken accessToken,
        String message,
        String placeId,
        List<String> tagIds,
        Callback callback) {

    Bundle parameters = new Bundle();
    parameters.putString("message", message);

    if (placeId != null) {
        parameters.putString("place", placeId);
    }

    if (tagIds != null && tagIds.size() > 0) {
        String tags = TextUtils.join(",", tagIds);
        parameters.putString("tags", tags);
    }

    return new GraphRequest(accessToken, MY_FEED, parameters, HttpMethod.POST, callback);
}
项目:SocioBlood    文件:ShareInternalUtility.java   
/**
 * Creates a new Request configured to post a status update to a user's feed.
 *
 * @param accessToken the access token to use, or null
 * @param message     the text of the status update
 * @param place       an optional place to associate with the post
 * @param tags        an optional list of users to tag in the post
 * @param callback    a callback that will be called when the request is completed to handle
 *                    success or error conditions
 * @return a Request that is ready to execute
 */
public static GraphRequest newStatusUpdateRequest(
        AccessToken accessToken,
        String message,
        JSONObject place,
        List<JSONObject> tags,
        Callback callback) {

    List<String> tagIds = null;
    if (tags != null) {
        tagIds = new ArrayList<String>(tags.size());
        for (JSONObject tag : tags) {
            tagIds.add(tag.optString("id"));
        }
    }
    String placeId = place == null ? null : place.optString("id");
    return newStatusUpdateRequest(accessToken, message, placeId, tagIds, callback);
}
项目:SocioBlood    文件:ShareInternalUtility.java   
/**
 * Creates a new Request configured to upload an image to create a staging resource. Staging
 * resources allow you to post binary data such as images, in preparation for a post of an Open
 * Graph object or action which references the image. The URI returned when uploading a staging
 * resource may be passed as the image property for an Open Graph object or action.
 *
 * @param accessToken the access token to use, or null
 * @param file        the file containing the image to upload
 * @param callback    a callback that will be called when the request is completed to handle
 *                    success or error conditions
 * @return a Request that is ready to execute
 * @throws FileNotFoundException
 */
public static GraphRequest newUploadStagingResourceWithImageRequest(
        AccessToken accessToken,
        File file,
        Callback callback
) throws FileNotFoundException {
    ParcelFileDescriptor descriptor =
            ParcelFileDescriptor.open(file, ParcelFileDescriptor.MODE_READ_ONLY);
    GraphRequest.ParcelableResourceWithMimeType<ParcelFileDescriptor> resourceWithMimeType =
            new GraphRequest.ParcelableResourceWithMimeType<>(descriptor, "image/png");
    Bundle parameters = new Bundle(1);
    parameters.putParcelable(STAGING_PARAM, resourceWithMimeType);

    return new GraphRequest(
            accessToken,
            MY_STAGING_RESOURCES,
            parameters,
            HttpMethod.POST,
            callback);
}
项目:kognitivo    文件:ShareInternalUtility.java   
/**
 * Creates a new Request configured to upload an image to create a staging resource. Staging
 * resources allow you to post binary data such as images, in preparation for a post of an Open
 * Graph object or action which references the image. The URI returned when uploading a staging
 * resource may be passed as the image property for an Open Graph object or action.
 *
 * @param accessToken the access token to use, or null
 * @param image       the image to upload
 * @param callback    a callback that will be called when the request is completed to handle
 *                    success or error conditions
 * @return a Request that is ready to execute
 */
public static GraphRequest newUploadStagingResourceWithImageRequest(
        AccessToken accessToken,
        Bitmap image,
        Callback callback) {
    Bundle parameters = new Bundle(1);
    parameters.putParcelable(STAGING_PARAM, image);

    return new GraphRequest(
            accessToken,
            MY_STAGING_RESOURCES,
            parameters,
            HttpMethod.POST,
            callback);
}
项目:kognitivo    文件:ShareInternalUtility.java   
/**
 * Creates a new Request configured to upload an image to create a staging resource. Staging
 * resources allow you to post binary data such as images, in preparation for a post of an Open
 * Graph object or action which references the image. The URI returned when uploading a staging
 * resource may be passed as the image property for an Open Graph object or action.
 *
 * @param accessToken the access token to use, or null
 * @param imageUri    the file:// or content:// Uri pointing to the image to upload
 * @param callback    a callback that will be called when the request is completed to handle
 *                    success or error conditions
 * @return a Request that is ready to execute
 * @throws FileNotFoundException
 */
public static GraphRequest newUploadStagingResourceWithImageRequest(
        AccessToken accessToken,
        Uri imageUri,
        Callback callback
) throws FileNotFoundException {
    if (Utility.isFileUri(imageUri)) {
        return newUploadStagingResourceWithImageRequest(
                accessToken,
                new File(imageUri.getPath()),
                callback);
    } else if (!Utility.isContentUri(imageUri)) {
        throw new FacebookException("The image Uri must be either a file:// or content:// Uri");
    }

    GraphRequest.ParcelableResourceWithMimeType<Uri> resourceWithMimeType =
            new GraphRequest.ParcelableResourceWithMimeType<>(imageUri, "image/png");
    Bundle parameters = new Bundle(1);
    parameters.putParcelable(STAGING_PARAM, resourceWithMimeType);

    return new GraphRequest(
            accessToken,
            MY_STAGING_RESOURCES,
            parameters,
            HttpMethod.POST,
            callback);
}
项目:Move-Alarm_ORCA    文件:ShareInternalUtility.java   
/**
 * Creates a new Request configured to upload a photo to the user's default photo album.
 *
 * @param accessToken the access token to use, or null
 * @param image       the image to upload
 * @param callback    a callback that will be called when the request is completed to handle
 *                    success or error conditions
 * @return a Request that is ready to execute
 */
public static GraphRequest newUploadPhotoRequest(
        AccessToken accessToken,
        Bitmap image,
        Callback callback) {
    Bundle parameters = new Bundle(1);
    parameters.putParcelable(PICTURE_PARAM, image);

    return new GraphRequest(accessToken, MY_PHOTOS, parameters, HttpMethod.POST, callback);
}
项目:Move-Alarm_ORCA    文件:ShareInternalUtility.java   
/**
 * Creates a new Request configured to upload a photo to the user's default photo album. The
 * photo will be read from the specified file.
 *
 * @param accessToken the access token to use, or null
 * @param file        the file containing the photo to upload
 * @param callback    a callback that will be called when the request is completed to handle
 *                    success or error conditions
 * @return a Request that is ready to execute
 * @throws java.io.FileNotFoundException
 */
public static GraphRequest newUploadPhotoRequest(
        AccessToken accessToken,
        File file,
        Callback callback
) throws FileNotFoundException {
    ParcelFileDescriptor descriptor =
            ParcelFileDescriptor.open(file, ParcelFileDescriptor.MODE_READ_ONLY);
    Bundle parameters = new Bundle(1);
    parameters.putParcelable(PICTURE_PARAM, descriptor);

    return new GraphRequest(accessToken, MY_PHOTOS, parameters, HttpMethod.POST, callback);
}
项目:Move-Alarm_ORCA    文件:ShareInternalUtility.java   
/**
 * Creates a new Request configured to upload a video to the user's default video album. The
 * video will be read from the specified file.
 *
 * @param accessToken the access token to use, or null
 * @param file        the file to upload
 * @param callback    a callback that will be called when the request is completed to handle
 *                    success or error conditions
 * @return a Request that is ready to execute
 * @throws FileNotFoundException
 */
public static GraphRequest newUploadVideoRequest(
        AccessToken accessToken,
        File file,
        Callback callback
) throws FileNotFoundException {
    ParcelFileDescriptor descriptor =
            ParcelFileDescriptor.open(file, ParcelFileDescriptor.MODE_READ_ONLY);
    Bundle parameters = new Bundle(1);
    parameters.putParcelable(file.getName(), descriptor);

    return new GraphRequest(accessToken, MY_VIDEOS, parameters, HttpMethod.POST, callback);
}
项目:Move-Alarm_ORCA    文件:ShareInternalUtility.java   
/**
 * Creates a new Request configured to upload an image to create a staging resource. Staging
 * resources allow you to post binary data such as images, in preparation for a post of an Open
 * Graph object or action which references the image. The URI returned when uploading a staging
 * resource may be passed as the image property for an Open Graph object or action.
 *
 * @param accessToken the access token to use, or null
 * @param image       the image to upload
 * @param callback    a callback that will be called when the request is completed to handle
 *                    success or error conditions
 * @return a Request that is ready to execute
 */
public static GraphRequest newUploadStagingResourceWithImageRequest(
        AccessToken accessToken,
        Bitmap image,
        Callback callback) {
    Bundle parameters = new Bundle(1);
    parameters.putParcelable(STAGING_PARAM, image);

    return new GraphRequest(
            accessToken,
            MY_STAGING_RESOURCES,
            parameters,
            HttpMethod.POST,
            callback);
}
项目:Move-Alarm_ORCA    文件:ShareInternalUtility.java   
/**
 * Creates a new Request configured to upload an image to create a staging resource. Staging
 * resources allow you to post binary data such as images, in preparation for a post of an Open
 * Graph object or action which references the image. The URI returned when uploading a staging
 * resource may be passed as the image property for an Open Graph object or action.
 *
 * @param accessToken the access token to use, or null
 * @param imageUri    the file:// or content:// Uri pointing to the image to upload
 * @param callback    a callback that will be called when the request is completed to handle
 *                    success or error conditions
 * @return a Request that is ready to execute
 * @throws FileNotFoundException
 */
public static GraphRequest newUploadStagingResourceWithImageRequest(
        AccessToken accessToken,
        Uri imageUri,
        Callback callback
) throws FileNotFoundException {
    if (Utility.isFileUri(imageUri)) {
        return newUploadStagingResourceWithImageRequest(
                accessToken,
                new File(imageUri.getPath()),
                callback);
    } else if (!Utility.isContentUri(imageUri)) {
        throw new FacebookException("The image Uri must be either a file:// or content:// Uri");
    }

    GraphRequest.ParcelableResourceWithMimeType<Uri> resourceWithMimeType =
            new GraphRequest.ParcelableResourceWithMimeType<>(imageUri, "image/png");
    Bundle parameters = new Bundle(1);
    parameters.putParcelable(STAGING_PARAM, resourceWithMimeType);

    return new GraphRequest(
            accessToken,
            MY_STAGING_RESOURCES,
            parameters,
            HttpMethod.POST,
            callback);
}
项目:SocioBlood    文件:ShareInternalUtility.java   
/**
 * Creates a new Request configured to upload a photo to the user's default photo album.
 *
 * @param accessToken the access token to use, or null
 * @param image       the image to upload
 * @param caption     the user generated caption for the photo.
 * @param callback    a callback that will be called when the request is completed to handle
 *                    success or error conditions
 * @return a Request that is ready to execute
 */
public static GraphRequest newUploadPhotoRequest(
        AccessToken accessToken,
        Bitmap image,
        String caption,
        Callback callback) {
    Bundle parameters = new Bundle(1);
    parameters.putParcelable(PICTURE_PARAM, image);
    if (caption != null && !caption.isEmpty()) {
        parameters.putString(CAPTION_PARAM, caption);
    }

    return new GraphRequest(accessToken, MY_PHOTOS, parameters, HttpMethod.POST, callback);
}
项目:SocioBlood    文件:ShareInternalUtility.java   
/**
 * Creates a new Request configured to upload an image to create a staging resource. Staging
 * resources allow you to post binary data such as images, in preparation for a post of an Open
 * Graph object or action which references the image. The URI returned when uploading a staging
 * resource may be passed as the image property for an Open Graph object or action.
 *
 * @param accessToken the access token to use, or null
 * @param image       the image to upload
 * @param callback    a callback that will be called when the request is completed to handle
 *                    success or error conditions
 * @return a Request that is ready to execute
 */
public static GraphRequest newUploadStagingResourceWithImageRequest(
        AccessToken accessToken,
        Bitmap image,
        Callback callback) {
    Bundle parameters = new Bundle(1);
    parameters.putParcelable(STAGING_PARAM, image);

    return new GraphRequest(
            accessToken,
            MY_STAGING_RESOURCES,
            parameters,
            HttpMethod.POST,
            callback);
}
项目:SocioBlood    文件:ShareInternalUtility.java   
/**
 * Creates a new Request configured to upload an image to create a staging resource. Staging
 * resources allow you to post binary data such as images, in preparation for a post of an Open
 * Graph object or action which references the image. The URI returned when uploading a staging
 * resource may be passed as the image property for an Open Graph object or action.
 *
 * @param accessToken the access token to use, or null
 * @param imageUri    the file:// or content:// Uri pointing to the image to upload
 * @param callback    a callback that will be called when the request is completed to handle
 *                    success or error conditions
 * @return a Request that is ready to execute
 * @throws FileNotFoundException
 */
public static GraphRequest newUploadStagingResourceWithImageRequest(
        AccessToken accessToken,
        Uri imageUri,
        Callback callback
) throws FileNotFoundException {
    if (Utility.isFileUri(imageUri)) {
        return newUploadStagingResourceWithImageRequest(
                accessToken,
                new File(imageUri.getPath()),
                callback);
    } else if (!Utility.isContentUri(imageUri)) {
        throw new FacebookException("The image Uri must be either a file:// or content:// Uri");
    }

    GraphRequest.ParcelableResourceWithMimeType<Uri> resourceWithMimeType =
            new GraphRequest.ParcelableResourceWithMimeType<>(imageUri, "image/png");
    Bundle parameters = new Bundle(1);
    parameters.putParcelable(STAGING_PARAM, resourceWithMimeType);

    return new GraphRequest(
            accessToken,
            MY_STAGING_RESOURCES,
            parameters,
            HttpMethod.POST,
            callback);
}
项目:Move-Alarm_ORCA    文件:ShareInternalUtility.java   
/**
 * Creates a new Request configured to create a user owned Open Graph object.
 *
 * @param accessToken      the access token to use, or null
 * @param type             the fully-specified Open Graph object type (e.g.,
 *                         my_app_namespace:my_object_name); must not be null
 * @param title            the title of the Open Graph object; must not be null
 * @param imageUrl         the link to an image to be associated with the Open Graph object; may
 *                         be null
 * @param url              the url to be associated with the Open Graph object; may be null
 * @param description      the description to be associated with the object; may be null
 * @param objectProperties any additional type-specific properties for the Open Graph object;
 *                         may be null
 * @param callback         a callback that will be called when the request is completed to
 *                         handle success or error conditions; may be null
 * @return a Request that is ready to execute
 */
public static GraphRequest newPostOpenGraphObjectRequest(
        AccessToken accessToken,
        String type,
        String title,
        String imageUrl,
        String url,
        String description,
        JSONObject objectProperties,
        Callback callback) {
    JSONObject openGraphObject = GraphUtil.createOpenGraphObjectForPost(
            type, title, imageUrl, url, description, objectProperties, null);
    return newPostOpenGraphObjectRequest(accessToken, openGraphObject, callback);
}
项目:Move-Alarm_ORCA    文件:ShareInternalUtility.java   
/**
 * Creates a new Request configured to update a user owned Open Graph object.
 *
 * @param accessToken      the access token to use, or null
 * @param id               the id of the Open Graph object
 * @param title            the title of the Open Graph object
 * @param imageUrl         the link to an image to be associated with the Open Graph object
 * @param url              the url to be associated with the Open Graph object
 * @param description      the description to be associated with the object
 * @param objectProperties any additional type-specific properties for the Open Graph object
 * @param callback         a callback that will be called when the request is completed to
 *                         handle success or error conditions
 * @return a Request that is ready to execute
 */
public static GraphRequest newUpdateOpenGraphObjectRequest(
        AccessToken accessToken,
        String id,
        String title,
        String imageUrl,
        String url,
        String description,
        JSONObject objectProperties,
        Callback callback) {
    JSONObject openGraphObject = GraphUtil.createOpenGraphObjectForPost(
            null, title, imageUrl, url, description, objectProperties, id);
    return newUpdateOpenGraphObjectRequest(accessToken, openGraphObject, callback);
}
项目:Move-Alarm_ORCA    文件:ShareInternalUtility.java   
/**
 * Creates a new Request configured to post a status update to a user's feed.
 *
 * @param accessToken the access token to use, or null
 * @param message     the text of the status update
 * @param callback    a callback that will be called when the request is completed to handle
 *                    success or error conditions
 * @return a Request that is ready to execute
 */
public static GraphRequest newStatusUpdateRequest(
        AccessToken accessToken,
        String message,
        Callback callback) {
    return newStatusUpdateRequest(accessToken, message, (String)null, null, callback);
}
项目:SocioBlood    文件:ShareInternalUtility.java   
/**
 * Creates a new Request configured to create a user owned Open Graph object.
 *
 * @param accessToken      the access token to use, or null
 * @param type             the fully-specified Open Graph object type (e.g.,
 *                         my_app_namespace:my_object_name); must not be null
 * @param title            the title of the Open Graph object; must not be null
 * @param imageUrl         the link to an image to be associated with the Open Graph object; may
 *                         be null
 * @param url              the url to be associated with the Open Graph object; may be null
 * @param description      the description to be associated with the object; may be null
 * @param objectProperties any additional type-specific properties for the Open Graph object;
 *                         may be null
 * @param callback         a callback that will be called when the request is completed to
 *                         handle success or error conditions; may be null
 * @return a Request that is ready to execute
 */
public static GraphRequest newPostOpenGraphObjectRequest(
        AccessToken accessToken,
        String type,
        String title,
        String imageUrl,
        String url,
        String description,
        JSONObject objectProperties,
        Callback callback) {
    JSONObject openGraphObject = GraphUtil.createOpenGraphObjectForPost(
            type, title, imageUrl, url, description, objectProperties, null);
    return newPostOpenGraphObjectRequest(accessToken, openGraphObject, callback);
}
项目:SocioBlood    文件:ShareInternalUtility.java   
/**
 * Creates a new Request configured to update a user owned Open Graph object.
 *
 * @param accessToken      the access token to use, or null
 * @param id               the id of the Open Graph object
 * @param title            the title of the Open Graph object
 * @param imageUrl         the link to an image to be associated with the Open Graph object
 * @param url              the url to be associated with the Open Graph object
 * @param description      the description to be associated with the object
 * @param objectProperties any additional type-specific properties for the Open Graph object
 * @param callback         a callback that will be called when the request is completed to
 *                         handle success or error conditions
 * @return a Request that is ready to execute
 */
public static GraphRequest newUpdateOpenGraphObjectRequest(
        AccessToken accessToken,
        String id,
        String title,
        String imageUrl,
        String url,
        String description,
        JSONObject objectProperties,
        Callback callback) {
    JSONObject openGraphObject = GraphUtil.createOpenGraphObjectForPost(
            null, title, imageUrl, url, description, objectProperties, id);
    return newUpdateOpenGraphObjectRequest(accessToken, openGraphObject, callback);
}
项目:SocioBlood    文件:ShareInternalUtility.java   
/**
 * Creates a new Request configured to post a status update to a user's feed.
 *
 * @param accessToken the access token to use, or null
 * @param message     the text of the status update
 * @param callback    a callback that will be called when the request is completed to handle
 *                    success or error conditions
 * @return a Request that is ready to execute
 */
public static GraphRequest newStatusUpdateRequest(
        AccessToken accessToken,
        String message,
        Callback callback) {
    return newStatusUpdateRequest(accessToken, message, (String) null, null, callback);
}