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

项目: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);
    }
}
项目:kognitivo    文件:ShareContentValidation.java   
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);
    }
}
项目: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    文件: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);
    }
}
项目:Move-Alarm_ORCA    文件:ShareContentValidation.java   
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);
    }
}
项目: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    文件: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);
    }
}
项目:SocioBlood    文件:ShareContentValidation.java   
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);
    }
}
项目: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(
        SharePhotoContent photoContent,
        List<String> imageUrls,
        boolean dataErrorsFatal) {
    Bundle params = createBaseParameters(photoContent, dataErrorsFatal);

    params.putStringArrayList(ShareConstants.PHOTOS, new ArrayList<>(imageUrls));

    return params;
}
项目: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(
        SharePhotoContent photoContent,
        List<String> imageUrls,
        boolean dataErrorsFatal) {
    Bundle params = createBaseParameters(photoContent, dataErrorsFatal);

    params.putStringArrayList(ShareConstants.LEGACY_PHOTOS, new ArrayList<>(imageUrls));

    return params;
}
项目:OSS-green-07    文件:HomeActivity.java   
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();
    }
}
项目:OSS-purple-06    文件:HomeActivity.java   
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();
    }
}
项目:PhotoApp    文件:SocialUtil.java   
/**
 * 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);
}
项目:journal    文件:FbInfoFragment.java   
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);
}
项目:android-fagyi    文件:FacebookHandler.java   
/**
 * 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);
    }
}
项目: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(
        SharePhotoContent photoContent,
        List<String> imageUrls,
        boolean dataErrorsFatal) {
    Bundle params = createBaseParameters(photoContent, dataErrorsFatal);

    params.putStringArrayList(ShareConstants.PHOTOS, new ArrayList<>(imageUrls));

    return params;
}
项目: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(
        SharePhotoContent photoContent,
        List<String> imageUrls,
        boolean dataErrorsFatal) {
    Bundle params = createBaseParameters(photoContent, dataErrorsFatal);

    params.putStringArrayList(ShareConstants.LEGACY_PHOTOS, new ArrayList<>(imageUrls));

    return params;
}
项目:EasyFacebook    文件:BaseLoginActivity.java   
@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()));
    }
}
项目: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(
        SharePhotoContent photoContent,
        List<String> imageUrls,
        boolean dataErrorsFatal) {
    Bundle params = createBaseParameters(photoContent, dataErrorsFatal);

    params.putStringArrayList(ShareConstants.PHOTOS, new ArrayList<>(imageUrls));

    return params;
}
项目:SocioBlood    文件: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;
}
项目:SocioBlood    文件:LegacyNativeDialogParameters.java   
private static Bundle create(
        SharePhotoContent photoContent,
        List<String> imageUrls,
        boolean dataErrorsFatal) {
    Bundle params = createBaseParameters(photoContent, dataErrorsFatal);

    params.putStringArrayList(ShareConstants.LEGACY_PHOTOS, new ArrayList<>(imageUrls));

    return params;
}
项目:journal    文件:FbInfoFragment.java   
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);
}
项目:kognitivo    文件:ShareContentValidation.java   
@Override
public void validate(final SharePhotoContent photoContent) {
    throw new FacebookException("Cannot share SharePhotoContent via web sharing dialogs");
}
项目:kognitivo    文件:ShareContentValidation.java   
public void validate(final SharePhotoContent photoContent) {
    validatePhotoContent(photoContent, this);
}
项目:Move-Alarm_ORCA    文件:ShareContentValidation.java   
@Override
public void validate(final SharePhotoContent photoContent) {
    throw new FacebookException("Cannot share SharePhotoContent via web sharing dialogs");
}
项目:Move-Alarm_ORCA    文件:ShareContentValidation.java   
public void validate(final SharePhotoContent photoContent) {
    validatePhotoContent(photoContent, this);
}
项目:SocioBlood    文件:ShareContentValidation.java   
@Override
public void validate(final SharePhotoContent photoContent) {
    throw new FacebookException("Cannot share SharePhotoContent via web sharing dialogs");
}
项目:SocioBlood    文件:ShareContentValidation.java   
public void validate(final SharePhotoContent photoContent) {
    validatePhotoContent(photoContent, this);
}
项目:EasyFacebook    文件:Facebook_ShareDialog.java   
void SharePhoto(SharePhotoContent sharePhotoContent);