Java 类com.facebook.Request.GraphUserCallback 实例源码

项目:QuizUpWinner    文件:FacebookFriendsFragment.java   
private void onLoginFacebookCallback(final Session paramSession)
{
  if (paramSession.isOpened())
    Request.newMeRequest(paramSession, new Request.GraphUserCallback()
    {
      public void onCompleted(GraphUser paramAnonymousGraphUser, Response paramAnonymousResponse)
      {
        if (paramAnonymousGraphUser != null)
        {
          FacebookFriendsFragment.access$202(FacebookFriendsFragment.this, paramSession.getAccessToken());
          Object[] arrayOfObject = new Object[1];
          arrayOfObject[0] = FacebookFriendsFragment.this.fbAccessToken;
          .ˊ("REQUEST_FB_LINKING", arrayOfObject);
        }
      }
    }).executeAsync();
}
项目:openkit-android    文件:FacebookUtilities.java   
private static void GetFacebookUserInfo(final GetFBUserIDRequestHandler requestHandler)
{
    Session session = Session.getActiveSession();

    if(isFBSessionOpen())
    {
        Request meRequest = Request.newMeRequest(session, new GraphUserCallback() {
            @Override
            public void onCompleted(GraphUser user, Response response) {
                if(user != null) {
                    requestHandler.onCompletion(user);
                } else {
                    requestHandler.onCompletion(null);
                }
            }
        });

        meRequest.executeAsync();
    } else {
        OKLog.v("Tried to get FB user ID without being logged into FB");
        requestHandler.onCompletion(null);
    }
}
项目:QuizUpWinner    文件:SettingsFragment.java   
public void onFacebookLinkClick()
{
  if (!.ˋ("PREF_IS_FACEBOOK_LINKED"))
  {
    Session.openActiveSession(getActivity(), this, true, new Session.StatusCallback()
    {
      public void call(final Session paramAnonymousSession, SessionState paramAnonymousSessionState, Exception paramAnonymousException)
      {
        if (paramAnonymousSession.isOpened())
          Request.executeMeRequestAsync(paramAnonymousSession, new Request.GraphUserCallback()
          {
            public void onCompleted(GraphUser paramAnonymous2GraphUser, Response paramAnonymous2Response)
            {
              if (paramAnonymous2GraphUser != null)
              {
                SettingsFragment.access$002(SettingsFragment.this, paramAnonymousSession.getAccessToken());
                Object[] arrayOfObject = new Object[1];
                arrayOfObject[0] = SettingsFragment.this.fbAccessToken;
                .ˊ("REQUEST_FB_LINKING", arrayOfObject);
              }
            }
          });
      }
    });
    return;
  }
   localⅹ = QuizApplication.ˊ.ˋ;
  int i;
  if ((localⅹ.ˏ != null) && (!localⅹ.ˏ.equals("")))
    i = 1;
  else
    i = 0;
  if (i != 0)
  {
    .ˊ("REQUEST_FB_UNLINK", new Object[0]);
    return;
  }
  showUnlinkNotAllowedError();
}
项目:QuizUpWinner    文件:LoginButton.java   
private void fetchUserInfo()
{
  if (this.fetchUserInfo)
  {
    final Session localSession = this.sessionTracker.getOpenSession();
    if (localSession != null)
    {
      if (localSession != this.userInfoSession)
      {
        Request.executeBatchAsync(new Request[] { Request.newMeRequest(localSession, new Request.GraphUserCallback()
        {
          public void onCompleted(GraphUser paramAnonymousGraphUser, Response paramAnonymousResponse)
          {
            if (localSession == LoginButton.this.sessionTracker.getOpenSession())
            {
              LoginButton.access$502(LoginButton.this, paramAnonymousGraphUser);
              if (LoginButton.this.userInfoChangedCallback != null)
                LoginButton.this.userInfoChangedCallback.onUserInfoFetched(LoginButton.this.user);
            }
            if (paramAnonymousResponse.getError() != null)
              LoginButton.this.handleError(paramAnonymousResponse.getError().getException());
          }
        }) });
        this.userInfoSession = localSession;
      }
    }
    else
    {
      this.user = null;
      if (this.userInfoChangedCallback != null)
        this.userInfoChangedCallback.onUserInfoFetched(this.user);
    }
  }
}
项目:QuizUpWinner    文件:UserSettingsFragment.java   
private void fetchUserInfo()
{
  final Session localSession = getSession();
  if ((localSession != null) && (localSession.isOpened()))
  {
    if (localSession != this.userInfoSession)
    {
      Request localRequest = Request.newMeRequest(localSession, new Request.GraphUserCallback()
      {
        public void onCompleted(GraphUser paramAnonymousGraphUser, Response paramAnonymousResponse)
        {
          if (localSession == UserSettingsFragment.this.getSession())
          {
            UserSettingsFragment.access$002(UserSettingsFragment.this, paramAnonymousGraphUser);
            UserSettingsFragment.this.updateUI();
          }
          if (paramAnonymousResponse.getError() != null)
            UserSettingsFragment.this.loginButton.handleError(paramAnonymousResponse.getError().getException());
        }
      });
      Bundle localBundle = new Bundle();
      localBundle.putString("fields", REQUEST_FIELDS);
      localRequest.setParameters(localBundle);
      Request.executeBatchAsync(new Request[] { localRequest });
      this.userInfoSession = localSession;
    }
  }
  else
    this.user = null;
}
项目:wings    文件:FacebookEndpoint.java   
/**
 * Asynchronously requests the user name associated with the linked account. Requires an opened active
 * {@link Session}.
 *
 * @param graphUserCallback a {@link GraphUserCallback} when the request completes.
 * @return true if the request is made; false if no opened {@link Session} is active.
 */
