예제 #1
0
  /** Get the current user profile info */
  private void makeMeRequest() {
    final Session session = Session.getActiveSession();
    if (session != null && session.isOpened()) {
      Request request =
          Request.newMeRequest(
              session,
              new Request.GraphUserCallback() {
                @Override
                public void onCompleted(GraphUser user, Response response) {
                  isMakeMeRequestStarted = false;
                  dismissProgressDialog();

                  if (session == Session.getActiveSession() && user != null) {
                    mUser = user;
                    updateUI();
                  }
                  if (response != null && response.getError() != null) {
                    Utils.handleError(
                        getActivity(), response.getError(), Utils.getProfileReadPermission());
                  }
                }
              });
      request.executeAsync();
    }
  }
예제 #2
0
  @Override
  public void onHiddenChanged(boolean hidden) {
    super.onHiddenChanged(hidden);

    final Session session = Session.getActiveSession();
    if (mUser == null && !hidden && session != null && session.isOpened()) {
      if (!isMakeMeRequestStarted) {
        makeMeRequest();
        isMakeMeRequestStarted = true;
      }
      if (!isStatusesRequestStarted) {
        startStatusesRequest();
        isStatusesRequestStarted = true;
      }
      showProgressDialog();
    }
  }
예제 #3
0
  /** Get the user's status */
  private void startStatusesRequest() {
    Session session = Session.getActiveSession();
    if (session != null && session.isOpened()) {
      new Request(
              session,
              "/me/statuses",
              null,
              HttpMethod.GET,
              new Request.Callback() {
                public void onCompleted(Response response) {
                  isStatusesRequestStarted = false;
                  dismissProgressDialog();

                  handleStatusResponse(response);
                }
              })
          .executeAsync();
    }
  }