use of com.facebook.share.model.SharePhoto in project facebook-android-sdk by facebook.
the class ShareContentValidationTest method testItValidatesNullImageForSharePhotoContentByApi.
@Test(expected = FacebookException.class)
public void testItValidatesNullImageForSharePhotoContentByApi() {
SharePhotoContent.Builder spcBuilder = new SharePhotoContent.Builder();
SharePhoto sharePhoto = new SharePhoto.Builder().setImageUrl(null).build();
SharePhotoContent sharePhotoContent = spcBuilder.addPhoto(sharePhoto).build();
ShareContentValidation.validateForApiShare(sharePhotoContent);
}
use of com.facebook.share.model.SharePhoto in project facebook-android-sdk by facebook.
the class RpsFragment method getThrowAction.
private ShareOpenGraphAction getThrowAction() {
// The OG objects have their own bitmaps we could rely on, but in order to demonstrate
// attaching an in-memory bitmap (e.g., a game screencap) we'll send the bitmap explicitly
// ourselves.
ImageButton view = gestureImages[playerChoice];
BitmapDrawable drawable = (BitmapDrawable) view.getBackground();
final Bitmap bitmap = drawable.getBitmap();
return new ShareOpenGraphAction.Builder().setActionType(OpenGraphConsts.THROW_ACTION_TYPE).putString("fb_sample_rps:gesture", getBuiltInGesture(playerChoice)).putString("fb_sample_rps:opposing_gesture", getBuiltInGesture(computerChoice)).putPhotoArrayList("og:image", new ArrayList<SharePhoto>() {
{
add(new SharePhoto.Builder().setBitmap(bitmap).build());
}
}).build();
}
use of com.facebook.share.model.SharePhoto in project facebook-android-sdk by facebook.
the class ShareInternalUtility method getAttachment.
private static NativeAppCallAttachmentStore.Attachment getAttachment(UUID callId, ShareMedia medium) {
Bitmap bitmap = null;
Uri uri = null;
if (medium instanceof SharePhoto) {
SharePhoto photo = (SharePhoto) medium;
bitmap = photo.getBitmap();
uri = photo.getImageUrl();
} else if (medium instanceof ShareVideo) {
ShareVideo video = (ShareVideo) medium;
uri = video.getLocalUrl();
}
NativeAppCallAttachmentStore.Attachment attachment = null;
if (bitmap != null) {
attachment = NativeAppCallAttachmentStore.createAttachment(callId, bitmap);
} else if (uri != null) {
attachment = NativeAppCallAttachmentStore.createAttachment(callId, uri);
}
return attachment;
}
use of com.facebook.share.model.SharePhoto in project facebook-android-sdk by facebook.
the class RpsFragment method publishResult.
private void publishResult() {
if (shouldImplicitlyPublish && canPublish()) {
String photoUri = PHOTO_URIS[playerChoice];
SharePhoto.Builder sharePhotoBuilder = new SharePhoto.Builder();
if (photoUri == null) {
Bitmap bitmap = BitmapFactory.decodeResource(getResources(), DRAWABLES_HUMAN[playerChoice]);
sharePhotoBuilder.setBitmap(bitmap);
} else {
sharePhotoBuilder.setImageUrl(Uri.parse(photoUri));
}
sharePhotoBuilder.setUserGenerated(false);
final SharePhoto gesturePhoto = sharePhotoBuilder.build();
ShareOpenGraphObject gameObject = createGameObject(gesturePhoto);
ShareOpenGraphAction playAction = createPlayActionWithGame(gameObject);
ShareOpenGraphContent content = new ShareOpenGraphContent.Builder().setAction(playAction).setPreviewPropertyName("game").build();
ShareApi.share(content, new FacebookCallback<Sharer.Result>() {
@Override
public void onSuccess(Sharer.Result result) {
Log.i(TAG, "Posted OG Action with id: " + result.getPostId());
}
@Override
public void onCancel() {
// This should not happen
}
@Override
public void onError(FacebookException error) {
Log.e(TAG, "Play action creation failed: " + error.getMessage());
}
});
}
}
use of com.facebook.share.model.SharePhoto in project facebook-android-sdk by facebook.
the class SelectionFragment method createOpenGraphContent.
private ShareOpenGraphContent createOpenGraphContent() {
ShareOpenGraphAction.Builder actionBuilder = createEatActionBuilder();
boolean userGenerated = false;
if (photoUri != null) {
String photoUriString = photoUri.toString();
Pair<File, Integer> fileAndMinDimension = getImageFileAndMinDimension();
userGenerated = fileAndMinDimension.second >= USER_GENERATED_MIN_SIZE;
if (fileAndMinDimension != null) {
final SharePhoto actionPhoto = new SharePhoto.Builder().setImageUrl(Uri.parse(photoUriString)).setUserGenerated(userGenerated).build();
actionBuilder.putPhotoArrayList("image", new ArrayList<SharePhoto>() {
{
add(actionPhoto);
}
});
}
}
return new ShareOpenGraphContent.Builder().setAction(actionBuilder.build()).setPreviewPropertyName("meal").build();
}
Aggregations