Java 类com.facebook.share.model.ShareLinkContent 实例源码

项目:TFG    文件:PantallaVictoria.java   
/**
 * Metodo para compartir en Facebook
 * @param titulo Titulo de lo que se va a compartir
 * @param contenido Contenido que se comparte
 */
private void compartir(String titulo, String contenido){
    //Comprobamos si se puede mostrar el ShareDialog
    if (ShareDialog.canShow(ShareLinkContent.class)) {
        //Creamos el contenido
        ShareLinkContent linkContent = new ShareLinkContent.Builder()
                //Le asignamos el titulo
                .setContentTitle(titulo)
                //Le asignamos una imagen para mostrar que subimos a internete
                .setImageUrl(Uri.parse("http://s2.postimg.org/m7kf0y8zt/565px_Mastermind.jpg"))
                //Un enlace al que se accederia clickando en Facebook
                .setContentUrl(Uri.parse("https://play.google.com/store"))
                //Le asignamos el contenido que se quiere compartir
                .setContentDescription(contenido)
                //Lo construimos
                .build();
        //Mostramos la pantalla de compartir con lo creado anteriormente
        shareDialog.show(linkContent);
    }
}
项目:kognitivo    文件:WebDialogParameters.java   
public static Bundle createForFeed(ShareLinkContent shareLinkContent) {
    Bundle webParams = new Bundle();

    Utility.putNonEmptyString(
            webParams,
            ShareConstants.WEB_DIALOG_PARAM_NAME,
            shareLinkContent.getContentTitle());

    Utility.putNonEmptyString(
            webParams,
            ShareConstants.WEB_DIALOG_PARAM_DESCRIPTION,
            shareLinkContent.getContentDescription());

    Utility.putNonEmptyString(
            webParams,
            ShareConstants.WEB_DIALOG_PARAM_LINK,
            Utility.getUriString(shareLinkContent.getContentUrl()));

    Utility.putNonEmptyString(
            webParams,
            ShareConstants.WEB_DIALOG_PARAM_PICTURE,
            Utility.getUriString(shareLinkContent.getImageUrl()));

    return webParams;
}
项目:kognitivo    文件:ShareContentValidation.java   
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);
    }
}
项目:android-oss    文件:ThanksShareViewHolder.java   
private void startShareOnFacebook(final @NonNull Project project) {
  if (!ShareDialog.canShow(ShareLinkContent.class)) {
    return;
  }

  final Photo photo = project.photo();
  final ShareOpenGraphObject object = new ShareOpenGraphObject.Builder()
    .putString("og:type", "kickstarter:project")
    .putString("og:title", project.name())
    .putString("og:description", project.blurb())
    .putString("og:image", photo == null ? null : photo.small())
    .putString("og:url", project.webProjectUrl())
    .build();

  final ShareOpenGraphAction action = new ShareOpenGraphAction.Builder()
    .setActionType("kickstarter:back")
    .putObject("project", object)
    .build();

  final ShareOpenGraphContent content = new ShareOpenGraphContent.Builder()
    .setPreviewPropertyName("project")
    .setAction(action)
    .build();

  this.shareDialog.show(content);
}
项目:FindMeAHome    文件:ListActivity.java   
private void shareOnFacebook() {

        facebookCallbackManager = CallbackManager.Factory.create();
        ShareDialog shareDialog = new ShareDialog(this);

        if (ShareDialog.canShow(ShareLinkContent.class)) {
            ShareLinkContent linkContent = new ShareLinkContent.Builder()
                    .setShareHashtag(new ShareHashtag.Builder()
                                    .setHashtag(getString(R.string.nomorehomelessanimals)).build())
                    .setQuote(getString(R.string.explore_adoption))
                    .setContentUrl(Uri.parse(getString(R.string.findmeahome_store_url)))
                    .build();

            shareDialog.show(linkContent);
        }
    }
