1

My goal is to wait for the profile picture download so I can start a video that will use that picture.

I'm using the provided facebook widget: ProfilePictureView to show the picture.

And I'm waiting for the onComplete of executeMeRequestAsync() but this seems to wait for the GraphUser that only contains the picture Id. When I do the setProfileId() of the ProfilePictureView is when it starts downloading the picture.

There's any possibility to have something like that onComplete() that waits for the download using ProfilePictureView? Or I'll need to go for a Bitmap or something, but then How do I make a callback to report that the download of file is completed?

Code that get's the info from FB and onComplete show my button that will start the video

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

3 Answers3

2

You can also set user profile image like this:

<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.(As your need) set the facebook user id in code :

ProfilePictureView profilePictureView = (ProfilePictureView) findViewById(R.id.friendProfilePicture);
profilePictureView.setProfileId(userId)`;
Yogendra
  • 4,817
  • 1
  • 28
  • 21
1

You don't need to use ProfilePictureView (unless you want to embed the view object directly in your animation, in which case you should call setProfileId in your onCompleted callback). If you want to just get the profile picture, in your onCompleted, you can do something like:

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

And then use that uri to create a bitmap (see answers here on how to do that).

If you want different sizes, you can also specify a "type", or a "height"/"width" parameter in the uri. See this page (and search for "The user's profile picture") for more info on the parameter values.

Community
  • 1
  • 1
Ming Li
  • 15,672
  • 3
  • 37
  • 35
  • That not actually answer my question. I was using setProfileId and only when you called that the image start downloading. But you make me understand that my solution will use Bitmap. Thanks for that and for the links also! – pepipe Feb 02 '13 at 20:11
0

For achieve want I want: to have the facebook profile picture downloaded before I go to the next screen I used the loadBitmap method linked by Ming Li inside doInBackground method from AsyncTask.

onComplete method look like this

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();                  
}

So this way I prevent users to continue by using a ProgressDialog that will disappear when the AsyncTask onPostExecute() method is called, meaning that the download is finished.

Community
  • 1
  • 1
pepipe
  • 61
  • 8