baoyongzhang / android-PullRefreshLayout

This component like SwipeRefreshLayout, it is more beautiful than SwipeRefreshLayout.
MIT License
2.07k stars 517 forks source link

pointerIndex out of range #46

Open vytautokas opened 6 years ago

vytautokas commented 6 years ago

Fatal Exception: java.lang.IllegalArgumentException: pointerIndex out of range at android.view.MotionEvent.nativeGetAxisValue(MotionEvent.java) at android.view.MotionEvent.getY(MotionEvent.java:2431) at android.support.v4.view.MotionEventCompat.getY(MotionEventCompat.java:521) at com.baoyz.widget.PullRefreshLayout.onTouchEvent(PullRefreshLayout.java:324) at android.view.View.dispatchTouchEvent(View.java:10920) at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2810) at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2512) at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2812) at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2527) at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2812) at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2527) at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2812) at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2527) at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2812) at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2527) at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2812) at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2527) at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2812) at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2527) at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2812) at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2527) at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2812) at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2527) at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2812) at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2527) at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2812) at android.view.ViewGroup.cancelAndClearTouchTargets(ViewGroup.java:2662) at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2368) at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2842) at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2469) at com.android.internal.policy.DecorView.superDispatchTouchEvent(DecorView.java:623) at com.android.internal.policy.PhoneWindow.superDispatchTouchEvent(PhoneWindow.java:1906) at android.app.Activity.dispatchTouchEvent(Activity.java:3247) at android.support.v7.view.WindowCallbackWrapper.dispatchTouchEvent(WindowCallbackWrapper.java:68) at com.android.internal.policy.DecorView.dispatchTouchEvent(DecorView.java:585) at android.view.View.dispatchPointerEvent(View.java:11149) at android.view.ViewRootImpl$ViewPostImeInputStage.processPointerEvent(ViewRootImpl.java:5227) at android.view.ViewRootImpl$ViewPostImeInputStage.onProcess(ViewRootImpl.java:5076) at android.view.ViewRootImpl$InputStage.deliver(ViewRootImpl.java:4580) at android.view.ViewRootImpl$InputStage.onDeliverToNext(ViewRootImpl.java:4633) at android.view.ViewRootImpl$InputStage.forward(ViewRootImpl.java:4599) at android.view.ViewRootImpl$AsyncInputStage.forward(ViewRootImpl.java:4736) at android.view.ViewRootImpl$InputStage.apply(ViewRootImpl.java:4607) at android.view.ViewRootImpl$AsyncInputStage.apply(ViewRootImpl.java:4793) at android.view.ViewRootImpl$InputStage.deliver(ViewRootImpl.java:4580) at android.view.ViewRootImpl$InputStage.onDeliverToNext(ViewRootImpl.java:4633) at android.view.ViewRootImpl$InputStage.forward(ViewRootImpl.java:4599) at android.view.ViewRootImpl$InputStage.apply(ViewRootImpl.java:4607) at android.view.ViewRootImpl$InputStage.deliver(ViewRootImpl.java:4580) at android.view.ViewRootImpl.deliverInputEvent(ViewRootImpl.java:7210) at android.view.ViewRootImpl.doProcessInputEvents(ViewRootImpl.java:7142) at android.view.ViewRootImpl.enqueueInputEvent(ViewRootImpl.java:7103) at android.view.ViewRootImpl$WindowInputEventReceiver.onInputEvent(ViewRootImpl.java:7321) at android.view.InputEventReceiver.dispatchInputEvent(InputEventReceiver.java:185) at android.os.MessageQueue.nativePollOnce(MessageQueue.java) at android.os.MessageQueue.next(MessageQueue.java:323) at android.os.Looper.loop(Looper.java:136) at android.app.ActivityThread.main(ActivityThread.java:6823) at java.lang.reflect.Method.invoke(Method.java) at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1563) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1451)

endy-s commented 6 years ago

Got this too. It was reported by Crashlytics in the production app, so I'm not sure how to reproduce it.

endy-s commented 6 years ago

having in mind the log, it seems to be related to the ACTION_CANCEL part of the onTouchEvent method.

Probably changing the code at line 324 to:

if (pointerIndex > -1 && MotionEventCompat.getPointerCount(ev)) {
    final float y = MotionEventCompat.getY(ev, pointerIndex);
    ... continue the processing ...
} else {
    return false;
}

Will prevent this kind of crash to happen.

I know you don't commit nothing to this repo since 2015 @baoyongzhang , but it would be great if you just add this preventing line :)

Thanks in advance!

vytautokas commented 6 years ago

Is there any possibility that issue will be solved ?

Spettacolo83 commented 5 years ago

I got the same error too. Please @baoyongzhang can you fix the code as @endy-s suggested. It would be great! Thank you for your library though!

Spettacolo83 commented 5 years ago

Any news? I'm still getting this error in production? Can we help you to fix this issue? Let us know! Thanks!