2016-06-28 13 views
0

私はGitHub hereを使用しています。これにより、イメージビューで簡単にズームインできます。しかし、ImageViewがViewGroup内にあるとアプリがクラッシュする問題があります。そこで彼らは回避策を提案しました。私は回避コードを自分のプロジェクトに実装したとき、それは仕事をしませんでした。ViewGroupがクラッシュするアプリケーション

候補]コード:

import android.content.Context; 
import android.util.AttributeSet; 
import android.view.MotionEvent; 

import com.mxn.soul.flowingdrawer_core.LeftDrawerLayout; 

/** 
* Created by user on 2016-06-28. 
*/ 
public class HackyProblematicViewGroup extends LeftDrawerLayout { 

public HackyProblematicViewGroup(Context context, AttributeSet attrs) { 
    super(context, attrs); 
} 

@Override 
public boolean onInterceptTouchEvent(MotionEvent ev) { 
    try { 
     return super.onInterceptTouchEvent(ev);//The error first goes here then to the LeftDrawerLayout on the bottom! 
    } catch (IllegalArgumentException e) { 
     //uncomment if you really want to see these errors 
     //e.printStackTrace(); 
     return false; 
    } 
} 
} 

エラーメッセージ:

06-28 16:07:51.764 614-614/com.wilsapp.wilsapp E/ViewDragHelper: Ignoring pointerId=1 because ACTION_DOWN was not received for this pointer before ACTION_MOVE. It likely happened because ViewDragHelper did not receive all the events in the event stream. 
06-28 16:07:51.772 614-614/com.wilsapp.wilsapp E/InputEventReceiver: Exception dispatching input event. 
06-28 16:07:51.772 614-614/com.wilsapp.wilsapp D/AndroidRuntime: Shutting down VM 
06-28 16:07:51.789 614-614/com.wilsapp.wilsapp E/AndroidRuntime: FATAL EXCEPTION: main 
                  Process: com.wilsapp.wilsapp, PID: 614 
                  java.lang.ArrayIndexOutOfBoundsException: length=1; index=1 
                   at android.support.v4.widget.ViewDragHelper.saveLastMotion(ViewDragHelper.java:849) 
                   at android.support.v4.widget.ViewDragHelper.shouldInterceptTouchEvent(ViewDragHelper.java:1057) 
                   at com.mxn.soul.flowingdrawer_core.LeftDrawerLayout.onInterceptTouchEvent(LeftDrawerLayout.java:212) 
                   at com.wilsapp.wilsapp.HackyProblematicViewGroup.onInterceptTouchEvent(HackyProblematicViewGroup.java:22) 
                   at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2108) 
                   at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2553) 
                   at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2254) 
                   at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2553) 
                   at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2254) 
                   at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2553) 
                   at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2254) 
                   at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2553) 
                   at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2254) 
                   at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2553) 
                   at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2254) 
                   at com.android.internal.policy.PhoneWindow$DecorView.superDispatchTouchEvent(PhoneWindow.java:2403) 
                   at com.android.internal.policy.PhoneWindow.superDispatchTouchEvent(PhoneWindow.java:1737) 
                   at android.app.Activity.dispatchTouchEvent(Activity.java:2771) 
                   at com.wilsapp.wilsapp.Buyer_Home_Page.dispatchTouchEvent(Buyer_Home_Page.java:410) 
                   at android.support.v7.view.WindowCallbackWrapper.dispatchTouchEvent(WindowCallbackWrapper.java:60) 
                   at android.support.v7.view.WindowCallbackWrapper.dispatchTouchEvent(WindowCallbackWrapper.java:60) 
                   at com.android.internal.policy.PhoneWindow$DecorView.dispatchTouchEvent(PhoneWindow.java:2364) 
                   at android.view.View.dispatchPointerEvent(View.java:9520) 
                   at android.view.ViewRootImpl$ViewPostImeInputStage.processPointerEvent(ViewRootImpl.java:4230) 
                   at android.view.ViewRootImpl$ViewPostImeInputStage.onProcess(ViewRootImpl.java:4096) 
                   at android.view.ViewRootImpl$InputStage.deliver(ViewRootImpl.java:3642) 
                   at android.view.ViewRootImpl$InputStage.onDeliverToNext(ViewRootImpl.java:3695) 
                   at android.view.ViewRootImpl$InputStage.forward(ViewRootImpl.java:3661) 
                   at android.view.ViewRootImpl$AsyncInputStage.forward(ViewRootImpl.java:3787) 
                   at android.view.ViewRootImpl$InputStage.apply(ViewRootImpl.java:3669) 
                   at android.view.ViewRootImpl$AsyncInputStage.apply(ViewRootImpl.java:3844) 
                   at android.view.ViewRootImpl$InputStage.deliver(ViewRootImpl.java:3642) 
                   at android.view.ViewRootImpl$InputStage.onDeliverToNext(ViewRootImpl.java:3695) 
                   at android.view.ViewRootImpl$InputStage.forward(ViewRootImpl.java:3661) 
                   at android.view.ViewRootImpl$InputStage.apply(ViewRootImpl.java:3669) 
                   at android.view.ViewRootImpl$InputStage.deliver(ViewRootImpl.java:3642) 
                   at android.view.ViewRootImpl.deliverInputEvent(ViewRootImpl.java:5922) 
                   at android.view.ViewRootImpl.doProcessInputEvents(ViewRootImpl.java:5896) 
                   at android.view.ViewRootImpl.enqueueInputEvent(ViewRootImpl.java:5857) 
                   at android.view.ViewRootImpl$WindowInputEventReceiver.onInputEvent(ViewRootImpl.java:6025) 
                   at android.view.InputEventReceiver.dispatchInputEvent(InputEventReceiver.java:185) 
                   at android.view.InputEventReceiver.nativeConsumeBatchedInputEvents(Native Method) 
                   at android.view.InputEventReceiver.consumeBatchedInputEvents(InputEventReceiver.java:176) 
                   at android.view.ViewRootImpl.doConsumeBatchedInput(ViewRootImpl.java:5996) 
                   at android.view.ViewRootImpl$ConsumeBatchedInputRunnable.run(ViewRootImpl.java:6048) 
                   at android.view.Choreographer$CallbackRecord.run(Choreographer.java:858) 
                   at android.view.Choreographer.doCallbacks(Choreographer.java:670) 
                   at android.view.Choreographer.doFrame(Choreographer.java:600) 
                   at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:844) 
                   at android.os.Handler.handleCallb 

私はコードが間違っていたり、追加のですか?

また、LeftDrawerLayoutクラスはここthis GitHubのから来ているとエラーのコードの別の行もこれに行く:

public class LeftDrawerLayout extends ViewGroup { 
... 
    @Override 
public boolean onInterceptTouchEvent(MotionEvent ev) { 
    return mHelper.shouldInterceptTouchEvent(ev); 
} 
... 

このアプリはネクサス6 V6.0.1上でテストされて

答えて

-1

ArrayIndexOutOfBoundsExceptionIllegalArgumentExceptionのサブクラスではありません。例外を実際にキャッチしたい場合は、IllegalArgumentExceptionExceptionに置き換えることができます。

+0

キャッチを「例外」に変更すると、まだエラーが表示されます –

+0

私は実際に何か他のものを修正し、このコードを使ってオリジナルの問題を修正しました!ありがとうございました! (見ている人のための私の修正の詳細な説明は、[this](https://github.com/chrisbanes/PhotoView/issues/382)を参照してください) –

関連する問題