bignerdranch / expandable-recycler-view

[DEPRECATED]
MIT License
1.21k stars 292 forks source link

Issue in View type #333

Open ahmedsalemelzeiny opened 7 years ago

ahmedsalemelzeiny commented 7 years ago

In Child view type when i define some view type with value 0,1 the application crashed with this exception : java.lang.ClassCastException: ....$DeParentHolder cannot be cast to com.bignerdranch.expandablerecyclerview.ChildViewHolder because parent and child view holder have constant values for view type, So when i change my child view type values from 0,1 to 100 and 200 the application work successfully without any issue

leonapse commented 7 years ago

@ahmedsalemelzeiny I also had the same issue, and I guess we can attribute it to bad documentation since clearly view types 0 and 1 are reserved for categories and children.

paul-turner commented 7 years ago

I've already tried to document this in both methods of getParentViewType here and getChildViewType here which I assumed would be read before overriding. Is there a better place to put this information? Looks like I should add a note in our page as well since it isn't mentioned there, any others?

I don't think changing the values will help much since that might make it less obvious that we are using them for the defaults (making the crash seem more random).

leonapse commented 7 years ago

@paul-turner Much better if it is in the page since it is where devs look for quick references. For example, I stumbled upon the issue because I tried to have 2 types of parent (I needed another view type which is not supposed to be the same object as a parent or a child) while only having a single child and since it was not explicitly stated in the site, I stupidly assumed that after the isParentViewType() override is defined, the child viewType would be automatically adjusted.

Coden55 commented 7 years ago

wasted one hour trying to figure out what causes this issue:(