List of usage examples for twitter4j Twitter searchUsers
ResponseList<User> searchUsers(String query, int page) throws TwitterException;
From source file:com.daiv.android.twitter.ui.search.UserSearchFragment.java
License:Apache License
public void doUserSearch(final String mQuery) { listView.setVisibility(View.GONE); spinner.setVisibility(View.VISIBLE); hasMore = true;//from ww w . j av a2s . c o m canRefresh = false; new Thread(new Runnable() { @Override public void run() { try { Twitter twitter = Utils.getTwitter(context, settings); ResponseList<User> result = twitter.searchUsers(mQuery, userPage); userPage++; if (result.size() < 18) { hasMore = false; canRefresh = false; } users = new ArrayList<User>(); for (User u : result) { users.add(u); } ((Activity) context).runOnUiThread(new Runnable() { @Override public void run() { peopleAdapter = new PeopleArrayAdapter(context, users, onlyProfile); listView.setAdapter(peopleAdapter); listView.setVisibility(View.VISIBLE); spinner.setVisibility(View.GONE); canRefresh = true; } }); } catch (Exception e) { e.printStackTrace(); ((Activity) context).runOnUiThread(new Runnable() { @Override public void run() { spinner.setVisibility(View.GONE); } }); hasMore = false; canRefresh = true; } } }).start(); }
From source file:com.daiv.android.twitter.ui.search.UserSearchFragment.java
License:Apache License
public void getMoreUsers(final String mQuery) { if (hasMore) { canRefresh = false;//from w w w. ja va 2 s . co m mPullToRefreshLayout.setRefreshing(true); new Thread(new Runnable() { @Override public void run() { try { Twitter twitter = Utils.getTwitter(context, settings); ResponseList<User> result = twitter.searchUsers(mQuery, userPage); userPage++; for (User u : result) { users.add(u); } ((Activity) context).runOnUiThread(new Runnable() { @Override public void run() { if (peopleAdapter != null) { peopleAdapter.notifyDataSetChanged(); } mPullToRefreshLayout.setRefreshing(false); } }); } catch (Exception e) { e.printStackTrace(); ((Activity) context).runOnUiThread(new Runnable() { @Override public void run() { mPullToRefreshLayout.setRefreshing(false); } }); hasMore = false; } } }).start(); } }
From source file:com.dwdesign.tweetings.loader.UserSearchLoader.java
License:Open Source License
@Override public List<ParcelableUser> getUsers() throws TwitterException { final Twitter twitter = getTwitter(); if (twitter == null) return null; final ResponseList<User> users = twitter.searchUsers(mQuery, mPage); final List<ParcelableUser> result = new ArrayList<ParcelableUser>(); final int size = users.size(); for (int i = 0; i < size; i++) { result.add(new ParcelableUser(users.get(i), mAccountId, (mPage - 1) * 20 + i)); }//from ww w . ja v a 2s .co m return result; }
From source file:com.klinker.android.twitter.ui.search.UserSearchFragment.java
License:Apache License
public void doUserSearch(final String mQuery) { listView.setVisibility(View.GONE); spinner.setVisibility(View.VISIBLE); hasMore = true;//from w w w . j a v a 2 s. co m canRefresh = false; new Thread(new Runnable() { @Override public void run() { try { Twitter twitter = Utils.getTwitter(context, settings); ResponseList<User> result = twitter.searchUsers(mQuery, userPage); userPage++; if (result.size() < 18) { hasMore = false; canRefresh = false; } users = new ArrayList<User>(); for (User u : result) { users.add(u); } ((Activity) context).runOnUiThread(new Runnable() { @Override public void run() { peopleAdapter = new PeopleArrayAdapter(context, users, onlyProfile); listView.setAdapter(peopleAdapter); listView.setVisibility(View.VISIBLE); spinner.setVisibility(View.GONE); canRefresh = true; } }); } catch (Exception e) { e.printStackTrace(); ((Activity) context).runOnUiThread(new Runnable() { @Override public void run() { spinner.setVisibility(View.GONE); } }); hasMore = false; canRefresh = true; } } }).start(); }
From source file:de.vanita5.twittnuker.loader.support.ParcelableUserLoader.java
License:Open Source License
private static User showUserAlternative(final Twitter twitter, final long id, final String screenName) throws TwitterException { final String searchScreenName; if (screenName != null) { searchScreenName = screenName;/*from w w w .j av a 2 s . c o m*/ } else if (id != -1) { searchScreenName = twitter.showFriendship(twitter.getId(), id).getTargetUserScreenName(); } else return null; for (final User user : twitter.searchUsers(searchScreenName, 1)) { if (user.getId() == id || searchScreenName.equals(user.getScreenName())) return user; } return null; }
From source file:de.vanita5.twittnuker.loader.support.UserSearchLoader.java
License:Open Source License
@Override public List<User> getUsers(final Twitter twitter) throws TwitterException { if (twitter == null) return null; return twitter.searchUsers(mQuery, mPage); }
From source file:org.getlantern.firetweet.util.TwitterWrapper.java
License:Open Source License
@NonNull public static User showUserAlternative(final Twitter twitter, final long id, final String screenName) throws TwitterException { final String searchScreenName; if (screenName != null) { searchScreenName = screenName;/* www . j av a2 s.c om*/ } else if (id != -1) { searchScreenName = twitter.showFriendship(twitter.getId(), id).getTargetUserScreenName(); } else throw new IllegalArgumentException(); final Paging paging = new Paging(); paging.count(1); 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; } } for (final User user : twitter.searchUsers(searchScreenName, 1)) { if (user.getId() == id || searchScreenName.equalsIgnoreCase(user.getScreenName())) return user; } throw new TwitterException("can't find user"); }
From source file:peoplesearch.SearchTwitterUsers.java
public void SearchTwitterUsers() { int page = 1; int numberofpages = 0; Date TwitterAccCreatedAt = new Date(); String TwitterAccDescr = " "; int TwitterFollowersCount = 0; int TwitterFriendsCount = 0; boolean TwitterGeoEnabled = false; String TwitterLocation = " "; String TwiterAccScrName = " "; long TwitterID = 0L; try {/*from w w w .j a v a 2 s . c o m*/ Twitter twitter = new TwitterFactory().getInstance(); ResponseList<User> users; List<Person> people = null; GraphManager mgr = EmbeddedGraphManager.getInstance(); mgr.init(new File("/usr/local/Cellar/neo4j/2.1.7/libexec/data/forlang1.db")); mgr.addPerson(new PersonImpl("wgaura")); mgr.addPerson(new PersonImpl("Derek Mizak")); mgr.addPerson(new PersonImpl("Swiderek")); mgr.addPerson(new PersonImpl("Microsoft")); mgr.addPerson(new PersonImpl("BBC")); mgr.addPerson(new PersonImpl("RTE")); mgr.addPerson(new PersonImpl("CNBC")); mgr.addPerson(new PersonImpl("Poland")); mgr.addPerson(new PersonImpl("Ireland")); mgr.addPerson(new PersonImpl("Ergo")); people = mgr.listPeople(); for (Person person : people) { do { TwitterLimitWait tlw = new TwitterLimitWait(); tlw.CheckLimit(); users = twitter.searchUsers(person.getName(), page); numberofpages = users.size() / 20; for (User user : users) { if (user.getStatus() != null) { TwitterAccCreatedAt = user.getCreatedAt(); if (!user.getDescription().isEmpty()) { TwitterAccDescr = user.getDescription(); } //if (user.getFollowersCount()>0) {TwitterFollowersCount=user.getFavouritesCount();} //if (user.getFriendsCount()>0) {TwitterFriendsCount=user.getFriendsCount();} TwitterFollowersCount = user.getFollowersCount(); TwitterFriendsCount = user.getFriendsCount(); TwitterGeoEnabled = user.isGeoEnabled(); if (!user.getLocation().isEmpty()) { TwitterLocation = user.getLocation(); } TwiterAccScrName = user.getScreenName(); TwitterID = user.getId(); System.out.println("@" + user.getScreenName() + " - " + TwitterFollowersCount + " _ " + TwitterFriendsCount); //mgr.addTwitterAccount(new TwitterAccountImpl(TwitterAccCreatedAt,TwitterAccDescr,TwitterFollowersCount,TwitterFriendsCount,TwitterGeoEnabled,TwitterLocation,TwiterAccScrName,TwitterID)); mgr.linkPersonToTwitterAccount(person, new TwitterAccountImpl(TwitterAccCreatedAt, TwitterAccDescr, TwitterFollowersCount, TwitterFriendsCount, TwitterGeoEnabled, TwitterLocation, TwiterAccScrName, TwitterID)); TwitterAccDescr = " "; TwitterLocation = " "; TwitterFollowersCount = 0; TwitterFriendsCount = 0; //numberofusers++; } else { // the user is protected System.out.println("@" + user.getScreenName()); } } page++; //System.out.println(page); } while (users.size() != 0 && page < numberofpages); } } catch (Exception ex) { System.out.println(ex.getMessage()); } }
From source file:twitter4j.examples.user.SearchUsers.java
License:Apache License
/** * Usage: java twitter4j.examples.user.SearchUsers [query] * * @param args message//from w w w . j a v a2s .c o m */ public static void main(String[] args) { if (args.length < 1) { System.out.println("Usage: java twitter4j.examples.user.SearchUsers [query]"); System.exit(-1); } try { Twitter twitter = new TwitterFactory().getInstance(); int page = 1; ResponseList<User> users; do { users = twitter.searchUsers(args[0], page); for (User user : users) { if (user.getStatus() != null) { System.out.println("@" + user.getScreenName() + " - " + user.getStatus().getText()); } else { // the user is protected System.out.println("@" + user.getScreenName()); } } page++; } while (users.size() != 0 && page < 50); System.out.println("done."); System.exit(0); } catch (TwitterException te) { te.printStackTrace(); System.out.println("Failed to search users: " + te.getMessage()); System.exit(-1); } }
From source file:User.SearchUsers.java
License:Apache License
public ResponseList<User> Twitters(String name) { try {/* ww w .j a v a 2s . c o m*/ Twitter twitter = builder.twitter; int page = 1; ResponseList<User> users; do { users = twitter.searchUsers(name, page); page++; } while (users.size() != 0 && page < 2); return users; } catch (TwitterException te) { te.printStackTrace(); } return null; }