Skip to content
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

Intermittent: Null Pointer Exception when setting adapter second time with updated list #288

Open
mdrafiwynk opened this issue Nov 15, 2024 · 8 comments

Comments

@mdrafiwynk
Copy link

Fatal Exception: java.lang.NullPointerException
Attempt to invoke virtual method 'void android.view.View.clearAccessibilityFocus()' on a null object reference

Stack Trace :

Fatal Exception: java.lang.NullPointerException: Attempt to invoke virtual method 'void android.view.View.clearAccessibilityFocus()' on a null object reference
at android.view.ViewGroup.removeViewInternal(ViewGroup.java:5594)
at android.view.ViewGroup.removeViewAt(ViewGroup.java:5550)
at com.rubensousa.dpadrecyclerview.DpadRecyclerView.removeViewAt(DpadRecyclerView.kt:367)
at androidx.recyclerview.widget.RecyclerView$5.removeViewAt(RecyclerView.java:915)
at androidx.recyclerview.widget.ChildHelper.removeViewAt(ChildHelper.java:168)
at androidx.recyclerview.widget.RecyclerView$LayoutManager.removeViewAt(RecyclerView.java:8940)
at androidx.recyclerview.widget.RecyclerView$LayoutManager.removeAndRecycleViewAt(RecyclerView.java:9211)
at androidx.recyclerview.widget.RecyclerView$LayoutManager.removeAndRecycleAllViews(RecyclerView.java:10624)
at androidx.recyclerview.widget.RecyclerView.removeAndRecycleViews(RecyclerView.java:1212)
at androidx.recyclerview.widget.RecyclerView.setAdapterInternal(RecyclerView.java:1236)
at androidx.recyclerview.widget.RecyclerView.setAdapter(RecyclerView.java:1194)
at tv.airtel.xstream.adapters.ContentListAdapter$ContentListViewHolder.bindItem(ContentListAdapter.kt:618)
at tv.airtel.xstream.adapters.ContentListAdapter.onBindViewHolder(ContentListAdapter.kt:197)
at androidx.recyclerview.widget.RecyclerView$Adapter.onBindViewHolder(RecyclerView.java:7254)
at androidx.recyclerview.widget.RecyclerView$Adapter.bindViewHolder(RecyclerView.java:7337)
at androidx.recyclerview.widget.RecyclerView$Recycler.tryBindViewHolderByDeadline(RecyclerView.java:6194)
at androidx.recyclerview.widget.RecyclerView$Recycler.tryGetViewHolderForPositionByDeadline(RecyclerView.java:6460)
at androidx.recyclerview.widget.RecyclerView$Recycler.getViewForPosition(RecyclerView.java:6300)
at androidx.recyclerview.widget.RecyclerView$Recycler.getViewForPosition(RecyclerView.java:6296)
at com.rubensousa.dpadrecyclerview.layoutmanager.layout.linear.LinearLayoutEngineer.initLayout(LinearLayoutEngineer.kt:63)
at com.rubensousa.dpadrecyclerview.layoutmanager.layout.StructureEngineer.layoutChildren(StructureEngineer.kt:205)
at com.rubensousa.dpadrecyclerview.layoutmanager.layout.PivotLayout.layoutChildren(PivotLayout.kt:124)
at com.rubensousa.dpadrecyclerview.layoutmanager.layout.PivotLayout.onLayoutChildren(PivotLayout.kt:89)
at com.rubensousa.dpadrecyclerview.layoutmanager.PivotLayoutManager.onLayoutChildren(PivotLayoutManager.kt:129)
at androidx.recyclerview.widget.RecyclerView.dispatchLayoutStep2(RecyclerView.java:4309)
at androidx.recyclerview.widget.RecyclerView.dispatchLayout(RecyclerView.java:4012)
at androidx.recyclerview.widget.RecyclerView.onLayout(RecyclerView.java:4578)
at android.view.View.layout(View.java:24421)
at android.view.ViewGroup.layout(ViewGroup.java:6443)
at androidx.constraintlayout.widget.ConstraintLayout.onLayout(ConstraintLayout.java:1915)
at android.view.View.layout(View.java:24421)
at android.view.ViewGroup.layout(ViewGroup.java:6443)
at android.widget.FrameLayout.layoutChildren(FrameLayout.java:332)
at android.widget.FrameLayout.onLayout(FrameLayout.java:270)
at android.view.View.layout(View.java:24421)
at android.view.ViewGroup.layout(ViewGroup.java:6443)
at androidx.constraintlayout.widget.ConstraintLayout.onLayout(ConstraintLayout.java:1915)
at android.view.View.layout(View.java:24421)
at android.view.ViewGroup.layout(ViewGroup.java:6443)
at android.widget.FrameLayout.layoutChildren(FrameLayout.java:332)
at android.widget.FrameLayout.onLayout(FrameLayout.java:270)
at android.view.View.layout(View.java:24421)
at android.view.ViewGroup.layout(ViewGroup.java:6443)
at androidx.constraintlayout.widget.ConstraintLayout.onLayout(ConstraintLayout.java:1915)
at android.view.View.layout(View.java:24421)
at android.view.ViewGroup.layout(ViewGroup.java:6443)
at androidx.constraintlayout.widget.ConstraintLayout.onLayout(ConstraintLayout.java:1915)
at android.view.View.layout(View.java:24421)
at android.view.ViewGroup.layout(ViewGroup.java:6443)
at android.widget.FrameLayout.layoutChildren(FrameLayout.java:332)
at android.widget.FrameLayout.onLayout(FrameLayout.java:270)
at android.view.View.layout(View.java:24421)
at android.view.ViewGroup.layout(ViewGroup.java:6443)
at androidx.constraintlayout.widget.ConstraintLayout.onLayout(ConstraintLayout.java:1915)
at android.view.View.layout(View.java:24421)
at android.view.ViewGroup.layout(ViewGroup.java:6443)
at android.widget.FrameLayout.layoutChildren(FrameLayout.java:332)
at android.widget.FrameLayout.onLayout(FrameLayout.java:270)
at android.view.View.layout(View.java:24421)
at android.view.ViewGroup.layout(ViewGroup.java:6443)
at android.widget.LinearLayout.setChildFrame(LinearLayout.java:1891)
at android.widget.LinearLayout.layoutVertical(LinearLayout.java:1729)
at android.widget.LinearLayout.onLayout(LinearLayout.java:1638)
at android.view.View.layout(View.java:24421)
at android.view.ViewGroup.layout(ViewGroup.java:6443)
at android.widget.FrameLayout.layoutChildren(FrameLayout.java:332)
at android.widget.FrameLayout.onLayout(FrameLayout.java:270)
at com.android.internal.policy.DecorView.onLayout(DecorView.java:789)
at android.view.View.layout(View.java:24421)
at android.view.ViewGroup.layout(ViewGroup.java:6443)
at android.view.ViewRootImpl.performLayout(ViewRootImpl.java:4258)
at android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:3583)
at android.view.ViewRootImpl.doTraversal(ViewRootImpl.java:2465)
at android.view.ViewRootImpl$TraversalRunnable.run(ViewRootImpl.java:9305)
at android.view.Choreographer$CallbackRecord.run(Choreographer.java:1339)
at android.view.Choreographer$CallbackRecord.run(Choreographer.java:1348)
at android.view.Choreographer.doCallbacks(Choreographer.java:952)
at android.view.Choreographer.doFrame(Choreographer.java:882)
at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:1322)
at android.os.Handler.handleCallback(Handler.java:958)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loopOnce(Looper.java:205)
at android.os.Looper.loop(Looper.java:294)
at android.app.ActivityThread.main(ActivityThread.java:8177)
at java.lang.reflect.Method.invoke(Method.java)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:552)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:971)

@rubensousa
Copy link
Owner

@mdrafiwynk

Can you explain what you mean with setting adapter second time? Please show me a small code example that triggers this crash

@mdrafiwynk
Copy link
Author

For example : First time I set adaptor with 10 itmes and then i removed one time from any position and then set adaptor again with 9 items.

@rubensousa
Copy link
Owner

@mdrafiwynk

But can you show me how you trigger those updates exactly? It's important for me to check how you're triggering the updates so I can reproduce the issue myself

@rubensousa
Copy link
Owner

So you're using setAdapter multiple times, is that it?

@mdrafiwynk
Copy link
Author

Yes. I am using nested recyler view and inside each parent recycler view nested recyler view adapter is called every time when anything added or removed in rail. Ex - Continue watching rail

@rubensousa
Copy link
Owner

Can you please share a small demo project with those setAdapter calls then?

@rubensousa
Copy link
Owner

@mdrafiwynk any update here?

@mdrafiwynk
Copy link
Author

Sorry. But i didn't have time to create demo. Also I am not sure this is the Rott cause for this or not. But this is very frequently observed when use nested recyler view

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants