Bug? Making a zoom gesture between two edittexts causes an error to exit the program

cxbs

Active Member
Licensed User
Longtime User
Hello everyone!

I don't know if it is caused by the ahviewpager class
Just a few more zoom gestures will cause the following error

java.lang.IllegalArgumentException: pointerIndex out of range
at android.view.MotionEvent.nativeGetAxisValue(Native Method)
at android.view.MotionEvent.getX(MotionEvent.java:2367)
at androidx.viewpager.widget.ViewPager.onInterceptTouchEvent(ViewPager.java:2072)
at de.amberhome.viewpager.CustomViewPager.onInterceptTouchEvent(CustomViewPager.java:34)
at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2629)
at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:3082)
at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2775)
at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:3082)
at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2775)
at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:3082)
at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2775)
at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:3082)
at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2775)
at com.android.internal.policy.DecorView.superDispatchTouchEvent(DecorView.java:487)
at com.android.internal.policy.PhoneWindow.superDispatchTouchEvent(PhoneWindow.java:1851)
at android.app.Activity.dispatchTouchEvent(Activity.java:4049)
at com.android.internal.policy.DecorView.dispatchTouchEvent(DecorView.java:445)
at android.view.View.dispatchPointerEvent(View.java:13699)
at android.view.ViewRootImpl$ViewPostImeInputStage.processPointerEvent(ViewRootImpl.java:5571)
at android.view.ViewRootImpl$ViewPostImeInputStage.onProcess(ViewRootImpl.java:5371)
at android.view.ViewRootImpl$InputStage.deliver(ViewRootImpl.java:4872)
at android.view.ViewRootImpl$InputStage.onDeliverToNext(ViewRootImpl.java:4925)
at android.view.ViewRootImpl$InputStage.forward(ViewRootImpl.java:4891)
at android.view.ViewRootImpl$AsyncInputStage.forward(ViewRootImpl.java:5031)
at android.view.ViewRootImpl$InputStage.apply(ViewRootImpl.java:4899)
at android.view.ViewRootImpl$AsyncInputStage.apply(ViewRootImpl.java:5088)
at android.view.ViewRootImpl$InputStage.deliver(ViewRootImpl.java:4872)
at android.view.ViewRootImpl$InputStage.onDeliverToNext(ViewRootImpl.java:4925)
at android.view.ViewRootImpl$InputStage.forward(ViewRootImpl.java:4891)
at android.view.ViewRootImpl$InputStage.apply(ViewRootImpl.java:4899)
at android.view.ViewRootImpl$InputStage.deliver(ViewRootImpl.java:4872)
at android.view.ViewRootImpl.deliverInputEvent(ViewRootImpl.java:7644)
at android.view.ViewRootImpl.doProcessInputEvents(ViewRootImpl.java:7613)
at android.view.ViewRootImpl.enqueueInputEvent(ViewRootImpl.java:7574)
at android.view.ViewRootImpl$WindowInputEventReceiver.onInputEvent(ViewRootImpl.java:7774)
at android.view.InputEventReceiver.dispatchInputEvent(InputEventReceiver.java:250)
at android.view.InputEventReceiver.nativeConsumeBatchedInputEvents(Native Method)
at android.view.InputEventReceiver.consumeBatchedInputEvents(InputEventReceiver.java:213)
at android.view.ViewRootImpl.doConsumeBatchedInput(ViewRootImpl.java:7720)
at android.view.ViewRootImpl$ConsumeBatchedInputRunnable.run(ViewRootImpl.java:7798)
at android.view.Choreographer$CallbackRecord.run(Choreographer.java:1031)
at android.view.Choreographer.doCallbacks(Choreographer.java:854)
at android.view.Choreographer.doFrame(Choreographer.java:782)
at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:1016)
at android.os.Handler.handleCallback(Handler.java:883)
at android.os.Handler.dispatchMessage(Handler.java:100)
at android.os.Looper.loop(Looper.java:214)
at android.app.ActivityThread.main(ActivityThread.java:7520)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:539)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:950)

zoomerr.jpg
 

Attachments

  • a.zip
    8.8 KB · Views: 201

corwin42

Expert
Licensed User
Longtime User
This is the code in the library:

Java:
    @Override
    public boolean onInterceptTouchEvent(MotionEvent event) {
        if (this.enabled) {
            return super.onInterceptTouchEvent(event);
        }
 
        return false;
    }

So it just calls the method of the Android Viewpager class when the View is enabled.

So the error happens somewhere deeper in the Google code of androidx.viewpager.widget.ViewPager.onInterceptTouchEvent

I guess there is nothing I can do here.
 

cxbs

Active Member
Licensed User
Longtime User
This is the code in the library:

Java:
    @Override
    public boolean onInterceptTouchEvent(MotionEvent event) {
        if (this.enabled) {
            return super.onInterceptTouchEvent(event);
        }

        return false;
    }

So it just calls the method of the Android Viewpager class when the View is enabled.

So the error happens somewhere deeper in the Google code of androidx.viewpager.widget.ViewPager.onInterceptTouchEvent

I guess there is nothing I can do here.

Oh, thank you very much for your help. I can only try my best to avoid it!
 

cxbs

Active Member
Licensed User
Longtime User
Solutions found online:

It's the android ViewPager's bug
stackoverflow's report: http://stackoverflow.com/questions/6919292/pointerindex-out-of-range-android-multitouch
android's report: http://code.google.com/p/android/issues/detail?id=18990

My simple's method to fix this bug:
You can extends the ViewPager class, your own ViewPager should override the onTouchEvent and the onInterceptTouchEvent methods, and try-catch the IllegalArgumentException exception. Then use your own ViewPager class in layout or others you want.

Examples:

Java:
/** Custom your own ViewPager to extends support ViewPager. java source: */
/** Created by azi on 2013-6-21.  */
 
package com.chaokuadi.android.support.view;
 
import android.content.Context;
import android.util.AttributeSet;
import android.view.MotionEvent;
 
public class ViewPagerFixed extends android.support.v4.view.ViewPager {
 
    public ViewPagerFixed(Context context) {
        super(context);
    }
 
    public ViewPagerFixed(Context context, AttributeSet attrs) {
        super(context, attrs);
    }
 
    @Override
    public boolean onTouchEvent(MotionEvent ev) {
        try {
            return super.onTouchEvent(ev);
        } catch (IllegalArgumentException ex) {
            ex.printStackTrace();
        }
        return false;
    }
 
    @Override
    public boolean onInterceptTouchEvent(MotionEvent ev) {
        try {
            return super.onInterceptTouchEvent(ev);
        } catch (IllegalArgumentException ex) {
            ex.printStackTrace();
        }
        return false;
    }
}


/** ViewPager layout */
<?xml version="1.0" encoding="utf-8"?>
<com.chaokuaidi.android.support.view.ViewPagerFixed xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/pager"
android:layout_width="fill_parent"
android:layout_height="fill_parent" />
 

cxbs

Active Member
Licensed User
Longtime User
This is the code in the library:

Java:
    @Override
    public boolean onInterceptTouchEvent(MotionEvent event) {
        if (this.enabled) {
            return super.onInterceptTouchEvent(event);
        }

        return false;
    }

So it just calls the method of the Android Viewpager class when the View is enabled.

So the error happens somewhere deeper in the Google code of androidx.viewpager.widget.ViewPager.onInterceptTouchEvent

I guess there is nothing I can do here.

Hello!

Can you replace it with the following code? Thank you very much!

Java:
    @Override
public boolean onInterceptTouchEvent(MotionEvent ev) {
        try {
            return super.onInterceptTouchEvent(ev);
        } catch (IllegalArgumentException ex) {
            ex.printStackTrace();
        }
        return false;
    }
 
Last edited:
Top