List of usage examples for twitter4j Paging count
int count
To view the source code for twitter4j Paging count.
Click Source Link
From source file:it.baywaylabs.jumpersumo.twitter.TwitterListener.java
License:Open Source License
/** * This method is called when invoke <b>execute()</b>.<br /> * Do not invoke manually. Use: <i>new TwitterListener().execute("");</i> * * @param params//www. ja v a 2 s . c om */ @Override protected List<String> doInBackground(String... params) { Intelligence ai = new Intelligence(); try { User user = twitter.verifyCredentials(); Paging paging; if (idLastTwit != 0) paging = new Paging(idLastTwit + 1); else paging = new Paging(); paging.count(100); statuses = twitter.getMentionsTimeline(paging); if (statuses.size() != 0 && statuses != null) { Log.d(TAG, "Showing @" + user.getScreenName() + "'s mentions:"); Log.d(TAG, statuses.get(0).getText() + "-- ID: " + statuses.get(0).getId()); if (!"".equals(statuses.get(0).getText()) && licenses.size() == 0) { extractCommand(ai, statuses); Log.d(TAG, "Non ho licenze attive!"); } else if (!"".equals(statuses.get(0).getText()) && licenses.size() > 0 && f.boolContainsIgnoreCase(licenses, String.valueOf(statuses.get(0).getUser().getId()))) { extractCommand(ai, statuses); Log.i(TAG, "Seguo la lista delle licenze: " + licenses.toString()); } else { publishProgress(false); } if (deviceController != null) { Random r = new Random(); Interpreter interp = new Interpreter(deviceController); for (int i = 0; i < execute.size(); i++) { Log.d(TAG, "Seguenza istruzioni rilevate: " + execute.toString()); if (execute.size() >= 1 && "EXECUTE".equals(execute.get(i)) && f.getUrls(statuses.get(0).getText()).size() != 0) { String url = statuses.get(0).getURLEntities()[0].getExpandedURL(); // String url = f.getUrls(statuses.get(0).getText()).get(0); File folder = new File(Constants.DIR_ROBOT); Log.d(TAG, "URL Expanded: " + url); if (downloadFileUrl(url, folder)) { FileFilter ff = new FileFilter(); File[] list = folder.listFiles(ff); Log.e(TAG, "Lista file: " + list.length); if (list != null && list.length >= 1) { if (list[0].getName().endsWith(".csv") || list[0].getName().endsWith(".txt")) { String commandsList = ""; try { commandsList = f.getStringFromFile(list[0].getPath()); } catch (Exception e) { e.printStackTrace(); } Log.d(TAG, "Lista comandi: " + commandsList); interp.doListCommands(commandsList); list[0].delete(); if (i == execute.size() - 1) { try { StatusUpdate reply = new StatusUpdate( ai.actionAnswer(execute.get(i)).get( r.nextInt(ai.actionAnswer(execute.get(i)).size())) + "@" + statuses.get(0).getUser().getScreenName()); reply.setInReplyToStatusId(statuses.get(0).getId()); twitter.updateStatus(reply); } catch (TwitterException te) { Log.e(TAG, "Twitter Post Error: " + te.getMessage()); } } } } } } else if (execute.size() >= 1 && "PHOTO".equals(execute.get(i))) { // Download immagine e post nel tweet if (interp.doCommand(execute.get(i)) == 0) { String result = FTPDownloadFile(ip_host, 21, "anonymous", "", context); if (i == execute.size() - 1 && !"".equals(result)) { try { StatusUpdate reply = new StatusUpdate(ai.actionAnswer(execute.get(i)) .get(r.nextInt(ai.actionAnswer(execute.get(i)).size())) + "@" + statuses.get(0).getUser().getScreenName()); reply.setInReplyToStatusId(statuses.get(0).getId()); File image = new File(Constants.DIR_ROBOT_IMG + "/" + result); Log.d(TAG, "Nome File immagine: " + image.getPath()); reply.media(image); twitter.updateStatus(reply); image.delete(); } catch (TwitterException te) { Log.e(TAG, "Twitter Post Error: " + te.getMessage()); } } } } else if (execute.size() >= 1 && !"PHOTO".equals(execute.get(i)) && !"EXECUTE".equals(execute.get(i))) { if (interp.doCommand(execute.get(i)) == 0) { if (i == execute.size() - 1) { try { StatusUpdate reply = new StatusUpdate(ai.actionAnswer(execute.get(i)) .get(r.nextInt(ai.actionAnswer(execute.get(i)).size())) + "@" + statuses.get(0).getUser().getScreenName()); reply.setInReplyToStatusId(statuses.get(0).getId()); twitter.updateStatus(reply); } catch (TwitterException te) { Log.e(TAG, "Twitter Post Error: " + te.getMessage()); } } } } } } } Log.d(TAG, "ready exit"); } catch (TwitterException te) { te.printStackTrace(); Log.e(TAG, "Failed to get timeline: " + te.getMessage()); } return execute; }
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;//w ww .j ava 2s . c o m } 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"); }