项目:bachamada    文件:FacebookShare.java   
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);
    }
}
项目:Move-Alarm_ORCA    文件:WebDialogParameters.java   
public static Bundle createForFeed(ShareLinkContent shareLinkContent) {
    Bundle webParams = new Bundle();

    Utility.putNonEmptyString(
            webParams,
            ShareConstants.WEB_DIALOG_PARAM_NAME,
            shareLinkContent.getContentTitle());

    Utility.putNonEmptyString(
            webParams,
            ShareConstants.WEB_DIALOG_PARAM_DESCRIPTION,
            shareLinkContent.getContentDescription());

    Utility.putNonEmptyString(
            webParams,
            ShareConstants.WEB_DIALOG_PARAM_LINK,
            Utility.getUriString(shareLinkContent.getContentUrl()));

    Utility.putNonEmptyString(
            webParams,
            ShareConstants.WEB_DIALOG_PARAM_PICTURE,
            Utility.getUriString(shareLinkContent.getImageUrl()));

    return webParams;
}
项目:Move-Alarm_ORCA    文件:ShareContentValidation.java   
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);
    }
}
项目:EasyFacebook    文件:BaseLoginActivity.java   
@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);
}
项目:SocioBlood    文件:WebDialogParameters.java   
public static Bundle createForFeed(ShareLinkContent shareLinkContent) {
    Bundle webParams = new Bundle();

    Utility.putNonEmptyString(
            webParams,
            ShareConstants.WEB_DIALOG_PARAM_NAME,
            shareLinkContent.getContentTitle());

    Utility.putNonEmptyString(
            webParams,
            ShareConstants.WEB_DIALOG_PARAM_DESCRIPTION,
            shareLinkContent.getContentDescription());

    Utility.putNonEmptyString(
            webParams,
            ShareConstants.WEB_DIALOG_PARAM_LINK,
            Utility.getUriString(shareLinkContent.getContentUrl()));

    Utility.putNonEmptyString(
            webParams,
            ShareConstants.WEB_DIALOG_PARAM_PICTURE,
            Utility.getUriString(shareLinkContent.getImageUrl()));

    return webParams;
}
项目:SocioBlood    文件:ShareContentValidation.java   
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);
    }
}
项目:kognitivo    文件:WebDialogParameters.java   
public static Bundle create(ShareLinkContent shareLinkContent) {
    Bundle params = new Bundle();
    Utility.putUri(
            params,
            ShareConstants.WEB_DIALOG_PARAM_HREF,
            shareLinkContent.getContentUrl());

    return params;
}
项目:kognitivo    文件:NativeDialogParameters.java   
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;
}
项目:kognitivo    文件:NativeDialogParameters.java   
private static Bundle create(ShareLinkContent linkContent, boolean dataErrorsFatal) {
    Bundle params = createBaseParameters(linkContent, dataErrorsFatal);

    Utility.putNonEmptyString(params, ShareConstants.TITLE, linkContent.getContentTitle());
    Utility.putNonEmptyString(
            params, ShareConstants.DESCRIPTION, linkContent.getContentDescription());
    Utility.putUri(params, ShareConstants.IMAGE_URL, linkContent.getImageUrl());

    return params;
}
项目:kognitivo    文件:ShareContentValidation.java   
private static void validateLinkContent(
        ShareLinkContent linkContent, Validator validator) {
    Uri imageUrl = linkContent.getImageUrl();
    if (imageUrl != null && !Utility.isWebUri(imageUrl)) {
        throw new FacebookException("Image Url must be an http:// or https:// url");
    }
}
项目:kognitivo    文件:LegacyNativeDialogParameters.java   
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;
}
项目:kognitivo    文件:LegacyNativeDialogParameters.java   
private static Bundle create(ShareLinkContent linkContent, boolean dataErrorsFatal) {
    Bundle params = createBaseParameters(linkContent, dataErrorsFatal);

    Utility.putNonEmptyString(
            params, ShareConstants.LEGACY_TITLE, linkContent.getContentTitle());
    Utility.putNonEmptyString(
            params, ShareConstants.LEGACY_DESCRIPTION, linkContent.getContentDescription());
    Utility.putUri(params, ShareConstants.LEGACY_IMAGE, linkContent.getImageUrl());

    return params;
}
项目:aftercare-app-android    文件:DCRoutineCompletedFragment.java   
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    final View view = inflater.inflate(R.layout.fragment_routine_completed, container);
    fbShare = (ShareButton) view.findViewById(R.id.fb_share);
    tvMessage = (DCTextView) view.findViewById(R.id.tv_message);
    tvCompleted = (DCTextView) view.findViewById(R.id.tv_completed);
    ivTooth = (ImageView) view.findViewById(R.id.iv_tooth);

    if (getArguments() != null) {
        final Routine.Type routineType = (Routine.Type)getArguments().getSerializable(KEY_ROUTINE_TYPE);

        if (routineType != null) {
            AudibleMessage audibleMessage;
            String shareLinkMessage;

            switch (routineType) {
                case MORNING:
                    shareLinkMessage = getString(R.string.fb_share_morning_routine_completed);
                    audibleMessage = AudibleMessage.MORNING_ROUTINE_END;
                    break;
                default:
                    shareLinkMessage = getString(R.string.fb_share_evening_routine_completed);
                    audibleMessage = AudibleMessage.EVENING_ROUTINE_END;
                    break;
            }

            tvMessage.setText(audibleMessage.getMessage(getActivity()));

            ShareLinkContent shareLinkContent = new ShareLinkContent.Builder()
                    .setContentUrl(Uri.parse(DCConstants.DENTACARE_GOOGLE_PLAY))
                    .setShareHashtag(new ShareHashtag.Builder()
                            .setHashtag("#dentacoin")
                            .build())
                    .setQuote(shareLinkMessage)
                    .build();

            fbShare.setShareContent(shareLinkContent);

            if (audibleMessage.getVoices() != null && audibleMessage.getVoices().length > 0) {
                DCSoundManager.getInstance().playVoice(getActivity(), audibleMessage.getVoices()[0]);
            }
        }
    }

    AlphaAnimation alphaAnimation = new AlphaAnimation(0f, 1f);
    alphaAnimation.setDuration(1000);
    ivTooth.startAnimation(alphaAnimation);

    AlphaAnimation dayAlphaAnimation = new AlphaAnimation(0f, 1f);
    dayAlphaAnimation.setDuration(2000);
    tvCompleted.startAnimation(dayAlphaAnimation);

    AlphaAnimation alphaAnimationMessage = new AlphaAnimation(0f, 1f);
    alphaAnimationMessage.setDuration(1000);
    tvMessage.startAnimation(alphaAnimationMessage);

    return view;
}
项目:Odyssey2017    文件:FeedAdapter.java   
@Override
public View getView(final int position, View convertView, ViewGroup parent) {
    final ViewHolder holder;
    if (convertView==null)
    {
        holder=new ViewHolder();
        ShareLinkContent content = new ShareLinkContent.Builder()
                .setContentUrl(Uri.parse(feeds.get(position).getImage_url()))
                .build();
        inflater=LayoutInflater.from(context);
        convertView= inflater.inflate(R.layout.activity_feeds_list, parent, false);
        holder.ivfeedimage= (ImageView) convertView.findViewById(R.id.iv_feed);
        holder.tvtitle= (TextView) convertView.findViewById(R.id.tv_feed_title);
        holder.tvmatter= (TextView) convertView.findViewById(R.id.tv_feed_matter);
        holder.tvdate= (TextView) convertView.findViewById(R.id.tv_date);
        convertView.setTag(holder);

    }
    else
    {
        holder= (ViewHolder) convertView.getTag();
    }
    try {
        holder.tvtitle.setText(feeds.get(position).getTitle());
        holder.tvtitle.setTypeface(typeface);
        holder.tvtitle.setTextColor(R.color.com_facebook_button_background_color);
        holder.tvmatter.setText(Html.fromHtml(feeds.get(position).getMatter()));
        holder.tvdate.setText("Posted at :"+feeds.get(position).getDate());

        Picasso.with(context).load(feeds.get(position).getImage_url()).fit().placeholder(R.drawable.placeholder).into( holder.ivfeedimage);

    }
    catch (Exception e){e.printStackTrace();}

    return convertView;
}
项目:AndroidBlueprints    文件:FacebookHelper.java   
/**
 * Share content on facebook wall
 *
 * @param activity the activity
 * @param callback the callback to receive a result of this share
 * @param url      the url you wish to share
 * @param quote    the text you wish to associate with the url shared
 */
