Exemplo n.º 1
0
  private static void getTwitterProfileInfo(AccessToken accessToken2) {
    try {
      String token = accessToken2.getToken();
      Log.i(TAG, "token is " + token);
      mUserInfo.setExtra(token);
      long userId = accessToken2.getUserId();
      mUserInfo.setTwitterId(String.valueOf(userId));
      userObj = twitter.showUser(userId);
      mUserInfo.setProfilePic(userObj.getBiggerProfileImageURLHttps());
      long cursor = -1;
      IDs freinds = twitter.getFriendsIDs(userObj.getId(), cursor);
      Log.d(TAG, "IDS:" + freinds.getIDs());
      if (freinds.getIDs() != null) {
        StringBuilder builder = new StringBuilder();
        builder.append("");
        do {
          for (long i : freinds.getIDs()) {

            builder.append(i + ",");
          }
        } while (freinds.hasNext());
        String freindIds = builder.toString();
        Log.d("MSG:", "FND id:" + freindIds);
        if (freindIds.equals("")) {
          mUserInfo.setFriendsIds(freindIds);
        } else {
          freindIds = freindIds.substring(0, freindIds.length() - 1);
          mUserInfo.setFriendsIds(freindIds);
        }
      }
      if (userObj.getName() != null) {
        String name[] = userObj.getName().split(" ");
        /*
         * mUserInfo.setFirstName(name[0]); if (name[1] != null) {
         * mUserInfo.setLastName(name[1]);
         *
         * }
         */
        if (name.length >= 2) {
          mUserInfo.setFirstName(name[0]);
          mUserInfo.setLastName(name[1]);
        } else if (name.length >= 1) {
          mUserInfo.setFirstName(name[0]);
        }
      }

      mUserInfo.setExpiresIn(String.valueOf(System.currentTimeMillis() + 600000));

    } catch (TwitterException e) {
      Log.e(TAG, "Twitter login error");
    }

    twitterHandler.isExit(String.valueOf(accessToken2.getUserId()));
  }
Exemplo n.º 2
0
  public TwitterUtil(Context mContext, String source, String filmId, boolean fromQueue) {
    TwitterUtil.mContext = mContext;
    mLoginProgressDialog = new ProgressDialog(mContext);
    mLoginProgressDialog.setCanceledOnTouchOutside(false);
    twitterHandler = new TwitterUsr(mContext);
    twitterHandler.setListener(this);

    loginHandler = new SaveUserHandler(mContext);
    loginHandler.setListener(this);
    this.source = source;
    this.mFilmId = filmId;
    this.fromQueue = fromQueue;
    context = (Activity) mContext;
  }