Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
private fun startAnimate() {
RxJavaPlugins.setErrorHandler { /*Catch InterruptedException*/ }
compositeDisposable.add(Observable
.create<Int> { emitter ->
while (true) {
if (control == 1) {
for (x in 0 until image.size) {
emitter.onNext(x)
Thread.sleep(100)
}
} else {
for (x in (image.size - 1) downTo 0) {
emitter.onNext(x)
Thread.sleep(100)
}
}
control *= -1
Thread.sleep(300)
}
}
.subscribeOn(Schedulers.io())
.observeOn(AndroidSchedulers.mainThread())
.subscribe { showImage(it) })
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.