同时单击两个子采样比例图像将使Android崩溃

时间:2015-09-18 13:45:24

标签: android debugging

点击两个Subsalmbling scale图像视图后...当我同时点击它们时,我收到此错误:

else if(requestCode == GALLERY_IMAGE_PICK && resultCode == RESULT_OK
        && null != data)
        {
            Uri selectedImage = data.getData();         
            String picturePath = getRealPathFromURI(selectedImage,
                    this);
           Intent i = new Intent(MainActivity.this, UploadActivity.class);
           i.putExtra("filePath", selectedImage);
           i.putExtra("isImage", isImage);
           startActivity(i);
        }
      }
}


public String getRealPathFromURI(Uri contentURI, Activity context) {
        String[] projection = { MediaStore.Images.Media.DATA };
        @SuppressWarnings("deprecation")
        Cursor cursor = context.managedQuery(contentURI, projection, null,
                null, null);
        if (cursor == null)
            return null;
        int column_index = cursor
                .getColumnIndexOrThrow(MediaStore.Images.Media.DATA);
        if (cursor.moveToFirst()) {
            String s = cursor.getString(column_index);
            // cursor.close();
            return s;
        }
        // cursor.close();
        return null;
    }

布局:

09-18 12:37:17.807  22777-22777/... E/AndroidRuntime﹕ FATAL EXCEPTION: main
Process: ..., PID: 22777
java.lang.ArrayIndexOutOfBoundsException: length=1; index=1
        at android.support.v4.widget.ViewDragHelper.shouldInterceptTouchEvent(ViewDragHelper.java:1004)
        at android.support.v4.widget.DrawerLayout.onInterceptTouchEvent(DrawerLayout.java:868)
        at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:1873)
        at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2230)
        at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:1973)
        at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2230)
        at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:1973)
        at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2230)
        at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:1973)
        at com.android.internal.policy.impl.PhoneWindow$DecorView.superDispatchTouchEvent(PhoneWindow.java:2069)
        at com.android.internal.policy.impl.PhoneWindow.superDispatchTouchEvent(PhoneWindow.java:1515)
        at android.app.Activity.dispatchTouchEvent(Activity.java:2531)
        at com.android.internal.policy.impl.PhoneWindow$DecorView.dispatchTouchEvent(PhoneWindow.java:2017)
        at android.view.View.dispatchPointerEvent(View.java:8004)
        at android.view.ViewRootImpl$ViewPostImeInputStage.processPointerEvent(ViewRootImpl.java:4136)
        at android.view.ViewRootImpl$ViewPostImeInputStage.onProcess(ViewRootImpl.java:3990)
        at android.view.ViewRootImpl$InputStage.deliver(ViewRootImpl.java:3548)
        at android.view.ViewRootImpl$InputStage.onDeliverToNext(ViewRootImpl.java:3598)
        at android.view.ViewRootImpl$InputStage.forward(ViewRootImpl.java:3567)
        at android.view.ViewRootImpl$AsyncInputStage.forward(ViewRootImpl.java:3674)
        at android.view.ViewRootImpl$InputStage.apply(ViewRootImpl.java:3575)
        at android.view.ViewRootImpl$AsyncInputStage.apply(ViewRootImpl.java:3731)
        at android.view.ViewRootImpl$InputStage.deliver(ViewRootImpl.java:3548)
        at android.view.ViewRootImpl$InputStage.onDeliverToNext(ViewRootImpl.java:3598)
        at android.view.ViewRootImpl$InputStage.forward(ViewRootImpl.java:3567)
        at android.view.ViewRootImpl$InputStage.apply(ViewRootImpl.java:3575)
        at android.view.ViewRootImpl$InputStage.deliver(ViewRootImpl.java:3548)
        at android.view.ViewRootImpl.deliverInputEvent(ViewRootImpl.java:5817)
        at android.view.ViewRootImpl.doProcessInputEvents(ViewRootImpl.java:5797)
        at android.view.ViewRootImpl.enqueueInputEvent(ViewRootImpl.java:5768)
        at android.view.ViewRootImpl$WindowInputEventReceiver.onInputEvent(ViewRootImpl.java:5897)
        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:5870)
        at android.view.ViewRootImpl$ConsumeBatchedInputRunnable.run(ViewRootImpl.java:5916)
        at android.view.Choreographer$CallbackRecord.run(Choreographer.java:761)
        at android.view.Choreographer.doCallbacks(Choreographer.java:574)
        at android.view.Choreographer.doFrame(Choreographer.java:542)
        at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:747)
        at android.os.Handler.handleCallback(Handler.java:733)
        at android.os.Handler.dispatchMessage(Handler.java:95)
        at android.os.Looper.loop(Looper.java:136)
        at android.app.ActivityThread.main(ActivityThread.java:5246)
        at java.lang.reflect.Method.invokeNative(Native Method)
        at java.lang.reflect.Method.invoke(Method.java:515)
        at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:780)
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:596)
        at dalvik.system.NativeStart.main(Native Method)

代码:

<FrameLayout
    android:id="@+id/idContainer"
    android:layout_width="match_parent"
    android:padding="16dp"
    android:layout_height="match_parent" >
    <com.davemorrissey.labs.subscaleview.SubsamplingScaleImageView
        android:id="@+id/idImage"
        android:background="@color/gsd_bg_darkest"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:layout_gravity="center" />

    <ProgressBar
        android:id="@+id/idProgress"
        style="?android:attr/progressBarStyle"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_gravity="center" />
</FrameLayout>

我是否在Android代码中发现了一个错误,或者我应该怎么做以找出问题的实际位置?任何提示(也只是为了澄清这个问题)都非常感激。

1 个答案:

答案 0 :(得分:2)

这是图书馆的一个错误。评论这一行解决了这个问题:

https://github.com/filnik/subsampling-scale-image-view/commit/b1ba2c3cbd0b095a90c463a682743e3e5dab88cf