Skip to content

Instantly share code, notes, and snippets.

View shaohui10086's full-sized avatar
🎯
Focusing

邵辉Vista shaohui10086

🎯
Focusing
View GitHub Profile
@shaohui10086
shaohui10086 / rxjava_vs_coroutines.kt
Last active November 18, 2019 05:51
RxJava vs Coroutines
fun rxJavaExample(folders: List<File>) {
Observable.from(folders)
.flatMap((folder) -> { Observable.from(folder.listFiles()) })
.filter( (file) -> { file.getName().endsWith(".png") })
.map( (file) -> { getBitmapFromFile(file) })
.subscribeOn(Schedulers.io())
.observeOn(AndroidSchedulers.mainThread())
.subscribe((Action1) (bitmap) -> { imageCollectorView.addImage(bitmap) });
}