O'Reilly logo

Reactive Android Programming by Tadas Subonis

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Other improvements

One can notice pretty fast that the rate the Twitter status updates are received at is really fast. To make the UI a little less overcrowded, we can add a simple .sample() method to reduce its rate:

observeTwitterStream(configuration, filterQuery)        .sample(700, TimeUnit.MILLISECONDS)        .map(StockUpdate::create)

With the following line, we make the TwitterStream Observable output an entry every 700 ms instead of flushing everything it receives:

.sample(700, TimeUnit.MILLISECONDS)

Obviously, this way we are losing some data, but for the sake of the exercise, it is a useful approach to cope with the data that keeps overflowing the UI.

Now, another problem is that the stream quickly leaves the user in the current scroll position, ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required