1

我的目标是等待个人资料图片下载,以便开始制作使用该图片的视频。

我正在使用提供的 facebook 小部件: ProfilePictureView 来显示图片。

我正在等待 executeMeRequestAsync() 的 onComplete ,但这似乎在等待仅包含图片 ID 的 GraphUser。当我执行 ProfilePictureView 的 setProfileId() 时,它开始下载图片。

有没有可能有类似 onComplete() 的东西等待使用 ProfilePictureView 下载?或者我需要去获取位图或其他东西,但是如何进行回调以报告文件下载已完成?

从 FB 和 onComplete 获取信息的代码显示了将启动视频的按钮

Request.executeMeRequestAsync(session, new Request.GraphUserCallback() {
    public void onCompleted(GraphUser user, Response response) {
        showStartButton();                  
    }               
}); 
4

3 回答 3

2

您还可以像这样设置用户个人资料图像:

<com.facebook.widget.ProfilePictureView
android:id="@+id/friendProfilePicture"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="center_horizontal"
android:padding="5sp"
facebook:preset_size="small" />

facebook:preset_size: small/normal/large/custom.(根据您的需要)在代码中设置 facebook 用户 ID:

ProfilePictureView profilePictureView = (ProfilePictureView) findViewById(R.id.friendProfilePicture);
profilePictureView.setProfileId(userId)`;
于 2014-08-30T12:52:19.470 回答
1

您不需要使用 ProfilePictureView(除非您想将视图对象直接嵌入到动画中,在这种情况下,您应该在 onCompleted 回调中调用 setProfileId)。如果您只想获取个人资料图片,在您的 onCompleted 中,您可以执行以下操作:

String id = user.getId();
Uri uri = Uri.parse("http://graph.facebook.com/" + id + "/picture");

然后使用该 uri 创建位图(请参阅此处有关如何执行此操作的答案)。

如果你想要不同的尺寸,你也可以在uri中指定一个“类型”,或者一个“高度”/“宽度”参数。有关参数值的更多信息,请参阅此页面(并搜索“用户的个人资料图片”)。

于 2013-01-29T17:58:02.873 回答
0

为了实现我想要的:在进入下一个屏幕之前下载 facebook 个人资料图片我使用了由 Ming Li在 AsyncTask 的 doInBackground 方法中链接的 loadBitmap 方法。

onComplete 方法看起来像这样

public void onCompleted(GraphUser user, Response response) {
    String id = user.getId();
    String url = "http://graph.facebook.com/" + id + "/picture?type=normal";
    ImageLoader il = new ImageLoader(getActivity());//this class extends AsyncTask<String, Integer, Bitmap>
    il.execute(url);
    showStartButton();                  
}

因此,我通过使用 ProgressDialog 来阻止用户继续,当调用 AsyncTask onPostExecute() 方法时该对话框将消失,这意味着下载已完成。

于 2013-02-02T20:23:52.440 回答