Ejemplo n.º 1
0
 @NonNull
 public static User showUserAlternative(
     final Twitter twitter, final long id, final String screenName) throws TwitterException {
   final String searchScreenName;
   if (screenName != null) {
     searchScreenName = screenName;
   } else if (id != -1) {
     searchScreenName = twitter.showFriendship(id).getTargetUserScreenName();
   } else throw new IllegalArgumentException();
   final Paging paging = new Paging();
   paging.count(1);
   for (final User user : twitter.searchUsers(searchScreenName, paging)) {
     if (user.getId() == id || searchScreenName.equalsIgnoreCase(user.getScreenName()))
       return user;
   }
   if (id != -1) {
     final ResponseList<Status> timeline = twitter.getUserTimeline(id, paging);
     for (final Status status : timeline) {
       final User user = status.getUser();
       if (user.getId() == id) return user;
     }
   } else {
     final ResponseList<Status> timeline = twitter.getUserTimeline(screenName, paging);
     for (final Status status : timeline) {
       final User user = status.getUser();
       if (searchScreenName.equalsIgnoreCase(user.getScreenName())) return user;
     }
   }
   throw new TwitterException("can't find user");
 }
Ejemplo n.º 2
0
 @Deprecated
 public String getDisplayName(
     final User user, final boolean nameFirst, final boolean ignoreCache) {
   return getDisplayName(
       user.getId(), user.getName(), user.getScreenName(), nameFirst, ignoreCache);
 }