add a helper extension for listening to viewpager page changes

This commit is contained in:
tibbi 2018-02-28 12:11:56 +01:00
parent c333579f26
commit c788aef4aa
2 changed files with 17 additions and 1 deletions

View file

@ -6,7 +6,7 @@ buildscript {
propMinSdkVersion = 16
propTargetSdkVersion = propCompileSdkVersion
propVersionCode = 1
propVersionName = '3.13.19'
propVersionName = '3.13.20'
kotlin_version = '1.2.21'
support_libs = '27.0.2'
}

View file

@ -0,0 +1,16 @@
package com.simplemobiletools.commons.extensions
import android.support.v4.view.ViewPager
fun ViewPager.onPageChangeListener(pageChangedAction: (newPosition: Int) -> Unit) =
addOnPageChangeListener(object : ViewPager.OnPageChangeListener {
override fun onPageScrollStateChanged(state: Int) {
}
override fun onPageScrolled(position: Int, positionOffset: Float, positionOffsetPixels: Int) {
}
override fun onPageSelected(position: Int) {
pageChangedAction(position)
}
})