private void initStream() { tweetsFlowRegulator = TweetsFlowRegulator.newInstance(listener); twitterStream.addListener( new StatusListener() { @Override public void onStatus(Status status) { tweetsFlowRegulator.addTweet(status); } @Override public void onDeletionNotice(StatusDeletionNotice statusDeletionNotice) { // No-op } @Override public void onTrackLimitationNotice(int numberOfLimitedStatuses) { // No-op } @Override public void onScrubGeo(long userId, long upToStatusId) { // No-op } @Override public void onStallWarning(StallWarning warning) { Log.w(warning); } @Override public void onException(Exception ex) { Log.e(ex); } }); }
@Override public void update() { if (running) { return; } running = true; tweetsFlowRegulator.startTweetPicker(); twitterStream.filter(query); }
@Override public void stop() { tweetsFlowRegulator.stopTweetPicker(); twitterStream.cleanUp(); running = false; }