package cc.shinichi.library.view
|
|
import android.content.Context
|
import android.util.AttributeSet
|
import android.view.MotionEvent
|
import androidx.viewpager.widget.ViewPager
|
|
/**
|
* Hacky fix for Issue #4 and
|
* http://code.google.com/p/android/issues/detail?id=18990
|
*
|
*
|
* ScaleGestureDetector seems to mess up the touch events, which means that
|
* ViewGroups which make use of onInterceptTouchEvent throw a lot of
|
* IllegalArgumentException: pointerIndex out of range.
|
*
|
*
|
* There's not much I can do in my code for now, but we can mask the result by
|
* just catching the problem and ignoring it.
|
*
|
* @author 工藤
|
* @email qinglingou@gmail.com
|
*/
|
class HackyViewPager : ViewPager {
|
|
constructor(context: Context) : super(context)
|
|
constructor(context: Context, attrs: AttributeSet?) : super(context, attrs) {}
|
|
override fun onInterceptTouchEvent(ev: MotionEvent): Boolean {
|
return try {
|
super.onInterceptTouchEvent(ev)
|
} catch (e: IllegalArgumentException) {
|
false
|
}
|
}
|
}
|