bignerdranch / expandable-recycler-view

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

Improve RecyclerView adapter change animations #371

Open vit001 opened 7 years ago

vit001 commented 7 years ago

First, great lib!

I have a use case where at most one parent can be expanded at any one time. Expanding a parent causes any other previously expanded parent to collapse. The problem I have is that the RecyclerView animation is strange: The children from the collapsing parent move to the newly expanding parent, rather than being removed (and new children added to the expanding parent). This looks very confusing to the user - children should not appear to move between parents.

How can I change this behavior so that children do not move between parents?

vit001 commented 7 years ago

It seems making getChildViewType unique for each child fixes this issue. But is this the correct approach?

@Override
public int getChildViewType( int parentPosition, int childPosition ) {
    return 3 + parentPosition * mParentList.size() + childPosition;
}