oxoooo / pull-back-layout

Pull down to finish an Activity.
www.oxo.ooo
MIT License
541 stars 65 forks source link

Crashes on zoomin and zoomout used with Touch Image View #4

Closed hardikamal closed 8 years ago

hardikamal commented 8 years ago

App crashes if zoomin then zoomout and again zoomin...

java.lang.ArrayIndexOutOfBoundsException: length=1; index=1
                                                                        at android.support.v4.widget.ViewDragHelper.shouldInterceptTouchEvent(ViewDragHelper.java:1014)
                                                                        at ooo.oxo.library.widget.PullBackLayout.onInterceptTouchEvent(PullBackLayout.java:67)
                                                                        at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:1960)
                                                                        at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2407)
                                                                        at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2106)
                                                                        at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2407)
                                                                        at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2106)
                                                                        at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2407)
                                                                        at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2106)
                                                                        at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2407)
                                                                        at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2106)
                                                                        at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2407)
                                                                        at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2106)
                                                                        at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2407)
                                                                        at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2106)
                                                                        at com.android.internal.policy.impl.PhoneWindow$DecorView.superDispatchTouchEvent(PhoneWindow.java:2369)
                                                                        at com.android.internal.policy.impl.PhoneWindow.superDispatchTouchEvent(PhoneWindow.java:1719)
                                                                        at android.app.Activity.dispatchTouchEvent(Activity.java:2752)
                                                                        at android.support.v7.view.WindowCallbackWrapper.dispatchTouchEvent(WindowCallbackWrapper.java:60)
                                                                        at com.android.internal.policy.impl.PhoneWindow$DecorView.dispatchTouchEvent(PhoneWindow.java:2330)
                                                                        at android.view.View.dispatchPointerEvent(View.java:8671)
                                                                        at android.view.ViewRootImpl$ViewPostImeInputStage.processPointerEvent(ViewRootImpl.java:4193)
                                                                        at android.view.ViewRootImpl$ViewPostImeInputStage.onProcess(ViewRootImpl.java:4059)
                                                                        at android.view.ViewRootImpl$InputStage.deliver(ViewRootImpl.java:3604)
                                                                        at android.view.ViewRootImpl$InputStage.onDeliverToNext(ViewRootImpl.java:3657)
                                                                        at android.view.ViewRootImpl$InputStage.forward(ViewRootImpl.java:3623)
                                                                        at android.view.ViewRootImpl$AsyncInputStage.forward(ViewRootImpl.java:3740)
                                                                        at android.view.ViewRootImpl$InputStage.apply(ViewRootImpl.java:3631)
                                                                        at android.view.ViewRootImpl$AsyncInputStage.apply(ViewRootImpl.java:3797)
                                                                        at android.view.ViewRootImpl$InputStage.deliver(ViewRootImpl.java:3604)
                                                                        at android.view.ViewRootImpl$InputStage.onDeliverToNext(ViewRootImpl.java:3657)
                                                                        at android.view.ViewRootImpl$InputStage.forward(ViewRootImpl.java:3623)
                                                                        at android.view.ViewRootImpl$InputStage.apply(ViewRootImpl.java:3631)
                                                                        at android.view.ViewRootImpl$InputStage.deliver(ViewRootImpl.java:3604)
                                                                        at android.view.ViewRootImpl.deliverInputEvent(ViewRootImpl.java:5912)
                                                                        at android.view.ViewRootImpl.doProcessInputEvents(ViewRootImpl.java:5851)
                                                                        at android.view.ViewRootImpl.enqueueInputEvent(ViewRootImpl.java:5822)
                                                                        at android.view.ViewRootImpl$WindowInputEventReceiver.onInputEvent(ViewRootImpl.java:6002)
                                                                        at android.view.InputEventReceiver.dispatchInputEvent(InputEventReceiver.java:192)
                                                                        at android.view.InputEventReceiver.nativeConsumeBatchedInputEvents(Native Method)
                                                                        at android.view.InputEventReceiver.consumeBatchedInputEvents(InputEventReceiver.java:183)
                                                                        at android.view.ViewRootImpl.doConsumeBatchedInput(ViewRootImpl.java:5973)
                                                                        at android.view.ViewRootImpl$ConsumeBatchedInputRunnable.run(ViewRootImpl.java:6025)
                                                                        at android.view.Choreographer$CallbackRecord.run(Choreographer.java:767)
                                                                        at android.view.Choreographer.doCallbacks(Choreographer.java:580)
                                                                        at android.view.Choreographer.doFrame(Choreographer.java:548)
                                                                        at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:753)
                                                                        at android.os.Handler.handleCallback(Handler.java:746)
                                                                        at android.os.Handler.dispatchMessage(Handler.java:95)
                                                                        at android.os.Looper.loop(Looper.java:135)
                                                                        at android.app.ActivityThread.main(ActivityThread.java:5343)
                                                                        at java.lang.reflect.Method.invoke(Native Me
blipinsk commented 8 years ago

:+1: Happens to me as well. If I pinch to zoom-out (to the end -> so the image gets a bit smaller), and then try to move my fingers down (still touching the screen with both fingers), it crashes.

hammerheadmmb29qbartoszlipinski03022016154105

xingrz commented 8 years ago

try https://github.com/oxoooo/touch-image-view

blipinsk commented 8 years ago

I am using it (Pull-back-layout with TouchImageView)

xingrz commented 8 years ago

@blipinsk oh yes, I reproduced this bug.

It seems to be a bug of ViewDragHelper, neither PBL nor TIV.

I'll try to find a way to work around this.

xingrz commented 8 years ago

It happens at

android.support.v4.widget.ViewDragHelper.shouldInterceptTouchEvent(ViewDragHelper.java:1014)

which is

case MotionEvent.ACTION_MOVE: {
    if (mInitialMotionX == null || mInitialMotionY == null) break;

    // First to cross a touch slop over a draggable view wins. Also report edge drags.
    final int pointerCount = MotionEventCompat.getPointerCount(ev);
    for (int i = 0; i < pointerCount; i++) {
        final int pointerId = MotionEventCompat.getPointerId(ev, i);
        final float x = MotionEventCompat.getX(ev, i);
        final float y = MotionEventCompat.getY(ev, i);
        final float dx = x - mInitialMotionX[pointerId];  // <--- HERE!!!
        final float dy = y - mInitialMotionY[pointerId];

        // ...
blipinsk commented 8 years ago

Hi @xingrz, the bug in ViewHelper seems to be fixed in the newest stable version of the Support Library (23.2.1). Would you mind updating it in your library?

xingrz commented 8 years ago

@blipinsk Thank you. PullBackLayout doesn't explicitly depend on a version of Support Library. So just update the dependency of your project to the latest Support Library and it may works.

blipinsk commented 8 years ago

@xingrz oh yea, true, its provided not compile, my bad :smile: thanks

xingrz commented 8 years ago

😉