timroes / EnhancedListView

[DEPRECATED] An Android ListView with enhanced functionality (e.g. Swipe To Dismiss or Undo)
Other
463 stars 147 forks source link

ArrayIndexOutOfBoundsException while Scrolling #43

Closed akohout closed 10 years ago

akohout commented 10 years ago

Hey,

first of: cool library!

But I'm facing one problem: When I open the view that contains the EnhancedListView and I start scrolling it simply crashes with an ArrayIndexOutOfBoundsException.

The according stack trace:

java.lang.ArrayIndexOutOfBoundsException: length=2; index=2130903077
            at android.widget.AbsListView$RecycleBin.addScrapView(AbsListView.java:6724)
            at android.widget.AbsListView.trackMotionScroll(AbsListView.java:5084)
            at android.widget.AbsListView.scrollIfNeeded(AbsListView.java:3236)
            at android.widget.AbsListView.onTouchMove(AbsListView.java:3580)
            at android.widget.AbsListView.onTouchEvent(AbsListView.java:3424)
            at de.timroes.android.listview.EnhancedListView.onTouchEvent(EnhancedListView.java:784)
            at android.view.View.dispatchTouchEvent(View.java:7706)
            at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2210)
            at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:1945)
            at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2216)
            at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:1959)
            at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2216)
            at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:1959)
            at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2216)
            at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:1959)
            at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2216)
            at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:1959)
            at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2216)
            at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:1959)
            at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2216)
            at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:1959)
            at com.android.internal.policy.impl.PhoneWindow$DecorView.superDispatchTouchEvent(PhoneWindow.java:2068)
            at com.android.internal.policy.impl.PhoneWindow.superDispatchTouchEvent(PhoneWindow.java:1515)
            at android.app.Activity.dispatchTouchEvent(Activity.java:2458)
            at com.android.internal.policy.impl.PhoneWindow$DecorView.dispatchTouchEvent(PhoneWindow.java:2016)
            at android.view.View.dispatchPointerEvent(View.java:7886)
            at android.view.ViewRootImpl$ViewPostImeInputStage.processPointerEvent(ViewRootImpl.java:3954)
            at android.view.ViewRootImpl$ViewPostImeInputStage.onProcess(ViewRootImpl.java:3833)
            at android.view.ViewRootImpl$InputStage.deliver(ViewRootImpl.java:3399)
            at android.view.ViewRootImpl$InputStage.onDeliverToNext(ViewRootImpl.java:3449)
            at android.view.ViewRootImpl$InputStage.forward(ViewRootImpl.java:3418)
            at android.view.ViewRootImpl$AsyncInputStage.forward(ViewRootImpl.java:3525)
            at android.view.ViewRootImpl$InputStage.apply(ViewRootImpl.java:3426)
            at android.view.ViewRootImpl$AsyncInputStage.apply(ViewRootImpl.java:3582)
            at android.view.ViewRootImpl$InputStage.deliver(ViewRootImpl.java:3399)
            at android.view.ViewRootImpl$InputStage.onDeliverToNext(ViewRootImpl.java:3449)
            at android.view.ViewRootImpl$InputStage.forward(ViewRootImpl.java:3418)
            at android.view.ViewRootImpl$InputStage.apply(ViewRootImpl.java:3426)
            at android.view.ViewRootImpl$InputStage.deliver(ViewRootImpl.java:3399)
            at android.view.ViewRootImpl.deliverInputEvent(ViewRootImpl.java:5602)
            at android.view.ViewRootImpl.doProcessInputEvents(ViewRootImpl.java:5582)
            at android.view.ViewRootImpl.enqueueInputEvent(ViewRootImpl.java:5553)
            at android.view.ViewRootImpl$WindowInputEventReceiver.onInputEvent(ViewRootImpl.java:5682)
            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:5655)
            at android.view.ViewRootImpl$ConsumeBatchedInputRunnable.run(ViewRootImpl.java:5701)
            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$FrameDisplayEve

To my app:

Do you have any idea what's going on there? Do you need more code? :)

akohout commented 10 years ago

I receive the same exception when swiping a ListView entry:

java.lang.ArrayIndexOutOfBoundsException: length=2; index=2130903077
            at android.widget.AbsListView$RecycleBin.addScrapView(AbsListView.java:6724)
            at android.widget.ListView.layoutChildren(ListView.java:1589)
            at android.widget.AbsListView.onLayout(AbsListView.java:2091)
            at android.view.View.layout(View.java:14817)
            at android.view.ViewGroup.layout(ViewGroup.java:4631)
            at android.widget.FrameLayout.layoutChildren(FrameLayout.java:453)
            at android.widget.FrameLayout.onLayout(FrameLayout.java:388)
            at android.view.View.layout(View.java:14817)
            at android.view.ViewGroup.layout(ViewGroup.java:4631)
            at android.widget.FrameLayout.layoutChildren(FrameLayout.java:453)
            at android.widget.FrameLayout.onLayout(FrameLayout.java:388)
            at android.view.View.layout(View.java:14817)
            at android.view.ViewGroup.layout(ViewGroup.java:4631)
            at android.support.v4.widget.DrawerLayout.onLayout(DrawerLayout.java:690)
            at android.view.View.layout(View.java:14817)
            at android.view.ViewGroup.layout(ViewGroup.java:4631)
            at android.widget.FrameLayout.layoutChildren(FrameLayout.java:453)
            at android.widget.FrameLayout.onLayout(FrameLayout.java:388)
            at android.view.View.layout(View.java:14817)
            at android.view.ViewGroup.layout(ViewGroup.java:4631)
            at com.android.internal.widget.ActionBarOverlayLayout.onLayout(ActionBarOverlayLayout.java:374)
            at android.view.View.layout(View.java:14817)
            at android.view.ViewGroup.layout(ViewGroup.java:4631)
            at android.widget.FrameLayout.layoutChildren(FrameLayout.java:453)
            at android.widget.FrameLayout.onLayout(FrameLayout.java:388)
            at android.view.View.layout(View.java:14817)
            at android.view.ViewGroup.layout(ViewGroup.java:4631)
            at android.view.ViewRootImpl.performLayout(ViewRootImpl.java:1987)
            at android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:1744)
            at android.view.ViewRootImpl.doTraversal(ViewRootImpl.java:1000)
            at android.view.ViewRootImpl$TraversalRunnable.run(ViewRootImpl.java:5670)
            at android.view.Choreographer$CallbackRecord.run(Choreographer.java:761)
            at android.view.Choreographer.doCallbacks(Choreographer.java:574)
            at android.view.Choreographer.doFrame(Choreographer.java:544)
            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:5017)
            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:779)
            at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:595)
            at dalvik.system.NativeStart.main(Native Method)

I hope you know what's going on there..

timroes commented 10 years ago

I doubt I do :(

Looking at the stack trace, the only part of this libraries code is the plain call to super.onTouchEvent, and AbsListView crashes then somehow. Looking at this, it doesn't seem to be a bug in the library (though you never know, you only wish :D).

Could you perhaps replace the EnhancedListView in your layout with a ListView and comment out the methods, that don't exists on the ListView and see if it still crashes if you touch something?

akohout commented 10 years ago

Oh sh**, you're right ... doing it with a simple ListView also let the app break. I really hoped it was your library :D

Thanks for your advice and sorry for reporting a non-existing exception!

timroes commented 10 years ago

No problem. If you want an wild guess what you might be doing wrong:

Are you using getViewTypeCount() and getItemViewType() and returned an integer from getItemViewType equal or larger than you returned from getViewTypeCount() (or perhaps a negative number)?

akohout commented 10 years ago

Haha, yeah - you’re right with your wild guess :-) Awesome, thanks!

Leonid-Kiev commented 8 years ago

I had the same trouble when used multiple view types for the ListView. The trick is that view types must start from 0. And not forget to ovverride getViewTypeCount method.