private void shareLinkOnFacebook(@NonNull final Activity activity, @NonNull final FacebookShareResultCallback callback, @NonNull String url, @Nullable String quote) {
    ShareDialog shareDialog = new ShareDialog(activity);

    shareDialog.registerCallback(mCallbackManager, new FacebookCallback<Sharer.Result>() {
        @Override
        public void onSuccess(Sharer.Result result) {
            callback.onFacebookShareSuccess(result);
        }

        @Override
        public void onCancel() {
            callback.onFacebookShareCancel();
        }

        @Override
        public void onError(FacebookException error) {
            callback.onFacebookShareError(error);
        }
    }, RC_FACEBOOK_SHARE);


    if (ShareDialog.canShow(ShareLinkContent.class)) {
        ShareLinkContent linkContent = new ShareLinkContent.Builder().setContentUrl(Uri.parse(url))
                .setQuote(quote)
                .build();
        shareDialog.show(linkContent);
    } else {
        callback.onFacebookShareCannotShowDialog();
    }
}
项目:mobile-sdk-android-sample    文件:WelcomeActivity.java   
/**
 * This method creates a facebook share button
 *
 * @param shareButton button pressed for a facebook share button
 */
public void shareFacebook(View shareButton) {
    ShareLinkContent content = new ShareLinkContent.Builder()
            .setContentUrl(Uri.parse(mUser.shareLinks.get("facebook")))
            .setContentTitle("Get SaaS for 10% less!")
            .setContentDescription("Sign up for a SaaS account and we both get 10% off our SaaS!")
            .build();

    ShareDialog dialog = new ShareDialog(this);

    if (ShareDialog.canShow(ShareLinkContent.class)) {
        dialog.show(content);
    }
}
项目:eazysocial    文件:FacebookManager.java   
private void setUpShareConfig(String url, ShareDialog shareDialog) {
    if (ShareDialog.canShow(ShareLinkContent.class)) {
        ShareLinkContent shareLinkContent = new ShareLinkContent.Builder()
                .setContentUrl(Uri.parse(url))
                .build();
        shareDialog.registerCallback(callbackManager, new FacebookCallback<Sharer.Result>() {
            @Override
            public void onSuccess(Sharer.Result result) {
                if (onFacebookShareEvent != null) {
                    onFacebookShareEvent.onShareSuccessFacebook();
                }
            }

            @Override
            public void onCancel() {
                if (onFacebookShareEvent != null) {
                    onFacebookShareEvent.onShareCanceledFacebook();
                }
            }

            @Override
            public void onError(FacebookException error) {
                error.printStackTrace();
            }
        });
        shareDialog.show(shareLinkContent);

    }
}
项目:event-app    文件:ShareDrawer.java   
private static void shareOnFacebook(){
    ShareLinkContent content = new ShareLinkContent.Builder()
            .setContentTitle(mMediaContent.getTitle())
            .setContentDescription(mMediaContent.getDescription())
            .setContentUrl(Uri.parse(mMediaContent.getImageSrc()))
            .build();

    ShareDialog.show(mActivity, content);
}
项目:Reciclo    文件:Utils.java   
public static void reciclo(ShareDialog shareDialog){
    //TODO Get random phrases
    ShareLinkContent linkContent = new ShareLinkContent.Builder()
            .setContentTitle("Reciclô")
            .setContentDescription(
                    "Veja só o que acabei de fazer utilizando o Reciclô!")
            .setContentUrl(Uri.parse("http://developers.facebook.com/android"))
            .build();

    shareDialog.show(linkContent);
}
项目:android-fagyi    文件:FacebookHandler.java   
/**
 * Share ritch content on facebook.
 * @param activity              Application base context.
 * @param contentUrl            Redirect url.
 * @param contentTitle          Title of content.
 * @param imageUrl              url of content's image.
 * @param contentDescription    description of the content.
 */
