-
-
Notifications
You must be signed in to change notification settings - Fork 17
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
IndexOutOfBoundsException but I can't reproduce it. #178
Comments
Hi @MRDHR can you please share the full stacktrace? I'm interested in knowing if the index was greater than the adapter size or if it was negative. |
Hey @MRDHR. I managed to reproduce the crash with this UI test: @Test
fun testSelectingPositionOutOfBoundsDoesNotCrash() {
val numberOfItems = 500
launchFragment(TestAdapterConfiguration(numberOfItems = numberOfItems))
selectPosition(numberOfItems + 100, smooth = true, waitForIdle = false)
Thread.sleep(1000L)
mutateAdapter { adapter ->
adapter.setList(MutableList(numberOfItems + 10) { it })
adapter.notifyItemRangeInserted(0, 100)
}
onRecyclerView("Request layout") { recyclerView ->
recyclerView.requestLayout()
}
assertFocusAndSelection(numberOfItems + 9)
} Please check if you're doing the following in your side:
There's a PR here to address this specific crash now, but you might still hit some issues if you don't follow those 2 steps: #179 |
Regarding the two points you mentioned 1: I did not use DiffUtil to update data, I used replace. That is, items clear, then add all, and finally execute notifydatasetchanged The data updates are not very frequent, and they are not updated every 1 second. At present, I have added the setSelectedPosition operation to be executed after recyclerview.post, and added the judgment for position>=0&&position<=items. size -1 |
Looking forward to your pull request being synchronized to the master and release an aar |
@MRDHR released in |
Our app used dpadrecycliew and also encountered IndexOutOfBoundsException,
Using 1.2.0-alpha02.
The following is the stack information when an error occurs
androidx.recyclerview.widget.RecyclerView$Recycler.tryGetViewHolderForPositionByDeadline(RecyclerView.java:6783) androidx.recyclerview.widget.RecyclerView$Recycler.getViewForPosition(RecyclerView.java:6757) androidx.recyclerview.widget.RecyclerView$Recycler.getViewForPosition(RecyclerView.java:6753) com.rubensousa.dpadrecyclerview.layoutmanager.layout.linear.LinearLayoutEngineer.initLayout(LinearLayoutEngineer.kt:63) com.rubensousa.dpadrecyclerview.layoutmanager.layout.StructureEngineer.layoutChildren(StructureEngineer.kt:205) com.rubensousa.dpadrecyclerview.layoutmanager.layout.PivotLayout.layoutChildren(PivotLayout.kt:124) com.rubensousa.dpadrecyclerview.layoutmanager.layout.PivotLayout.onLayoutChildren(PivotLayout.kt:89) com.rubensousa.dpadrecyclerview.layoutmanager.PivotLayoutManager.onLayoutChildren(PivotLayoutManager.kt:128) androidx.recyclerview.widget.RecyclerView.dispatchLayoutStep2(RecyclerView.java:4645) androidx.recyclerview.widget.RecyclerView.dispatchLayout(RecyclerView.java:4348) androidx.recyclerview.widget.RecyclerView.onLayout(RecyclerView.java:4919) android.view.View.layout(View.java:22501) android.view.ViewGroup.layout(ViewGroup.java:6528) android.widget.FrameLayout.layoutChildren(FrameLayout.java:334) android.widget.FrameLayout.onLayout(FrameLayout.java:270) android.view.View.layout(View.java:22501) android.view.ViewGroup.layout(ViewGroup.java:6528) androidx.appcompat.widget.LinearLayoutCompat.setChildFrame(LinearLayoutCompat.java:1669) androidx.appcompat.widget.LinearLayoutCompat.layoutHorizontal(LinearLayoutCompat.java:1658) androidx.appcompat.widget.LinearLayoutCompat.onLayout(LinearLayoutCompat.java:1433) android.view.View.layout(View.java:22501) android.view.ViewGroup.layout(ViewGroup.java:6528) android.widget.FrameLayout.layoutChildren(FrameLayout.java:334) android.widget.FrameLayout.onLayout(FrameLayout.java:270) android.view.View.layout(View.java:22501) android.view.ViewGroup.layout(ViewGroup.java:6528) android.widget.FrameLayout.layoutChildren(FrameLayout.java:334) android.widget.FrameLayout.onLayout(FrameLayout.java:270) android.view.View.layout(View.java:22501) android.view.ViewGroup.layout(ViewGroup.java:6528) razerdp.basepopup.PopupDecorViewProxy.layoutInternal(PopupDecorViewProxy.java:597) razerdp.basepopup.PopupDecorViewProxy.onLayout(PopupDecorViewProxy.java:378) android.view.View.layout(View.java:22501) android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:3276) android.view.ViewRootImpl.doTraversal(ViewRootImpl.java:2235) android.view.ViewRootImpl$TraversalRunnable.run(ViewRootImpl.java:9043) android.view.Choreographer$CallbackRecord.run(Choreographer.java:1280) android.view.Choreographer.doCallbacks(Choreographer.java:1019) android.view.Choreographer.doFrame(Choreographer.java:911) android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:1248) android.os.Handler.handleCallback(Handler.java:900) android.os.Handler.dispatchMessage(Handler.java:103) android.os.Looper.loop(Looper.java:219) android.app.ActivityThread.main(ActivityThread.java:8673) java.lang.reflect.Method.invoke(Native Method) com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:513) com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1109)
The text was updated successfully, but these errors were encountered: