kaelaela / VerticalViewPager

Vertically ViewPager and vertically transformer for Android.
Apache License 2.0
1.23k stars 214 forks source link

java.lang.IllegalArgumentException: pointerIndex out of range #24

Open WeDoX opened 6 years ago

WeDoX commented 6 years ago
 java.lang.IllegalArgumentException: pointerIndex out of range
   at android.view.MotionEvent.nativeGetAxisValue(Native Method)
   at android.view.MotionEvent.getX(MotionEvent.java:2139)
   at android.support.v4.view.ViewPager.onInterceptTouchEvent(ViewPager.java:2064)

my answer:

 @Override
    public boolean onInterceptTouchEvent(MotionEvent event) {
        try {
            boolean intercept = super.onInterceptTouchEvent(swapTouchEvent(event));
            //If not intercept, touch event should not be swapped.
            swapTouchEvent(event);
            return intercept;
        } catch (IllegalArgumentException e) {
            e.printStackTrace();
        }
        return false;
    }

    @Override
    public boolean onTouchEvent(MotionEvent ev) {
        try {
            return super.onTouchEvent(swapTouchEvent(ev));
        } catch (IllegalArgumentException e) {
            e.printStackTrace();
        }
        return false;
    }