boolean requestAccountName(GraphUserCallback graphUserCallback) {
    boolean isSuccessful = false;

    Session session = Session.getActiveSession();
    if (session != null && session.isOpened()) {
        Request.newMeRequest(session, graphUserCallback).executeAsync();
        isSuccessful = true;
    }
    return isSuccessful;
}
项目:wings    文件:FacebookAlbumListFragment.java   
/**
 * Asynchronously requests the user name associated with the linked account. Tries to finish the
 * {@link FacebookSettingsActivity} when completed.
 */
private void requestAccountName() {
    GraphUserCallback callback = new GraphUserCallback() {
        @Override
        public void onCompleted(GraphUser user, Response response) {
            FacebookSettingsActivity activity = (FacebookSettingsActivity) getActivity();
            if (activity == null || activity.isFinishing()) {
                return;
            }

            if (response != null && response.getError() == null && user != null) {
                String accountName = user.getFirstName() + " " + user.getLastName();
                if (accountName != null && accountName.length() > 0) {
                    activity.mAccountName = accountName;
                } else {
                    activity.mHasErrorOccurred = true;
                }
            } else {
                activity.mHasErrorOccurred = true;
            }

            activity.tryFinish();
        }
    };

    mFacebookEndpoint.requestAccountName(callback);
}
项目:buddycloud-android    文件:FacebookContactMatcher.java   
private void getFriends(final Context context, final Session session, 
        final ModelCallback<JSONArray> callback) {
    Request.newMeRequest(session, new GraphUserCallback() {
        @Override
        public void onCompleted(final GraphUser user, Response response) {
            if (response.getError() != null) {
                callback.error(response.getError().getException());
                return;
            }
            getFriends(context, session, user, callback);
        }
    }).executeAsync();
}
项目:CodePix-Android    文件:SettingsFragment.java   
private void login() {



     try {
        if (Session.getActiveSession() == null
                    || Session.getActiveSession().isClosed()) {
                Session.openActiveSession(getActivity(), true, new StatusCallback() {

                    @SuppressWarnings("deprecation")
                    @Override
                    public void call(Session session, SessionState state,
                            Exception exception) {
                        System.out.println("State= " + state);

                        if (session.isOpened()) {
                            System.out.println("Token=" + session.getAccessToken());

                            mPrefs.edit().putString("fbToken", session.getAccessToken()).commit();
                            Request.executeMeRequestAsync(session,
                                    new GraphUserCallback() {
                                        @Override
                                        public void onCompleted(GraphUser user,
                                                Response response) {
                                            if (user != null) {
                                                System.out.println("User=" + user);

                                            }
                                            pd.dismiss();
                                        }
                                    });
                        }
                        if (exception != null) {
                            System.out.println("Some thing bad happened!");
                            exception.printStackTrace();


                            pd.dismiss();

                            GlobalMethods.showMessage(getActivity(), "Facebook connect failed.");
                        }
                    }
                });
            }
    } catch (Exception e) {

        pd.dismiss();
        e.printStackTrace();
        GlobalMethods.showMessage(getActivity(), getString(R.string.internet_error));
    }
}
项目:CodePix-Android    文件:ImageDistortedUploadActivity.java   
private void login() {
     try {
    if (Session.getActiveSession() == null
                || Session.getActiveSession().isClosed()) {
            Session.openActiveSession(ImageDistortedUploadActivity.this, true, new StatusCallback() {

                @SuppressWarnings("deprecation")
                @Override
                public void call(Session session, SessionState state,
                        Exception exception) {
                    System.out.println("State= " + state);

                    if (session.isOpened()) {
                        System.out.println("Token=" + session.getAccessToken());

                        mPrefs.edit().putString("fbToken", session.getAccessToken()).commit();
                        Request.executeMeRequestAsync(session,
                                new GraphUserCallback() {
                                    @Override
                                    public void onCompleted(GraphUser user,
                                            Response response) {
                                        if (user != null) {
                                            System.out.println("User=" + user);

                                        }
                                        pd.dismiss();
                                    }
                                });
                    }
                    if (exception != null) {
                        System.out.println("Some thing bad happened!");
                        exception.printStackTrace();

                        pd.dismiss();

                        GlobalMethods.showMessage(getApplicationContext(), "Facebook Share failed.");
                    }
                }
            });
        }
} catch (Exception e) {
    // TODO Auto-generated catch block

    pd.dismiss();
    e.printStackTrace();
    GlobalMethods.showMessage(getApplicationContext(), getString(R.string.internet_error));
}
  }
