Last active
August 29, 2015 14:26
-
-
Save marcoRS/53e2eb187ccfc324b6db to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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