Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
// how to use
val timer = Timer()
timer.schedule(RemindTask(imageList.size, pager), 0, 5000)
// handler
inner class RemindTask() : TimerTask() {
private var numberOfPages = 0
private lateinit var mViewPager: ViewPager
private var page = 0
constructor(numberOfPages: Int, mViewPager: ViewPager) : this() {
this.numberOfPages = numberOfPages
this.mViewPager = mViewPager
}
override fun run() {
this@ItemDetailActivity.runOnUiThread({
if (page > numberOfPages) {
mViewPager.currentItem = 0
page = 0
} else {
mViewPager.currentItem = page++
}
})
}
}
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.