Skip to content

Instantly share code, notes, and snippets.

@BetterProgramming
Created August 27, 2019 13:55
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save BetterProgramming/c871a11983d128ffd81dd4f5d8c33990 to your computer and use it in GitHub Desktop.
Save BetterProgramming/c871a11983d128ffd81dd4f5d8c33990 to your computer and use it in GitHub Desktop.
private fun startAnimate() {
compositeDisposable.add(Observable
.interval(0, 1, TimeUnit.SECONDS)
.flatMap {
return@flatMap Observable
.interval(0, 100, TimeUnit.MILLISECONDS)
.take(image.size.toLong())
}
.map { it.toInt() }
.doAfterNext { if (it == (image.size - 1)) control *= -1 }
.map { if (control == 1) it else image.size - 1 - it }
.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