public void shareLink(Activity activity, String contentUrl, String contentTitle, String imageUrl, String contentDescription) {
    ShareDialog shareDialog = new ShareDialog(activity);

    if (ShareDialog.canShow(ShareLinkContent.class)) {
        ShareLinkContent content = new ShareLinkContent.Builder()
                .setContentUrl(Uri.parse(contentUrl))
                .setContentTitle(contentTitle)
                .setContentDescription(contentDescription)
                .setImageUrl(Uri.parse(imageUrl)).build();

        shareDialog.show(content);
    }

}
项目:Move-Alarm_ORCA    文件:WebDialogParameters.java   
public static Bundle create(ShareLinkContent shareLinkContent) {
    Bundle params = new Bundle();
    Utility.putUri(
            params,
            ShareConstants.WEB_DIALOG_PARAM_HREF,
            shareLinkContent.getContentUrl());

    return params;
}
项目:Move-Alarm_ORCA    文件:NativeDialogParameters.java   
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;
}
项目:Move-Alarm_ORCA    文件:NativeDialogParameters.java   
private static Bundle create(ShareLinkContent linkContent, boolean dataErrorsFatal) {
    Bundle params = createBaseParameters(linkContent, dataErrorsFatal);

    Utility.putNonEmptyString(params, ShareConstants.TITLE, linkContent.getContentTitle());
    Utility.putNonEmptyString(
            params, ShareConstants.DESCRIPTION, linkContent.getContentDescription());
    Utility.putUri(params, ShareConstants.IMAGE_URL, linkContent.getImageUrl());

    return params;
}
项目:Move-Alarm_ORCA    文件:ShareContentValidation.java   
private static void validateLinkContent(
        ShareLinkContent linkContent, Validator validator) {
    Uri imageUrl = linkContent.getImageUrl();
    if (imageUrl != null && !Utility.isWebUri(imageUrl)) {
        throw new FacebookException("Image Url must be an http:// or https:// url");
    }
}
项目:Move-Alarm_ORCA    文件:LegacyNativeDialogParameters.java   
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;
}
项目:Move-Alarm_ORCA    文件:LegacyNativeDialogParameters.java   
private static Bundle create(ShareLinkContent linkContent, boolean dataErrorsFatal) {
    Bundle params = createBaseParameters(linkContent, dataErrorsFatal);

    Utility.putNonEmptyString(
            params, ShareConstants.LEGACY_TITLE, linkContent.getContentTitle());
    Utility.putNonEmptyString(
            params, ShareConstants.LEGACY_DESCRIPTION, linkContent.getContentDescription());
    Utility.putUri(params, ShareConstants.LEGACY_IMAGE, linkContent.getImageUrl());

    return params;
}
项目:EasyFacebook    文件:BaseLoginActivity.java   
@Override
public void ShareLink(ShareLinkContent shareLinkContent) {
    Profile profile = Profile.getCurrentProfile();
    if (canPresentShareDialog) {
        shareDialog.show(shareLinkContent);
    } else if (profile != null && hasPublishPermission()) {
        ShareApi.share(shareLinkContent, shareCallback);
    }
}
项目:getsocial-android-sdk    文件:FacebookSharePlugin.java   
@Override
public void presentChannelInterface(InviteChannel inviteChannel, InvitePackage invitePackage, final InviteCallback callback) {
    if (isConnected()) {
        ShareLinkContent.Builder shareLinkBuilder = new ShareLinkContent.Builder();

        shareLinkBuilder.setContentUrl(Uri.parse(invitePackage.getReferralUrl()));

        ShareLinkContent sharedContent = shareLinkBuilder.build();

        ShareDialog shareDialog = new ShareDialog(_activity);
        shareDialog.registerCallback(_callbackManager, new FacebookCallback<ShareDialog.Result>() {
                    @Override
                    public void onSuccess(ShareDialog.Result result) {
                        callback.onComplete();
                    }

                    @Override
                    public void onCancel() {
                        callback.onCancel();
                    }

                    @Override
                    public void onError(FacebookException facebookException) {
                        callback.onError(facebookException);
                    }
                }
        );
        shareDialog.show(sharedContent, ShareDialog.Mode.WEB);
    } else {
        onError("Can't reach Facebook. No internet connection.", callback);
    }
}
项目:getsocial-android-sdk    文件:FacebookSharePlugin.java   
@Override
public void presentChannelInterface(InviteChannel inviteChannel, InvitePackage invitePackage, final InviteCallback callback) {
    if (isConnected()) {
        ShareLinkContent.Builder shareLinkBuilder = new ShareLinkContent.Builder();

        shareLinkBuilder.setContentUrl(Uri.parse(invitePackage.getReferralUrl()));

        ShareLinkContent sharedContent = shareLinkBuilder.build();

        ShareDialog shareDialog = new ShareDialog(_activity);
        shareDialog.registerCallback(_callbackManager, new FacebookCallback<ShareDialog.Result>() {
                    @Override
                    public void onSuccess(ShareDialog.Result result) {
                        callback.onComplete();
                    }

                    @Override
                    public void onCancel() {
                        callback.onCancel();
                    }

                    @Override
                    public void onError(FacebookException facebookException) {
                        callback.onError(facebookException);
                    }
                }
        );
        shareDialog.show(sharedContent, ShareDialog.Mode.WEB);
    } else {
        onError("Can't reach Facebook. No internet connection.", callback);
    }
}
项目:CE-SMART-TRACKER-DEV    文件:MyCourseActivity.java   
public void onShareResult(){
    FacebookSdk.sdkInitialize(getApplicationContext());
    callbackManager = CallbackManager.Factory.create();
    final ShareDialog shareDialog = new ShareDialog(this);

    shareDialog.registerCallback(callbackManager, new FacebookCallback<Sharer.Result>() {

        @Override
        public void onSuccess(Sharer.Result result) {
        }

        @Override
        public void onError(FacebookException error) {
        }

        @Override
        public void onCancel() {
        }
    });


    if (shareDialog.canShow(ShareLinkContent.class)) {
        String link = "http://203.151.92.187:8080/courseSchedule?username=" + SingletonID.getInstance().getUserName();
        ShareLinkContent linkContent = new ShareLinkContent.Builder()
                .setContentTitle("CE SMART TRACKER")
                .setContentDescription("วิชาที่เรียน")
                .setContentUrl(Uri.parse(link))
                .build();

        shareDialog.show(linkContent);
    }
    else Toast.makeText(getApplicationContext(),"ลงทะเบียนผ่าน Facebook",Toast.LENGTH_SHORT).show();
}
项目:MyMartlet    文件:DrawerActivity.java   
/**
 * Shares the app on Facebook
 */
