Created
August 27, 2019 13:48
-
-
Save BetterProgramming/84e8f934896d52172ca7dd623abf0322 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
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