本文整理汇总了Java中com.facebook.share.model.SharePhoto类的典型用法代码示例。如果您正苦于以下问题:Java SharePhoto类的具体用法?Java SharePhoto怎么用?Java SharePhoto使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
SharePhoto类属于com.facebook.share.model包,在下文中一共展示了SharePhoto类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: validatePhotoContent
import com.facebook.share.model.SharePhoto; //导入依赖的package包/类
private static void validatePhotoContent(
SharePhotoContent photoContent, Validator validator) {
List<SharePhoto> photos = photoContent.getPhotos();
if (photos == null || photos.isEmpty()) {
throw new FacebookException("Must specify at least one Photo in SharePhotoContent.");
}
if (photos.size() > ShareConstants.MAXIMUM_PHOTO_COUNT) {
throw new FacebookException(
String.format(
Locale.ROOT,
"Cannot add more than %d photos.",
ShareConstants.MAXIMUM_PHOTO_COUNT));
}
for (SharePhoto photo : photos) {
validator.validate(photo);
}
}
示例2: validatePhotoForApi
import com.facebook.share.model.SharePhoto; //导入依赖的package包/类
private static void validatePhotoForApi(SharePhoto photo, Validator validator) {
if (photo == null) {
throw new FacebookException("Cannot share a null SharePhoto");
}
Bitmap photoBitmap = photo.getBitmap();
Uri photoUri = photo.getImageUrl();
if (photoBitmap == null) {
if (photoUri == null) {
throw new FacebookException(
"SharePhoto does not have a Bitmap or ImageUrl specified");
}
if (Utility.isWebUri(photoUri) && !validator.isOpenGraphContent()) {
throw new FacebookException(
"Cannot set the ImageUrl of a SharePhoto to the Uri of an image on the " +
"web when sharing SharePhotoContent");
}
}
}
示例3: toJSONObjectForWeb
import com.facebook.share.model.SharePhoto; //导入依赖的package包/类
public static JSONObject toJSONObjectForWeb(
final ShareOpenGraphContent shareOpenGraphContent)
throws JSONException {
ShareOpenGraphAction action = shareOpenGraphContent.getAction();
return OpenGraphJSONUtility.toJSONObject(
action,
new OpenGraphJSONUtility.PhotoJSONProcessor() {
@Override
public JSONObject toJSONObject(SharePhoto photo) {
Uri photoUri = photo.getImageUrl();
JSONObject photoJSONObject = new JSONObject();
try {
photoJSONObject.put(
NativeProtocol.IMAGE_URL_KEY, photoUri.toString());
} catch (JSONException e) {
throw new FacebookException("Unable to attach images", e);
}
return photoJSONObject;
}
});
}
示例4: getAttachment
import com.facebook.share.model.SharePhoto; //导入依赖的package包/类
private static NativeAppCallAttachmentStore.Attachment getAttachment(
UUID callId,
SharePhoto photo) {
Bitmap bitmap = photo.getBitmap();
Uri photoUri = photo.getImageUrl();
NativeAppCallAttachmentStore.Attachment attachment = null;
if (bitmap != null) {
attachment = NativeAppCallAttachmentStore.createAttachment(
callId,
bitmap);
} else if (photoUri != null) {
attachment = NativeAppCallAttachmentStore.createAttachment(
callId,
photoUri);
}
return attachment;
}
示例5: openFbDialog
import com.facebook.share.model.SharePhoto; //导入依赖的package包/类
public void openFbDialog(int v) {
boolean installed = appInstalledOrNot("com.facebook.katana");
if (installed) {
Bitmap image = getPersonalHeartRateBitmap(v);
SharePhoto photo = new SharePhoto.Builder()
.setBitmap(image)
.build();
SharePhotoContent photoContent = new SharePhotoContent.Builder()
.addPhoto(photo)
.build();
mShareDialog.show(photoContent);
} else {
ShareLinkContent linkContent = new ShareLinkContent.Builder()
.setContentTitle(String.format(mContext.getString(R.string.share_message_format), v))
.setContentDescription(
String.format(mContext.getString(R.string.share_message_format), v))
.setContentUrl(Uri.parse("https://play.google.com/store/apps/details?id=fr.machada.bpm"))
.build();
mShareDialog.show(linkContent);
}
}
示例6: validatePhotoForNativeDialog
import com.facebook.share.model.SharePhoto; //导入依赖的package包/类
private static void validatePhotoForNativeDialog(SharePhoto photo, Validator validator) {
if (photo == null) {
throw new FacebookException("Cannot share a null SharePhoto");
}
Bitmap photoBitmap = photo.getBitmap();
Uri photoUri = photo.getImageUrl();
if (photoBitmap == null) {
if (photoUri == null) {
throw new FacebookException(
"SharePhoto does not have a Bitmap or ImageUrl specified");
}
if (Utility.isWebUri(photoUri) && !validator.isOpenGraphContent()) {
throw new FacebookException(
"Cannot set the ImageUrl of a SharePhoto to the Uri of an image on the " +
"web when sharing SharePhotoContent");
}
}
}
示例7: toJSONValue
import com.facebook.share.model.SharePhoto; //导入依赖的package包/类
public static Object toJSONValue(
@Nullable final Object object,
final PhotoJSONProcessor photoJSONProcessor) throws JSONException {
if (object == null) {
return JSONObject.NULL;
}
if ((object instanceof String) ||
(object instanceof Boolean) ||
(object instanceof Double) ||
(object instanceof Float) ||
(object instanceof Integer) ||
(object instanceof Long)) {
return object;
}
if (object instanceof SharePhoto) {
if (photoJSONProcessor != null) {
return photoJSONProcessor.toJSONObject((SharePhoto) object);
}
return null;
}
if (object instanceof ShareOpenGraphObject) {
return toJSONObject((ShareOpenGraphObject) object, photoJSONProcessor);
}
if (object instanceof List) {
return toJSONArray((List) object, photoJSONProcessor);
}
throw new IllegalArgumentException(
"Invalid object found for JSON serialization: " +object.toString());
}
示例8: validatePhotoForNativeDialog
import com.facebook.share.model.SharePhoto; //导入依赖的package包/类
private static void validatePhotoForNativeDialog(SharePhoto photo, Validator validator) {
validatePhotoForApi(photo, validator);
if (photo.getBitmap() != null || !Utility.isWebUri(photo.getImageUrl())) {
Validate.hasContentProvider(FacebookSdk.getApplicationContext());
}
}
示例9: validatePhotoForWebDialog
import com.facebook.share.model.SharePhoto; //导入依赖的package包/类
private static void validatePhotoForWebDialog(SharePhoto photo, Validator validator) {
if (photo == null) {
throw new FacebookException("Cannot share a null SharePhoto");
}
Uri imageUri = photo.getImageUrl();
if (imageUri == null || !Utility.isWebUri(imageUri)) {
throw new FacebookException(
"SharePhoto must have a non-null imageUrl set to the Uri of an image " +
"on the web");
}
}
示例10: validateVideoContent
import com.facebook.share.model.SharePhoto; //导入依赖的package包/类
private static void validateVideoContent(
ShareVideoContent videoContent, Validator validator) {
validator.validate(videoContent.getVideo());
SharePhoto previewPhoto = videoContent.getPreviewPhoto();
if (previewPhoto != null) {
validator.validate(previewPhoto);
}
}
示例11: validateOpenGraphValueContainerObject
import com.facebook.share.model.SharePhoto; //导入依赖的package包/类
private static void validateOpenGraphValueContainerObject(
Object o, Validator validator) {
if (o instanceof ShareOpenGraphObject) {
validator.validate((ShareOpenGraphObject) o);
} else if (o instanceof SharePhoto) {
validator.validate((SharePhoto) o);
}
}
示例12: shareImage
import com.facebook.share.model.SharePhoto; //导入依赖的package包/类
public void shareImage(ArrayList<String> cards){
try {
List<SharePhoto> convertCards = new ArrayList<SharePhoto>();
SharePhoto photo;
for (int i = 0; i < cards.size(); i++) {
Uri uri = Uri.fromFile(new File(cards.get(i)));
Bitmap bitmap = MediaStore.Images.Media.getBitmap(this.getContentResolver(), uri);
int nh = (int) (bitmap.getHeight() * (1024.0 / bitmap.getWidth()));
Bitmap scaled = Bitmap.createScaledBitmap(bitmap, 1024, nh, true);
photo = new SharePhoto.Builder()
.setBitmap(scaled)
.build();
convertCards.add(photo);
}
ShareContent content = new SharePhotoContent.Builder().addPhotos(convertCards).build();
if(ShareDialog.canShow(SharePhotoContent.class)){
shareDialog.show(content);
}
} catch (Exception e) {
e.printStackTrace();
}
}
示例13: getFacebookShareContent
import com.facebook.share.model.SharePhoto; //导入依赖的package包/类
private ShareContent getFacebookShareContent(@NonNull PlaceCheckin theCheckin, @NonNull Place place, String applink) {
ShareOpenGraphObject.Builder objectBuilder = new ShareOpenGraphObject.Builder()
.putString("og:type", "fitness.course")
.putString("og:url", applink)
.putString("og:title", getContext().getString(R.string.share_title, place.getName()));
if (place.getDescription() != null) {
objectBuilder.putString("og:description", place.getDescription());
}
if (place.hasLocation()) {
objectBuilder.putDouble("fitness:metrics:location:latitude", place.getLocation().getLatitude());
objectBuilder.putDouble("fitness:metrics:location:longitude", place.getLocation().getLongitude());
}
// Create an action
ShareOpenGraphAction.Builder actionBuilder = new ShareOpenGraphAction.Builder()
.setActionType("fitness.walks")
.putObject("fitness:course", objectBuilder.build());
if (theCheckin.getImageUrl(SHARE_IMAGE_WIDTH) != null) {
SharePhoto photo = new SharePhoto.Builder()
.setImageUrl(Uri.parse(theCheckin.getImageUrl(SHARE_IMAGE_WIDTH)))
.setUserGenerated(true)
.build();
ArrayList<SharePhoto> photoArray = new ArrayList<>();
photoArray.add(photo);
actionBuilder.putPhotoArrayList("image", photoArray);
}
return new ShareOpenGraphContent.Builder()
.setPreviewPropertyName("fitness:course")
.setAction(actionBuilder.build())
.build();
}
示例14: share
import com.facebook.share.model.SharePhoto; //导入依赖的package包/类
@OnClick(R.id.button_social)
public void share(final View view) {
if (editing) {
setTextAndHideKeyboard(view);
} else {
AlertDialog.Builder builder = new AlertDialog.Builder(context)
.setTitle("Share with:")
.setItems(MainActivity.SOCIAL_MEDIA_PLATFORMS, new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
switch (which) {
case 0:
makeSnackbar(view, "Selected " + MainActivity.SOCIAL_MEDIA_PLATFORMS[0]);
Bitmap crop = ((BitmapDrawable) imageView.getDrawable()).getBitmap();
Bitmap preview = ((BitmapDrawable) previewImage.getDrawable()).getBitmap();
SharePhoto cropPhoto = new SharePhoto.Builder()
.setBitmap(crop)
.build();
SharePhoto previewPhoto = new SharePhoto.Builder()
.setBitmap(preview)
.build();
ShareContent shareContent = new ShareMediaContent.Builder()
.addMedium(cropPhoto)
.addMedium(previewPhoto)
.build();
ShareDialog shareDialog = new ShareDialog((Activity) context);
shareDialog.show(shareContent, ShareDialog.Mode.AUTOMATIC);
break;
}
}
});
builder.show();
}
}
示例15: publishImage
import com.facebook.share.model.SharePhoto; //导入依赖的package包/类
private void publishImage(Bitmap img) {
SharePhoto photo = new SharePhoto.Builder()
.setBitmap(img)
.build();
SharePhotoContent content = new SharePhotoContent.Builder()
.addPhoto(photo)
.build();
Log.e("abc", content.toString());
shareDialog.show(content);
}