Created
January 24, 2018 02:41
-
-
Save amyu/ec07fad04f0ac1a5beeab7f6783cb157 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 NonSwipeViewPager @JvmOverloads constructor( | |
context: Context, | |
attrs: AttributeSet? = null, | |
defStyleAttr: Int = 0 | |
) : ViewPager(context, attrs) { | |
override fun onInterceptTouchEvent(ev: MotionEvent?): Boolean = false | |
override fun onTouchEvent(ev: MotionEvent?): Boolean = false | |
override fun onKeyDown(keyCode: Int, event: KeyEvent?): Boolean = | |
when (event?.action) { | |
KeyEvent.KEYCODE_DPAD_LEFT, KeyEvent.KEYCODE_DPAD_RIGHT -> false | |
else -> super.onKeyDown(keyCode, event) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment