本文整理匯總了Java中com.facebook.internal.Utility.isContentUri方法的典型用法代碼示例。如果您正苦於以下問題:Java Utility.isContentUri方法的具體用法?Java Utility.isContentUri怎麽用?Java Utility.isContentUri使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類com.facebook.internal.Utility
的用法示例。
在下文中一共展示了Utility.isContentUri方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: initialize
import com.facebook.internal.Utility; //導入方法依賴的package包/類
private void initialize()
throws FileNotFoundException {
ParcelFileDescriptor fileDescriptor = null;
try {
if (Utility.isFileUri(videoUri)) {
fileDescriptor = ParcelFileDescriptor.open(
new File(videoUri.getPath()),
ParcelFileDescriptor.MODE_READ_ONLY);
videoSize = fileDescriptor.getStatSize();
videoStream = new ParcelFileDescriptor.AutoCloseInputStream(fileDescriptor);
} else if (Utility.isContentUri(videoUri)) {
videoSize = Utility.getContentSize(videoUri);
videoStream = FacebookSdk
.getApplicationContext()
.getContentResolver()
.openInputStream(videoUri);
} else {
throw new FacebookException("Uri must be a content:// or file:// uri");
}
} catch (FileNotFoundException e) {
Utility.closeQuietly(videoStream);
throw e;
}
}
示例2: validateVideo
import com.facebook.internal.Utility; //導入方法依賴的package包/類
private static void validateVideo(ShareVideo video, Validator validator) {
if (video == null) {
throw new FacebookException("Cannot share a null ShareVideo");
}
Uri localUri = video.getLocalUrl();
if (localUri == null) {
throw new FacebookException("ShareVideo does not have a LocalUrl specified");
}
if (!Utility.isContentUri(localUri) && !Utility.isFileUri(localUri)) {
throw new FacebookException("ShareVideo must reference a video that is on the device");
}
}
示例3: newUploadStagingResourceWithImageRequest
import com.facebook.internal.Utility; //導入方法依賴的package包/類
/**
* 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);
}