if (page > 0)
query.setMaxId(maxId);
query.setPage(page + 1);
query.setRpp(hitsPerPage);
QueryResult res = twitter.search(query);
// is res.getTweets() sorted?
for (Object o : res.getTweets()) {
Tweet twe = (Tweet) o;
// determine maxId in the first page
if (page == 0 && maxId < twe.getId())
maxId = twe.getId();
if (maxMillis < twe.getCreatedAt().getTime())
maxMillis = twe.getCreatedAt().getTime();
if (twe.getCreatedAt().getTime() + 1000 < lastMaxCreateTime)
breakPaging = true;
else {
String userName = twe.getFromUser().toLowerCase();
JUser user = userMap.get(userName);
if (user == null) {
user = new JUser(userName).init(twe);
userMap.put(userName, user);
}
result.add(new JTweet(twe, user));
}
}
// minMillis could force us to leave earlier than defined by maxPages
// or if resulting tweets are less then request (but -10 because of twitter strangeness)
if (breakPaging || res.getTweets().size() < hitsPerPage - 10)
break;
}
return maxMillis;
}