Created
June 28, 2019 11:48
-
-
Save saddahussain/1b3a74bcb2f327b4f4a86fd436e75e5c 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 SwipeLockableViewPager(context: Context, attrs: AttributeSet) : ViewPager(context, attrs) { | |
private var swipeEnabled = false | |
override fun onTouchEvent(event: MotionEvent): Boolean { | |
return when (swipeEnabled) { | |
true -> super.onTouchEvent(event) | |
false -> false | |
} | |
} | |
override fun onInterceptTouchEvent(event: MotionEvent): Boolean { | |
return when (swipeEnabled) { | |
true -> super.onInterceptTouchEvent(event) | |
false -> false | |
} | |
} | |
fun setSwipePagingEnabled(swipeEnabled: Boolean) { | |
this.swipeEnabled = swipeEnabled | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment