evant / binding-collection-adapter

Easy way to bind collections to listviews and recyclerviews with the new Android Data Binding framework
Apache License 2.0
1.92k stars 255 forks source link

NullPointerException at me.tatarka.bindingcollectionadapter2.collections.DiffObservableList.size(DiffObservableList.java:184) #190

Open shanhuiyang opened 4 years ago

shanhuiyang commented 4 years ago

Issue

05-19 04:41:06.107 4263 4263 E AndroidRuntime: java.lang.NullPointerException: Attempt to invoke interface method 'int java.util.List.size()' on a null object reference
05-19 04:41:06.107 4263 4263 E AndroidRuntime: at me.tatarka.bindingcollectionadapter2.collections.DiffObservableList.size(DiffObservableList.java:184)
05-19 04:41:06.107 4263 4263 E AndroidRuntime: at me.tatarka.bindingcollectionadapter2.BindingRecyclerViewAdapter.getItemCount(BindingRecyclerViewAdapter.java:249)
05-19 04:41:06.107 4263 4263 E AndroidRuntime: at androidx.recyclerview.widget.RecyclerView.dispatchLayoutStep1(RecyclerView.java:4044)
05-19 04:41:06.107 4263 4263 E AndroidRuntime: at androidx.recyclerview.widget.RecyclerView.dispatchLayout(RecyclerView.java:3849)
05-19 04:41:06.107 4263 4263 E AndroidRuntime: at androidx.recyclerview.widget.RecyclerView.onLayout(RecyclerView.java:4404)
05-19 04:41:06.107 4263 4263 E AndroidRuntime: at android.view.View.layout(View.java:19659)
05-19 04:41:06.107 4263 4263 E AndroidRuntime: at android.view.ViewGroup.layout(ViewGroup.java:6075)
05-19 04:41:06.107 4263 4263 E AndroidRuntime: at android.widget.FrameLayout.layoutChildren(FrameLayout.java:323)
05-19 04:41:06.107 4263 4263 E AndroidRuntime: at android.widget.FrameLayout.onLayout(FrameLayout.java:261)
05-19 04:41:06.107 4263 4263 E AndroidRuntime: at android.view.View.layout(View.java:19659)
05-19 04:41:06.107 4263 4263 E AndroidRuntime: at android.view.ViewGroup.layout(ViewGroup.java:6075)
05-19 04:41:06.107 4263 4263 E AndroidRuntime: at androidx.swiperefreshlayout.widget.SwipeRefreshLayout.onLayout(SwipeRefreshLayout.java:625)
05-19 04:41:06.107 4263 4263 E AndroidRuntime: at android.view.View.layout(View.java:19659)
05-19 04:41:06.107 4263 4263 E AndroidRuntime: at android.view.ViewGroup.layout(ViewGroup.java:6075)
05-19 04:41:06.107 4263 4263 E AndroidRuntime: at android.widget.FrameLayout.layoutChildren(FrameLayout.java:323)
05-19 04:41:06.107 4263 4263 E AndroidRuntime: at android.widget.FrameLayout.onLayout(FrameLayout.java:261)
05-19 04:41:06.107 4263 4263 E AndroidRuntime: at android.view.View.layout(View.java:19659)

version: 3.2.0

Not sure why the list could be null.

evant commented 4 years ago

Thank you for reporting your issue. In order to look into it, can you please provide a sample project and clear steps to reproduce?

shanhuiyang commented 4 years ago

Cannot provide that, this issue only happened once in my app. @evant I just would like to try here to see if you can get some clue on this.