项目:android_socialmedia    文件:MainActivity.java   
private void loginToFacebook() {
    openActiveSession(this, true, new StatusCallback() {

        @Override
        public void call(Session session, SessionState state, Exception exception) {
            if (session.isOpened()) {
                Session.setActiveSession(session);
                Request.newMeRequest(session, new GraphUserCallback() {

                    @Override
                    public void onCompleted(GraphUser user, Response response) {
                        if (user != null) {
                            Log.d("facebook name", user.getName() + " " + user.asMap().get("email"));
                            String userimage = "http://graph.facebook.com/" + user.getId() + "/picture?style=small";

                            Editor editor = sharedPreferences.edit();
                            editor.putString(Config.ACCOUNT, "Facebook");
                            editor.putString(Config.NAME, "Name: " + user.getName());
                            editor.putString(Config.IMAGE, userimage);
                            String location = null;
                            try {
                                location = user.getLocation().getCity();
                                if (location == null || location.equals(""))
                                    location = "Not found";
                            } catch (Exception e) {
                                e.printStackTrace();
                                location = "Not found";
                            }

                            String data = "UserName: " + user.getUsername() + "\n" + "Location: " + location + "\n";
                            editor.putString(Config.DATA, data);
                            editor.commit();

                            /*
                             * HashMap<String, String> map = new
                             * HashMap<String, String>(); map.put("account",
                             * "Google+"); map.put("name",
                             * "Name:\n"+user.getFirstName
                             * ()+" "+user.getLastName()); map.put("image",
                             * userimage); String data =
                             * "UserName: "+user.getUsername()+"\n"+
                             * "Location: "+user.getLocation()+"\n";
                             * map.put("userData", data);
                             */
                            // in.putExtra("data", map);
                            startActivity(new Intent(MainActivity.this, ResultActivity.class));
                            overridePendingTransition(android.R.anim.slide_in_left, android.R.anim.slide_out_right);
                            finish();
                        }
                    }
                }).executeAsync();
            }
        }
    }, Arrays.asList("email", "publish_actions"));
}