public void getTrailers(long movieId) { this.movieId = movieId; if (realmWatcher.isWatching()) return; realmWatcher.watch(this); addSubscription( movieDBWebService .getTrailers(movieId, apiKey) .subscribeOn(Schedulers.io()) .observeOn(Schedulers.computation()) .map(TrailersResponse::results) .flatMap(trailers -> realmWrapper.mapTrailers(trailers, movieId)) .observeOn(AndroidSchedulers.mainThread()) .subscribe( realmWrapper::performBatchWrite, throwable -> { getView() .showError( error, () -> { getTrailers(movieId); return null; }); })); }
@Override public RealmResults<RealmTrailer> getQuery() { return realmWrapper.queryTrailers(movieId); }