myinnos / AlphabetIndex-Fast-Scroll-RecyclerView

A Powerful AlphabetIndex FastScroller Library for Android's RecyclerView!
https://myinnos.github.io/AlphabetIndex-Fast-Scroll-RecyclerView/
Apache License 2.0
603 stars 114 forks source link

Crash while scrolling index & filter #66

Open Xuemin91 opened 5 years ago

Xuemin91 commented 5 years ago

I found there is a crash while scrolling using the index letters(at the right side of the view) and filter. Please take a look when you get a chance. Added error log

2019-10-31 12:58:49.414 12373-12373/? E/application: Fatal Exception occurred: length=2; index=24 2019-10-31 12:58:49.417 12373-12373/? E/application: Stack Trace: java.lang.ArrayIndexOutOfBoundsException: length=2; index=24 at in.myinnos.alphabetsindexfastscrollrecycler.IndexFastScrollRecyclerSection.draw(IndexFastScrollRecyclerSection.java:94) at in.myinnos.alphabetsindexfastscrollrecycler.IndexFastScrollRecyclerView.draw(IndexFastScrollRecyclerView.java:105) at android.view.View.updateDisplayListIfDirty(View.java:19315) at android.view.View.draw(View.java:20093) at android.view.ViewGroup.drawChild(ViewGroup.java:4421) at android.view.ViewGroup.dispatchDraw(ViewGroup.java:4207) at android.view.View.draw(View.java:20373) at android.view.View.updateDisplayListIfDirty(View.java:19315) at android.view.View.draw(View.java:20093) at android.view.ViewGroup.drawChild(ViewGroup.java:4421) at android.view.ViewGroup.dispatchDraw(ViewGroup.java:4207) at android.view.View.draw(View.java:20373) at android.view.View.updateDisplayListIfDirty(View.java:19315) at android.view.View.draw(View.java:20093) at android.view.ViewGroup.drawChild(ViewGroup.java:4421) at android.view.ViewGroup.dispatchDraw(ViewGroup.java:4207) at android.view.View.updateDisplayListIfDirty(View.java:19306) at android.view.View.draw(View.java:20093) at android.view.ViewGroup.drawChild(ViewGroup.java:4421) at android.view.ViewGroup.dispatchDraw(ViewGroup.java:4207) at android.view.View.updateDisplayListIfDirty(View.java:19306) at android.view.View.draw(View.java:20093) at android.view.ViewGroup.drawChild(ViewGroup.java:4421) at android.view.ViewGroup.dispatchDraw(ViewGroup.java:4207) at android.view.View.updateDisplayListIfDirty(View.java:19306) at android.view.View.draw(View.java:20093) at android.view.ViewGroup.drawChild(ViewGroup.java:4421) at android.view.ViewGroup.dispatchDraw(ViewGroup.java:4207) at android.view.View.updateDisplayListIfDirty(View.java:19306) at android.view.View.draw(View.java:20093) at android.view.ViewGroup.drawChild(ViewGroup.java:4421) at android.view.ViewGroup.dispatchDraw(ViewGroup.java:4207) at android.view.View.updateDisplayListIfDirty(View.java:19306) at android.view.View.draw(View.java:20093) at android.view.ViewGroup.drawChild(ViewGroup.java:4421) at android.view.ViewGroup.dispatchDraw(ViewGroup.java:4207) at android.view.View.updateDisplayListIfDirty(View.java:19306) at android.view.View.draw(View.java:20093) at android.view.ViewGroup.drawChild(ViewGroup.java:4421) at android.view.ViewGroup.dispatchDraw(ViewGroup.java:4207) at android.view.View.draw(View.java:20373) at com.android.internal.policy.DecorView.draw(DecorView.java:980) at android.view.View.updateDisplayListIfDirty(View.java:19315) at android.view.ThreadedRenderer.updateViewTreeDisplayList(ThreadedRenderer.java:686) at android.view.ThreadedRenderer.updateRootDisplayList(ThreadedRenderer.java:692) at android.view.ThreadedRenderer.draw(ThreadedRenderer.java:800) at android.view.ViewRootImpl.draw(ViewRootImpl.java:3496) at android.view.ViewRootImpl.performDraw(ViewRootImpl.java:3283) at android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:2818) at android.view.ViewRootImpl.doTraversal(ViewRootImpl.java:1780) at android.view.ViewRootImpl$TraversalRunnable.run(ViewRootImpl.java:7827) at android.view.Choreographer$CallbackRecord.run(Choreographer.java:911) at android.view.Choreographer.doCallbacks(Choreographer.java:723) at android.view.Choreographer.doFrame(Choreographer.java:658) at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:897) at android.os.Handler.handleCallback(Handler.java:789) at android.os.Handler.dispatchMessage(Handler.java:98) at android.os.Looper.loop(Looper.java:164) at android.app.ActivityThread.main(ActivityThread.java:6944) at java.lang.reflect.Method.invoke(Native Method) at com.android.internal.os.Zygote$MethodAndArgsCaller.run(Zygote.java:327) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1374)

joshmon27 commented 2 years ago

I am getting the same crash as you. I came up with a solution. however, I have not tested it throughly; but it seems like it's working! public int getPositionForSection(int sectionIndex) { if (sectionIndex >= sectionPositions.size()){ return 0; } return sectionPositions.get(sectionIndex); }