use of com.facebook.share.model.ShareOpenGraphContent in project facebook-android-sdk by facebook.
the class ShareContentValidationTest method testItValidatesShareOpenGraphWithNoActionByMessage.
// -ShareOpenGraphContent
@Test(expected = FacebookException.class)
public void testItValidatesShareOpenGraphWithNoActionByMessage() {
ShareOpenGraphContent shareOpenGraphContent = new ShareOpenGraphContent.Builder().setAction(null).build();
ShareContentValidation.validateForMessage(shareOpenGraphContent);
}
use of com.facebook.share.model.ShareOpenGraphContent in project facebook-android-sdk by facebook.
the class DeviceShareDialog method showImpl.
@Override
protected void showImpl(final ShareContent content, final Object mode) {
if (content == null) {
throw new FacebookException("Must provide non-null content to share");
}
if (!(content instanceof ShareLinkContent) && !(content instanceof ShareOpenGraphContent)) {
throw new FacebookException(this.getClass().getSimpleName() + " only supports ShareLinkContent or ShareOpenGraphContent");
}
Intent intent = new Intent();
intent.setClass(FacebookSdk.getApplicationContext(), FacebookActivity.class);
intent.setAction(DeviceShareDialogFragment.TAG);
intent.putExtra("content", content);
startActivityForResult(intent, getRequestCode());
}
use of com.facebook.share.model.ShareOpenGraphContent 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.ShareOpenGraphContent 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();
}
use of com.facebook.share.model.ShareOpenGraphContent in project facebook-android-sdk by facebook.
the class ShareContentValidationTest method testItValidatesShareOpenGraphWithPreviewPropertyNameByMessage.
@Test(expected = FacebookException.class)
public void testItValidatesShareOpenGraphWithPreviewPropertyNameByMessage() {
ShareOpenGraphAction shareOpenGraphAction = new ShareOpenGraphAction.Builder().setActionType("foo").build();
ShareOpenGraphContent shareOpenGraphContent = new ShareOpenGraphContent.Builder().setAction(shareOpenGraphAction).build();
ShareContentValidation.validateForMessage(shareOpenGraphContent);
}
Aggregations