ExpandableGroup constructor can cause ClassCastException
lukasz-kalnik-gcx opened this issue · 1 comments
lukasz-kalnik-gcx commented
The constructor ExpandableGroup(Group)
immediately casts its Group
argument to ExpandableItem
which is not guaranteed to succeed in any way (a Group
does not extend ExpandableItem
). This can lead to a ClassCastException at runtime.
Example:
val parent = CardItem(rainbow200[0])
val expandableGroup = ExpandableGroup(parent)
java.lang.ClassCastException: com.xwray.groupie.example.viewbinding.item.CardItem cannot be cast to com.xwray.groupie.ExpandableItem
Solution would be probably to make ExpandableItem
extend Group
(like e.g. also Item
does) and change the ExpandableGroup
constructor parameter and parent
field type to ExpandableItem
.
Zhuinden commented
Yes, this is true. I always wondered why ExpandableGroup
takes a Group
instead of an ExpandableItem
, when it requires an ExpandableItem
either way.