expandable-recycler-view icon indicating copy to clipboard operation
expandable-recycler-view copied to clipboard

There is a crash when parent object return null in getchildList()

Open fathallah92 opened this issue 7 years ago • 2 comments

If one of the parent has no children, The application crashes. I am working on 'com.bignerdranch.android:expandablerecyclerview:3.0.0-RC1'

java.lang.NullPointerException: Attempt to invoke interface method 'java.util.Iterator java.util.List.iterator()' on a null object reference at com.bignerdranch.expandablerecyclerview.model.ExpandableWrapper.generateChildItemList(ExpandableWrapper.java:99) at com.bignerdranch.expandablerecyclerview.model.ExpandableWrapper.(ExpandableWrapper.java:33) at com.bignerdranch.expandablerecyclerview.ExpandableRecyclerAdapter.generateParentWrapper(ExpandableRecyclerAdapter.java:1357) at com.bignerdranch.expandablerecyclerview.ExpandableRecyclerAdapter.generateFlattenedParentChildList(ExpandableRecyclerAdapter.java:1326) at com.bignerdranch.expandablerecyclerview.ExpandableRecyclerAdapter.(ExpandableRecyclerAdapter.java:120)

fathallah92 avatar Mar 12 '17 10:03 fathallah92

If the parent has no child, I think you'd better to return Collections.EMPTY_LIST.

clearw5 avatar Mar 13 '17 04:03 clearw5

Thanks for the report. I'll take a look at what it might take to protect from a null child list. Right now @hyb1996 is correct that we expect an empty list. At least I'm going to have the method annotated with @NotNull if that's what it expects.

paul-turner avatar Mar 31 '17 15:03 paul-turner