Skip to content

Instantly share code, notes, and snippets.

@baggednismo
Last active May 27, 2020 12:43
Show Gist options
  • Save baggednismo/fea80879eaa4d49a8e92505ea30166bc to your computer and use it in GitHub Desktop.
Save baggednismo/fea80879eaa4d49a8e92505ea30166bc to your computer and use it in GitHub Desktop.
...
pager.registerOnPageChangeCallback(object : OnPageChangeCallback() {
override fun onPageSelected(position: Int) {
super.onPageSelected(position)
// Clear the messages so that every time an item has changed
// we reset our handler.
handler.removeMessages(0)
if (position == 0) btnBack.visibility = View.GONE
else btnBack.visibility = View.VISIBLE
val runnable = Runnable { pager.currentItem = position + 1 }
if (position < pager.adapter?.itemCount ?: 0) {
handler.postDelayed(runnable, timerDelay)
}
}
})
...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment