mirror of
https://github.com/SimpleMobileTools/Simple-Notes.git
synced 2025-06-05 17:00:23 +02:00
add a custom viewpager
This commit is contained in:
@ -0,0 +1,36 @@
|
||||
package com.simplemobiletools.notes.views
|
||||
|
||||
import android.content.Context
|
||||
import android.support.v4.view.ViewPager
|
||||
import android.util.AttributeSet
|
||||
import android.view.MotionEvent
|
||||
|
||||
// we are creating a custom viewpager just to fix "pointerIndex out of range" exception at onInterceptTouchEvent
|
||||
class MyViewPager : ViewPager {
|
||||
|
||||
constructor(context: Context) : super(context) {
|
||||
}
|
||||
|
||||
constructor(context: Context, attrs: AttributeSet) : super(context, attrs) {
|
||||
}
|
||||
|
||||
override fun onInterceptTouchEvent(ev: MotionEvent): Boolean {
|
||||
try {
|
||||
return super.onInterceptTouchEvent(ev)
|
||||
} catch (ex: IllegalArgumentException) {
|
||||
ex.printStackTrace()
|
||||
}
|
||||
|
||||
return false
|
||||
}
|
||||
|
||||
override fun onTouchEvent(ev: MotionEvent): Boolean {
|
||||
try {
|
||||
return super.onTouchEvent(ev)
|
||||
} catch (ex: IllegalArgumentException) {
|
||||
ex.printStackTrace()
|
||||
}
|
||||
|
||||
return false
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user