Skip to content

Instantly share code, notes, and snippets.

@marcoRS
Last active August 29, 2015 14:26
Show Gist options
  • Save marcoRS/53e2eb187ccfc324b6db to your computer and use it in GitHub Desktop.
Save marcoRS/53e2eb187ccfc324b6db to your computer and use it in GitHub Desktop.
// Not working...
.getVolumesByLanguageCode(database, "ENG")
.subscribeOn(Schedulers.io())
.observeOn(AndroidSchedulers.mainThread())
.flatMap(new Func1<List<Volume>, Observable<Volume>>() {
@Override public Observable<Volume> call(List<Volume> volumes) {
return Observable.from(volumes);
}
})
.map(new Func1<Volume, String>() {
@Override public String call(Volume volume) {
return volume.name;
}
})
.toList()
.subscribe(new Observer<List<String>>() {
@Override public void onCompleted() {
Log.i("VolumesByLanguage", "onCompleted");
}
@Override public void onError(Throwable e) {
UiUtils.toast("Error occurred no bibles found.", getActivity());
}
@Override public void onNext(List<String> volumes) {
bibles = volumes;
populateListView();
}
});
// Working....
FileUtils.getVolumesByLanguageCode(database, "ENG")
.subscribeOn(Schedulers.io())
.observeOn(AndroidSchedulers.mainThread())
.subscribe(new Observer<List<Volume>>() {
@Override public void onCompleted() {
Log.i("VolumesByLanguage", "onCompleted");
}
@Override public void onError(Throwable e) {
UiUtils.toast("Error occurred no bibles found.", getActivity());
}
@Override public void onNext(List<Volume> volumes) {
rx.Observable.from(volumes)
.observeOn(AndroidSchedulers.mainThread())
.map(s -> s.name)
.toSortedList()
.subscribe(titles -> {
bibles = titles;
populateListView();
});
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment