PhotoView DrawerLayout,DrawerLayout ArrayIndexOutOfBoundsException shouldInterceptTouchEvent。 :
03-19 15:32:36.720: E/AndroidRuntime(5284): FATAL EXCEPTION: main
03-19 15:32:36.720: E/AndroidRuntime(5284): java.lang.ArrayIndexOutOfBoundsException: length=1; index=1
03-19 15:32:36.720: E/AndroidRuntime(5284): at android.support.v4.widget.ViewDragHelper.shouldInterceptTouchEvent(ViewDragHelper.java:1004)
03-19 15:32:36.720: E/AndroidRuntime(5284): at android.support.v4.widget.DrawerLayout.onInterceptTouchEvent(DrawerLayout.java:820)
03-19 15:32:36.720: E/AndroidRuntime(5284): at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:1817)
03-19 15:32:36.720: E/AndroidRuntime(5284): at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2174)
03-19 15:32:36.720: E/AndroidRuntime(5284): at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:1917)
03-19 15:32:36.720: E/AndroidRuntime(5284): at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2174)
03-19 15:32:36.720: E/AndroidRuntime(5284): at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:1917)
03-19 15:32:36.720: E/AndroidRuntime(5284): at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2174)
03-19 15:32:36.720: E/AndroidRuntime(5284): at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:1917)
03-19 15:32:36.720: E/AndroidRuntime(5284): at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2174)
03-19 15:32:36.720: E/AndroidRuntime(5284): at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:1917)
03-19 15:32:36.720: E/AndroidRuntime(5284): at com.android.internal.policy.impl.PhoneWindow$DecorView.superDispatchTouchEvent(PhoneWindow.java:1953)
03-19 15:32:36.720: E/AndroidRuntime(5284): at com.android.internal.policy.impl.PhoneWindow.superDispatchTouchEvent(PhoneWindow.java:1405)
03-19 15:32:36.720: E/AndroidRuntime(5284): at android.app.Activity.dispatchTouchEvent(Activity.java:2410)
03-19 15:32:36.720: E/AndroidRuntime(5284): at com.android.internal.policy.impl.PhoneWindow$DecorView.dispatchTouchEvent(PhoneWindow.java:1901)
03-19 15:32:36.720: E/AndroidRuntime(5284): at android.view.View.dispatchPointerEvent(View.java:7421)
03-19 15:32:36.720: E/AndroidRuntime(5284): at android.view.ViewRootImpl.deliverPointerEvent(ViewRootImpl.java:3220)
03-19 15:32:36.720: E/AndroidRuntime(5284): at android.view.ViewRootImpl.deliverInputEvent(ViewRootImpl.java:3165)
03-19 15:32:36.720: E/AndroidRuntime(5284): at android.view.ViewRootImpl.doProcessInputEvents(ViewRootImpl.java:4292)
03-19 15:32:36.720: E/AndroidRuntime(5284): at android.view.ViewRootImpl.enqueueInputEvent(ViewRootImpl.java:4271)
03-19 15:32:36.720: E/AndroidRuntime(5284): at android.view.ViewRootImpl$WindowInputEventReceiver.onInputEvent(ViewRootImpl.java:4363)
03-19 15:32:36.720: E/AndroidRuntime(5284): at android.view.InputEventReceiver.dispatchInputEvent(InputEventReceiver.java:179)
03-19 15:32:36.720: E/AndroidRuntime(5284): at android.view.InputEventReceiver.nativeConsumeBatchedInputEvents(Native Method)
03-19 15:32:36.720: E/AndroidRuntime(5284): at android.view.InputEventReceiver.consumeBatchedInputEvents(InputEventReceiver.java:171)
03-19 15:32:36.720: E/AndroidRuntime(5284): at android.view.ViewRootImpl.doConsumeBatchedInput(ViewRootImpl.java:4342)
03-19 15:32:36.720: E/AndroidRuntime(5284): at android.view.ViewRootImpl$ConsumeBatchedInputRunnable.run(ViewRootImpl.java:4382)
03-19 15:32:36.720: E/AndroidRuntime(5284): at android.view.Choreographer$CallbackRecord.run(Choreographer.java:749)
03-19 15:32:36.720: E/AndroidRuntime(5284): at android.view.Choreographer.doCallbacks(Choreographer.java:562)
03-19 15:32:36.720: E/AndroidRuntime(5284): at android.view.Choreographer.doFrame(Choreographer.java:530)
03-19 15:32:36.720: E/AndroidRuntime(5284): at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:735)
03-19 15:32:36.720: E/AndroidRuntime(5284): at android.os.Handler.handleCallback(Handler.java:725)
03-19 15:32:36.720: E/AndroidRuntime(5284): at android.os.Handler.dispatchMessage(Handler.java:92)
03-19 15:32:36.720: E/AndroidRuntime(5284): at android.os.Looper.loop(Looper.java:137)
03-19 15:32:36.720: E/AndroidRuntime(5284): at android.app.ActivityThread.main(ActivityThread.java:5039)
03-19 15:32:36.720: E/AndroidRuntime(5284): at java.lang.reflect.Method.invokeNative(Native Method)
03-19 15:32:36.720: E/AndroidRuntime(5284): at java.lang.reflect.Method.invoke(Method.java:511)
03-19 15:32:36.720: E/AndroidRuntime(5284): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:793)
03-19 15:32:36.720: E/AndroidRuntime(5284): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:560)
03-19 15:32:36.720: E/AndroidRuntime(5284): at dalvik.system.NativeStart.main(Native Method)
requestDisallowInterceptTouchEvent DrawerLayout innerViews 。
innerViews requestDisallowInterceptTouchEvent(true),DrawerLayout onInterceptTouchEvent 。
, , ArrayIndexOutOfBoundsException 。
(pointerId=0), requestDisallowInterceptTouchEvent(true)。 , (pointerId= 1)
( requestDisallowInterceptTouchEvent(true))。 (pointerId= 0), (pointerId= 1) onInterceptTouchEvent , DrawerLayout (pointerId=1) DrawerLayout ACTION_MOVE , pointerId 。 ,DrawerLayout =0,mInitialMotionX 1。
ArrayIndexOutOfBoundsException
:
public class HackyDrawerLayout extends DrawerLayout {
public HackyDrawerLayout(Context context) {
super(context);
}
public HackyDrawerLayout(Context context, AttributeSet attrs) {
super(context, attrs);
}
public HackyDrawerLayout(Context context, AttributeSet attrs, int defStyle) {
super(context, attrs, defStyle);
}
private boolean mIsDisallowIntercept = false;
@Override
public void requestDisallowInterceptTouchEvent(boolean disallowIntercept) {
// keep the info about if the innerViews do requestDisallowInterceptTouchEvent
mIsDisallowIntercept = disallowIntercept;
super.requestDisallowInterceptTouchEvent(disallowIntercept);
}
@Override
public boolean dispatchTouchEvent(MotionEvent ev) {
// the incorrect array size will only happen in the multi-touch scenario.
if (ev.getPointerCount() > 1 && mIsDisallowIntercept) {
requestDisallowInterceptTouchEvent(false);
boolean handled = super.dispatchTouchEvent(ev);
requestDisallowInterceptTouchEvent(true);
return handled;
} else {
return super.dispatchTouchEvent(ev);
}
}
}