Created
March 20, 2018 12:10
-
-
Save titoaesj/5bf52547ce779c6987dc24bc5a52fb64 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
class CustomDisableSwapViewPager(context: Context, attrs: AttributeSet) : ViewPager(context, attrs) { | |
var enabled: Boolean? | |
init { | |
this.enabled = false | |
} | |
override fun onTouchEvent(event: MotionEvent): Boolean { | |
return if (this.enabled!!) { | |
super.onTouchEvent(event) | |
} else false | |
} | |
override fun onInterceptTouchEvent(event: MotionEvent): Boolean { | |
return if (this.enabled!!) { | |
super.onInterceptTouchEvent(event) | |
} else false | |
return super.isClickable() | |
} | |
fun isSwipEnabled(enabled: Boolean) { | |
this.enabled = enabled | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment