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

Issue in View type

Open ahmedsalemelzeiny opened this issue 8 years ago • 4 comments

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

ahmedsalemelzeiny avatar Feb 13 '17 09:02 ahmedsalemelzeiny

@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.

leonapse avatar Feb 15 '17 15:02 leonapse

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).

paul-turner avatar Feb 15 '17 15:02 paul-turner

@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.

leonapse avatar Feb 15 '17 17:02 leonapse

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

Coden55 avatar May 18 '17 19:05 Coden55