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

Displaying data on the UI

As we now have the data prepared, it will be super easy to plug it in to our existing RecyclerView population code.

Recall our initial RecyclerView population code that contained mock data:

Observable.just(        new StockUpdate("GOOGLE", 12.43, new Date()),        new StockUpdate("APPL", 645.1, new Date()),        new StockUpdate("TWTR", 1.43, new Date()))        .subscribe(stockUpdate -> {            Log.d("APP", "New update " + stockUpdate.getStockSymbol());            stockDataAdapter.add(stockUpdate);        });

Here, the last part (.subscribe()) can be taken and plugged in to the existing flow we have just created:

yahooService.yqlQuery(query, env)        .subscribeOn(Schedulers.io())        .toObservable()        .map(r -> r.getQuery().getResults().getQuote()) .flatMap(r -> Observable. ...

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