本文整理汇总了Java中com.facebook.share.model.SharePhotoContent类的典型用法代码示例。如果您正苦于以下问题:Java SharePhotoContent类的具体用法?Java SharePhotoContent怎么用?Java SharePhotoContent使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
SharePhotoContent类属于com.facebook.share.model包,在下文中一共展示了SharePhotoContent类的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: validate
import com.facebook.share.model.SharePhotoContent; //导入依赖的package包/类
private static void validate(ShareContent content, Validator validator)
throws FacebookException {
if (content == null) {
throw new FacebookException("Must provide non-null content to share");
}
if (content instanceof ShareLinkContent) {
validator.validate((ShareLinkContent) content);
} else if (content instanceof SharePhotoContent) {
validator.validate((SharePhotoContent) content);
} else if (content instanceof ShareVideoContent) {
validator.validate((ShareVideoContent) content);
} else if (content instanceof ShareOpenGraphContent) {
validator.validate((ShareOpenGraphContent) content);
}
}
示例2: validatePhotoContent
import com.facebook.share.model.SharePhotoContent; //导入依赖的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);
}
}
示例3: openFbDialog
import com.facebook.share.model.SharePhotoContent; //导入依赖的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);
}
}
示例4: onCreate
import com.facebook.share.model.SharePhotoContent; //导入依赖的package包/类
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
FacebookSdk.sdkInitialize(this.getApplicationContext());
callbackManager = CallbackManager.Factory.create();
shareDialog = new ShareDialog(this);
shareDialog.registerCallback(
callbackManager,
shareCallback);
// Can we present the share dialog for regular links?
canPresentShareDialog = ShareDialog.canShow(
ShareLinkContent.class);
// Can we present the share dialog for photos?
canPresentShareDialogWithPhotos = ShareDialog.canShow(
SharePhotoContent.class);
}
示例5: create
import com.facebook.share.model.SharePhotoContent; //导入依赖的package包/类
public static Bundle create(
UUID callId,
ShareContent shareContent,
boolean shouldFailOnDataError) {
Validate.notNull(shareContent, "shareContent");
Validate.notNull(callId, "callId");
Bundle nativeParams = null;
if (shareContent instanceof ShareLinkContent) {
final ShareLinkContent linkContent = (ShareLinkContent) shareContent;
nativeParams = create(linkContent, shouldFailOnDataError);
} else if (shareContent instanceof SharePhotoContent) {
final SharePhotoContent photoContent = (SharePhotoContent) shareContent;
List<String> photoUrls = ShareInternalUtility.getPhotoUrls(
photoContent,
callId);
nativeParams = create(photoContent, photoUrls, shouldFailOnDataError);
} else if (shareContent instanceof ShareVideoContent) {
final ShareVideoContent videoContent = (ShareVideoContent) shareContent;
String videoUrl = ShareInternalUtility.getVideoUrl(videoContent, callId);
nativeParams = create(videoContent, videoUrl, shouldFailOnDataError);
} else if (shareContent instanceof ShareOpenGraphContent) {
final ShareOpenGraphContent openGraphContent = (ShareOpenGraphContent) shareContent;
try {
JSONObject openGraphActionJSON = ShareInternalUtility.toJSONObjectForCall(
callId, openGraphContent);
openGraphActionJSON = ShareInternalUtility.removeNamespacesFromOGJsonObject(
openGraphActionJSON, false);
nativeParams = create(openGraphContent, openGraphActionJSON, shouldFailOnDataError);
} catch (final JSONException e) {
throw new FacebookException(
"Unable to create a JSON Object from the provided ShareOpenGraphContent: "
+ e.getMessage());
}
}
return nativeParams;
}
示例6: create
import com.facebook.share.model.SharePhotoContent; //导入依赖的package包/类
public static Bundle create(
UUID callId,
ShareContent shareContent,
boolean shouldFailOnDataError) {
Validate.notNull(shareContent, "shareContent");
Validate.notNull(callId, "callId");
Bundle nativeParams = null;
if (shareContent instanceof ShareLinkContent) {
final ShareLinkContent linkContent = (ShareLinkContent)shareContent;
nativeParams = create(linkContent, shouldFailOnDataError);
} else if (shareContent instanceof SharePhotoContent) {
final SharePhotoContent photoContent = (SharePhotoContent)shareContent;
List<String> photoUrls = ShareInternalUtility.getPhotoUrls(
photoContent,
callId);
nativeParams = create(photoContent, photoUrls, shouldFailOnDataError);
} else if (shareContent instanceof ShareVideoContent) {
final ShareVideoContent videoContent = (ShareVideoContent)shareContent;
nativeParams = create(videoContent, shouldFailOnDataError);
} else if (shareContent instanceof ShareOpenGraphContent) {
final ShareOpenGraphContent openGraphContent = (ShareOpenGraphContent) shareContent;
try {
JSONObject openGraphActionJSON = ShareInternalUtility.toJSONObjectForCall(
callId, openGraphContent);
nativeParams = create(openGraphContent, openGraphActionJSON, shouldFailOnDataError);
} catch (final JSONException e) {
throw new FacebookException(
"Unable to create a JSON Object from the provided ShareOpenGraphContent: "
+ e.getMessage());
}
}
return nativeParams;
}
示例7: shareImage
import com.facebook.share.model.SharePhotoContent; //导入依赖的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();
}
}
示例8: publishImage
import com.facebook.share.model.SharePhotoContent; //导入依赖的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);
}
示例9: sharePhoto
import com.facebook.share.model.SharePhotoContent; //导入依赖的package包/类
/**
* share bitmap content.
* @param bitmap
*/
public void sharePhoto(Bitmap bitmap) {
SharePhoto photo = new SharePhoto.Builder()
.setBitmap(bitmap)
.build();
SharePhotoContent photoContent = new SharePhotoContent.Builder().addPhoto(photo).build();
ShareDialog shareDialog = new ShareDialog(activity);
if (ShareDialog.canShow(SharePhotoContent.class)) {
shareDialog.show(photoContent);
}
}
示例10: create
import com.facebook.share.model.SharePhotoContent; //导入依赖的package包/类
public static Bundle create(
UUID callId,
ShareContent shareContent,
boolean shouldFailOnDataError) {
Validate.notNull(shareContent, "shareContent");
Validate.notNull(callId, "callId");
Bundle nativeParams = null;
if (shareContent instanceof ShareLinkContent) {
final ShareLinkContent linkContent = (ShareLinkContent) shareContent;
nativeParams = create(linkContent, shouldFailOnDataError);
} else if (shareContent instanceof SharePhotoContent) {
final SharePhotoContent photoContent = (SharePhotoContent) shareContent;
List<String> photoUrls = ShareInternalUtility.getPhotoUrls(
photoContent,
callId);
nativeParams = create(photoContent, photoUrls, shouldFailOnDataError);
} else if (shareContent instanceof ShareVideoContent) {
final ShareVideoContent videoContent = (ShareVideoContent) shareContent;
nativeParams = create(videoContent, shouldFailOnDataError);
} else if (shareContent instanceof ShareOpenGraphContent) {
final ShareOpenGraphContent openGraphContent = (ShareOpenGraphContent) shareContent;
final ShareOpenGraphAction action = openGraphContent.getAction();
try {
JSONObject openGraphActionJSON = ShareInternalUtility.toJSONObjectForCall(
callId, action);
openGraphActionJSON = ShareInternalUtility.removeNamespacesFromOGJsonObject(
openGraphActionJSON, false);
nativeParams = create(openGraphContent, openGraphActionJSON, shouldFailOnDataError);
} catch (final JSONException e) {
throw new FacebookException(
"Unable to create a JSON Object from the provided ShareOpenGraphContent: "
+ e.getMessage());
}
}
return nativeParams;
}
示例11: create
import com.facebook.share.model.SharePhotoContent; //导入依赖的package包/类
public static Bundle create(
UUID callId,
ShareContent shareContent,
boolean shouldFailOnDataError) {
Validate.notNull(shareContent, "shareContent");
Validate.notNull(callId, "callId");
Bundle nativeParams = null;
if (shareContent instanceof ShareLinkContent) {
final ShareLinkContent linkContent = (ShareLinkContent)shareContent;
nativeParams = create(linkContent, shouldFailOnDataError);
} else if (shareContent instanceof SharePhotoContent) {
final SharePhotoContent photoContent = (SharePhotoContent)shareContent;
List<String> photoUrls = ShareInternalUtility.getPhotoUrls(
photoContent,
callId);
nativeParams = create(photoContent, photoUrls, shouldFailOnDataError);
} else if (shareContent instanceof ShareVideoContent) {
final ShareVideoContent videoContent = (ShareVideoContent)shareContent;
nativeParams = create(videoContent, shouldFailOnDataError);
} else if (shareContent instanceof ShareOpenGraphContent) {
final ShareOpenGraphContent openGraphContent = (ShareOpenGraphContent) shareContent;
final ShareOpenGraphAction action = openGraphContent.getAction();
try {
JSONObject openGraphActionJSON = ShareInternalUtility.toJSONObjectForCall(
callId, action);
nativeParams = create(openGraphContent, openGraphActionJSON, shouldFailOnDataError);
} catch (final JSONException e) {
throw new FacebookException(
"Unable to create a JSON Object from the provided ShareOpenGraphContent: "
+ e.getMessage());
}
}
return nativeParams;
}
示例12: SharePhoto
import com.facebook.share.model.SharePhotoContent; //导入依赖的package包/类
@Override
public void SharePhoto(SharePhotoContent sharePhotoContent) {
if (canPresentShareDialogWithPhotos) {
shareDialog.show(sharePhotoContent);
} else if (hasPublishPermission()) {
ShareApi.share(sharePhotoContent, shareCallback);
} else {
LoginManager.getInstance().logInWithPublishPermissions(
this,
Arrays.asList(Permission.PUBLISH_ACTION.getValue()));
}
}
示例13: shareImageOnFace
import com.facebook.share.model.SharePhotoContent; //导入依赖的package包/类
/**
* Handle Facebook
*/
public static void shareImageOnFace(Activity activity, RelativeLayout photoContent, View v) {
// Cria conteudo para ser publicado no face
SharePhoto photo = new SharePhoto.Builder().setBitmap(ImageUtil.drawBitmap(photoContent)).build();
SharePhotoContent content = new SharePhotoContent.Builder()
.addPhoto(photo)
.setShareHashtag(new ShareHashtag.Builder().setHashtag(HASHTAG).build())
.build();
new ShareDialog(activity).show(content);
}
示例14: SharePhoto
import com.facebook.share.model.SharePhotoContent; //导入依赖的package包/类
void SharePhoto(SharePhotoContent sharePhotoContent);