예제 #1
0
    public void onSessionOpened() {
      UserProfile userProfile = UserProfile.loadFromCache();
      if (userProfile != null && userProfile.getId() != Long.MIN_VALUE) {
        Toast.makeText(
                getActivity(),
                "user id : "
                    + String.valueOf(userProfile.getId())
                    + "\naccess_token : "
                    + Session.getCurrentSession().getAccessToken(),
                Toast.LENGTH_SHORT)
            .show();
      } else {

        UserManagement.requestMe(
            new MeResponseCallback() {

              @Override
              protected void onSuccess(final UserProfile userProfile) {
                Logger.getInstance().d("UserProfile : " + userProfile);
                userProfile.saveUserToCache();
                Toast.makeText(
                        getActivity(),
                        "user id : "
                            + String.valueOf(userProfile.getId())
                            + "\naccess_token : "
                            + Session.getCurrentSession().getAccessToken(),
                        Toast.LENGTH_SHORT)
                    .show();
              }

              @Override
              protected void onNotSignedUp() {}

              @Override
              protected void onSessionClosedFailure(final APIErrorResult errorResult) {}

              @Override
              protected void onFailure(final APIErrorResult errorResult) {
                String message = "failed to get user info. msg=" + errorResult;
                Logger.getInstance().d(message);
              }
            });
      }
    }
 /**
  * param으로 온 UserProfile에 대해 view를 update한다.
  *
  * @param userProfile 화면에 반영할 사용자 정보
  */
 public void setUserProfile(final UserProfile userProfile) {
   setProfileURL(userProfile.getProfileImagePath());
   setNickname(userProfile.getNickname());
   setUserId(String.valueOf(userProfile.getId()));
 }