private void shareOnFacebook() {
    analytics.sendEvent("facebook", "attempt_post");

    // Set up all of the info
    ShareLinkContent content = new ShareLinkContent.Builder()
            .setContentTitle(getString(R.string.social_facebook_title, "Android"))
            .setContentDescription(getString(R.string.social_facebook_description_android))
            .setContentUrl(Uri.parse(getString(R.string.social_link_android)))
            .setImageUrl(Uri.parse(getString(R.string.social_facebook_image)))
            .build();

    // Show the dialog
    ShareDialog dialog = new ShareDialog(this);
    dialog.registerCallback(facebookCallbackManager, new FacebookCallback<Sharer.Result>() {
        @Override
        public void onSuccess(Sharer.Result result) {
            if (result.getPostId() != null) {
                // Let the user know they posted successfully
                Utils.toast(DrawerActivity.this, R.string.social_post_success);
                analytics.sendEvent("facebook", "successful_post");
            } else {
                Timber.i("Facebook post cancelled");
            }
        }

        @Override
        public void onCancel() {
            Timber.i("Facebook post cancelled");
        }

        @Override
        public void onError(FacebookException e) {
            Timber.e(e, "Error posting to Facebook");
            Utils.toast(DrawerActivity.this, R.string.social_post_failure);
            analytics.sendEvent("facebook", "failed_post");
        }
    });
    dialog.show(content);
}
项目:SocioBlood    文件:WebDialogParameters.java   
public static Bundle create(ShareLinkContent shareLinkContent) {
    Bundle params = new Bundle();
    Utility.putUri(
            params,
            ShareConstants.WEB_DIALOG_PARAM_HREF,
            shareLinkContent.getContentUrl());

    return params;
}
项目:SocioBlood    文件:NativeDialogParameters.java   
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;
}
项目:SocioBlood    文件:NativeDialogParameters.java   
private static Bundle create(ShareLinkContent linkContent, boolean dataErrorsFatal) {
    Bundle params = createBaseParameters(linkContent, dataErrorsFatal);

    Utility.putNonEmptyString(params, ShareConstants.TITLE, linkContent.getContentTitle());
    Utility.putNonEmptyString(
            params, ShareConstants.DESCRIPTION, linkContent.getContentDescription());
    Utility.putUri(params, ShareConstants.IMAGE_URL, linkContent.getImageUrl());

    return params;
}
项目:SocioBlood    文件:ShareContentValidation.java   
private static void validateLinkContent(
        ShareLinkContent linkContent, Validator validator) {
    Uri imageUrl = linkContent.getImageUrl();
    if (imageUrl != null && !Utility.isWebUri(imageUrl)) {
        throw new FacebookException("Image Url must be an http:// or https:// url");
    }
}