Esempio n. 1
0
    public void onComplete(final String response, final Object state) {
      // Log.d(tag, "    onComplete()");
      JSONObject jobj;
      try {
        jobj = new JSONObject(response);
        final String picURL =
            jobj.getJSONObject("picture")
                .getJSONObject("data")
                .getString("url")
                .replaceFirst("^https", "http");
        Fb fb = Fb.getInstance();
        fb.setUserName(jobj.getString("name"));
        fb.setUserUID(jobj.getString("id"));
        fb.setUserPicNotAvailable();
        handler.sendEmptyMessage(1); // User info update

        Bitmap userpic_bitmap = Utility.getBitmap(picURL);
        if (null == userpic_bitmap) return;

        try {
          FileOutputStream fos = new FileOutputStream(fb.getUserPicFilename());
          userpic_bitmap.compress(CompressFormat.JPEG, 100, fos);
        } catch (FileNotFoundException e) {
          e.printStackTrace();
        }
        fb.setUserPicAvailable();
        handler.sendEmptyMessage(1); // User info update
      } catch (JSONException e) {
        e.printStackTrace();
      }
    }
Esempio n. 2
0
 public static void loadUserInfo(Handler handler) {
   Bundle params = new Bundle();
   params.putString("fields", "name, picture");
   Fb.getInstance().async().request("me", params, new UserRequestListener(handler));
 }