本文整理汇总了Java中com.facebook.share.model.ShareContent类的典型用法代码示例。如果您正苦于以下问题:Java ShareContent类的具体用法?Java ShareContent怎么用?Java ShareContent使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
ShareContent类属于com.facebook.share.model包,在下文中一共展示了ShareContent类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: createBaseParameters
import com.facebook.share.model.ShareContent; //导入依赖的package包/类
private static Bundle createBaseParameters(ShareContent content, boolean dataErrorsFatal) {
Bundle params = new Bundle();
Utility.putUri(params, ShareConstants.CONTENT_URL, content.getContentUrl());
Utility.putNonEmptyString(params, ShareConstants.PLACE_ID, content.getPlaceId());
Utility.putNonEmptyString(params, ShareConstants.REF, content.getRef());
params.putBoolean(ShareConstants.DATA_FAILURES_FATAL, dataErrorsFatal);
List<String> peopleIds = content.getPeopleIds();
if (!Utility.isNullOrEmpty(peopleIds)) {
params.putStringArrayList(
ShareConstants.PEOPLE_IDS,
new ArrayList<String>(peopleIds));
}
return params;
}
开发者ID:eviltnan,项目名称:kognitivo,代码行数:19,代码来源:NativeDialogParameters.java
示例2: validate
import com.facebook.share.model.ShareContent; //导入依赖的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);
}
}
开发者ID:eviltnan,项目名称:kognitivo,代码行数:17,代码来源:ShareContentValidation.java
示例3: createBaseParameters
import com.facebook.share.model.ShareContent; //导入依赖的package包/类
private static Bundle createBaseParameters(ShareContent content, boolean dataErrorsFatal) {
Bundle params = new Bundle();
Utility.putUri(params, ShareConstants.LEGACY_LINK, content.getContentUrl());
Utility.putNonEmptyString(params, ShareConstants.LEGACY_PLACE_TAG, content.getPlaceId());
Utility.putNonEmptyString(params, ShareConstants.LEGACY_REF, content.getRef());
params.putBoolean(ShareConstants.LEGACY_DATA_FAILURES_FATAL, dataErrorsFatal);
List<String> peopleIds = content.getPeopleIds();
if (!Utility.isNullOrEmpty(peopleIds)) {
params.putStringArrayList(
ShareConstants.LEGACY_FRIEND_TAGS,
new ArrayList<>(peopleIds));
}
return params;
}
开发者ID:eviltnan,项目名称:kognitivo,代码行数:19,代码来源:LegacyNativeDialogParameters.java
示例4: create
import com.facebook.share.model.ShareContent; //导入依赖的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;
}
开发者ID:eviltnan,项目名称:kognitivo,代码行数:41,代码来源:NativeDialogParameters.java
示例5: create
import com.facebook.share.model.ShareContent; //导入依赖的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;
}
开发者ID:eviltnan,项目名称:kognitivo,代码行数:38,代码来源:LegacyNativeDialogParameters.java
示例6: getDialog
import com.facebook.share.model.ShareContent; //导入依赖的package包/类
@Override
protected FacebookDialogBase<ShareContent, Sharer.Result> getDialog() {
final ShareDialog dialog;
if (ShareButton.this.getFragment() != null) {
dialog = new ShareDialog(ShareButton.this.getFragment() , getRequestCode());
} else {
dialog = new ShareDialog(getActivity(), getRequestCode());
}
return dialog;
}
开发者ID:eviltnan,项目名称:kognitivo,代码行数:11,代码来源:ShareButton.java
示例7: setShareContent
import com.facebook.share.model.ShareContent; //导入依赖的package包/类
/**
* Sets the share content on the button.
* @param shareContent The share content.
*/
public void setShareContent(final ShareContent shareContent) {
this.shareContent = shareContent;
if (!enabledExplicitlySet) {
internalSetEnabled(canShare());
}
}
开发者ID:eviltnan,项目名称:kognitivo,代码行数:11,代码来源:ShareButtonBase.java
示例8: getDialog
import com.facebook.share.model.ShareContent; //导入依赖的package包/类
@Override
protected FacebookDialogBase<ShareContent, Sharer.Result> getDialog() {
final MessageDialog dialog;
if (SendButton.this.getFragment() != null) {
dialog = new MessageDialog(SendButton.this.getFragment() , getRequestCode());
} else {
dialog = new MessageDialog(getActivity(), getRequestCode());
}
return dialog;
}
开发者ID:eviltnan,项目名称:kognitivo,代码行数:11,代码来源:SendButton.java
示例9: testFBShareBind_shareContentSet
import com.facebook.share.model.ShareContent; //导入依赖的package包/类
@Test
public void testFBShareBind_shareContentSet() throws Exception {
int positionToShow = 0;
when(recipeList.get(positionToShow)).thenReturn(recipe);
shadowAdapter.itemVisible(positionToShow);
View view = shadowAdapter.getViewForHolderPosition(positionToShow);
ShareButton fbShare = (ShareButton) view.findViewById(R.id.fbShare);
ShareContent shareContent = fbShare.getShareContent();
assertNotNull(shareContent);
assertEquals(URL, shareContent.getContentUrl().toString());
}
开发者ID:micromasterandroid,项目名称:androidadvanced,代码行数:14,代码来源:RecipesAdapterTest.java
示例10: testFBSendBind_shareContentSet
import com.facebook.share.model.ShareContent; //导入依赖的package包/类
@Test
public void testFBSendBind_shareContentSet() throws Exception {
int positionToShow = 0;
when(recipeList.get(positionToShow)).thenReturn(recipe);
shadowAdapter.itemVisible(positionToShow);
View view = shadowAdapter.getViewForHolderPosition(positionToShow);
SendButton fbSend = (SendButton) view.findViewById(R.id.fbSend);
ShareContent shareContent = fbSend.getShareContent();
assertNotNull(shareContent);
assertEquals(URL, shareContent.getContentUrl().toString());
}
开发者ID:micromasterandroid,项目名称:androidadvanced,代码行数:14,代码来源:RecipesAdapterTest.java
示例11: shareImage
import com.facebook.share.model.ShareContent; //导入依赖的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();
}
}
开发者ID:gugusny5758,项目名称:OSS-green-07,代码行数:28,代码来源:HomeActivity.java
示例12: getFacebookShareContent
import com.facebook.share.model.ShareContent; //导入依赖的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();
}
开发者ID:Turistforeningen,项目名称:SjekkUT,代码行数:35,代码来源:CheckinAndSocialView.java
示例13: share
import com.facebook.share.model.ShareContent; //导入依赖的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();
}
}
开发者ID:IgorGee,项目名称:Carbonizr,代码行数:36,代码来源:CustomAdapter.java
示例14: create
import com.facebook.share.model.ShareContent; //导入依赖的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;
}
开发者ID:CE-KMITL-OOAD-2015,项目名称:Move-Alarm_ORCA,代码行数:40,代码来源:NativeDialogParameters.java
示例15: create
import com.facebook.share.model.ShareContent; //导入依赖的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;
}
开发者ID:CE-KMITL-OOAD-2015,项目名称:Move-Alarm_ORCA,代码行数:39,代码来源:LegacyNativeDialogParameters.java
示例16: validateForMessage
import com.facebook.share.model.ShareContent; //导入依赖的package包/类
public static void validateForMessage(ShareContent content) {
validate(content, getDefaultValidator());
}
开发者ID:eviltnan,项目名称:kognitivo,代码行数:4,代码来源:ShareContentValidation.java
示例17: validateForNativeShare
import com.facebook.share.model.ShareContent; //导入依赖的package包/类
public static void validateForNativeShare(ShareContent content) {
validate(content, getDefaultValidator());
}
开发者ID:eviltnan,项目名称:kognitivo,代码行数:4,代码来源:ShareContentValidation.java
示例18: validateForWebShare
import com.facebook.share.model.ShareContent; //导入依赖的package包/类
public static void validateForWebShare(ShareContent content) {
validate(content, getWebShareValidator());
}
开发者ID:eviltnan,项目名称:kognitivo,代码行数:4,代码来源:ShareContentValidation.java
示例19: validateForApiShare
import com.facebook.share.model.ShareContent; //导入依赖的package包/类
public static void validateForApiShare(ShareContent content) {
validate(content, getApiValidator());
}
开发者ID:eviltnan,项目名称:kognitivo,代码行数:4,代码来源:ShareContentValidation.java
示例20: updateView
import com.facebook.share.model.ShareContent; //导入依赖的package包/类
private void updateView() {
if (!mAttached)
return;
Context context = getContext();
boolean userCanCheckin = CheckinRules.canCheckin(mPlace, mUserStats, mCheckinRules, mLocation);
PlaceCheckin latestCheckin = (mPlace != null && mUserStats != null) ? mUserStats.getLatestCheckin(mPlace.getId()) : null;
boolean userAlreadyVisited = latestCheckin != null;
boolean latestCheckinIsPublic = latestCheckin != null && latestCheckin.isPublicCheckin();
boolean latestCheckinIsOld = latestCheckin != null && !latestCheckin.isFresherThan(SIX_HOURS_MS);
String selfieUrl = latestCheckin != null ? latestCheckin.getImageUrl((int) (Utils.getDisplayWidth(context) * 0.2)) : null;
boolean userOnline = Utils.isConnected(context);
boolean showVisitContainer = userCanCheckin || !userAlreadyVisited;
// update visit container
mVisitContainer.setVisibility(showVisitContainer ? View.VISIBLE : View.GONE);
String visitText;
int visitButtonColor = ContextCompat.getColor(context, R.color.subtitleColor);
int visitWithSelfieButtonColor = ContextCompat.getColor(context, R.color.subtitleColor);
if (userCanCheckin) {
visitText = context.getString(R.string.visit_possible);
visitButtonColor = ContextCompat.getColor(context, R.color.accentColor);
if (userOnline) {
visitWithSelfieButtonColor = ContextCompat.getColor(context, R.color.accentColor);
}
} else if (mPlace != null && mPlace.hasLocation() && mLocation != null) {
visitText = context.getString(R.string.visit_impossible_distance, Utils.formatDistance(context, mPlace.getDistanceTo(mLocation)));
} else {
visitText = context.getString(R.string.visit_impossible_location);
}
mVisitText.setText(visitText);
mVisitButton.setTextColor(visitButtonColor);
mVisitButton.setTag(R.id.USER_CHECKIN_OK, userCanCheckin);
mVisitWithSelfieButton.setTextColor(visitWithSelfieButtonColor);
mVisitWithSelfieButton.setTag(R.id.USER_CHECKIN_OK, userCanCheckin);
// update share container
mShareContainer.setVisibility(!showVisitContainer ? View.VISIBLE : View.GONE);
int shareSignButtonColor = ContextCompat.getColor(context, userOnline ? R.color.accentColor : R.color.subtitleColor);
mSignButton.setText(latestCheckinIsPublic || latestCheckinIsOld ? R.string.read_guestbook : R.string.sign_guestbook);
mSignButton.setTextColor(shareSignButtonColor);
String shareText = "";
ShareContent shareContent = null;
if (mPlace != null && latestCheckin != null) {
String timeSpan = Utils.getTimeSpanFromNow(latestCheckin.getTimestamp(), getContext().getString(R.string.just_now));
if (latestCheckinIsOld) {
shareText = context.getString(R.string.you_visited_place_at, mPlace.getName(), timeSpan);
} else if (userOnline) {
shareText = context.getString(R.string.you_visited_place_at_congrats, mPlace.getName(), timeSpan);
} else {
shareText = context.getString(R.string.you_visited_place_at_congrats_offline, mPlace.getName(), timeSpan);
}
if (mAppLink != null && userOnline) {
shareContent = getFacebookShareContent(latestCheckin, mPlace, mAppLink);
}
}
mShareText.setText(shareText);
mShareButton.setTextColor(shareSignButtonColor);
mShareButton.setCompoundDrawablesWithIntrinsicBounds(userOnline ? mShareActive : mShareInactive, null, null, null);
mShareFacebookButton.setTextColor(shareSignButtonColor);
mShareFacebookButton.setCompoundDrawablesWithIntrinsicBounds(userOnline ? mFacebookActive : mFacebookInactive, null, null, null);
mShareFacebookButton.setShareContent(shareContent);
mShareFacebookButton.setEnabled(true);
Picasso.with(context)
.load(selfieUrl)
.placeholder(userOnline && !latestCheckinIsOld ? mCameraActive : mCameraInactive)
.error(userOnline && !latestCheckinIsOld ? mCameraActive : mCameraInactive)
.fit()
.into(mSelfieButton);
}
开发者ID:Turistforeningen,项目名称:SjekkUT,代码行数:71,代码来源:CheckinAndSocialView.java
注:本文中的com.facebook.share.model.ShareContent类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论