thoughtbot / expandable-recycler-view

Custom Android RecyclerViewAdapters that collapse and expand
https://robots.thoughtbot.com/introducing-expandablerecyclerview
MIT License
2.12k stars 391 forks source link

Fix for not working arrow rotations in expandablerecyclerview source #139

Open l2dev opened 6 years ago

l2dev commented 6 years ago

So basically if you remove expandablerecyclerviewcheck project and in your sample project you try to rely on project expandablerecyclerview like this compile project(':expandablerecyclerview') then you will have a bad time. When expanding the groups, arrows are just rotating 360 degrees and events are messed up.

I digged deeper and saw that expandablerecyclerview project is relying on expandablerecyclerviewcheck project which in the gradle has a dependency on the repo compile 'com.thoughtbot:expandablerecyclerview:1.3'

After lots of trial and error I've concluded that the repo 'com.thoughtbot:expandablerecyclerview:1.3' has this issue fixed, while in provided source it's not fixed.

So here's what you need to do to fix this:

  1. Go com/thoughtbot/expandablerecyclerview/ExpandCollapseController.java

Change:

boolean expanded = expandableList.expandedGroupIndexes[listPos.groupPos];

to:

boolean expanded = isGroupExpanded(listPos.groupPos);

  1. Go com/thoughtbot/expandablerecyclerview/ExpandableRecyclerViewAdapter.java

Delete this block

       if (isGroupExpanded(group)) {    
          ((GVH) holder).expand();  
        } else {    
          ((GVH) holder).collapse();    
        }

Delete this block in onGroupExpanded Method

    //update header 
    int headerPosition = positionStart - 1; 
    notifyItemChanged(headerPosition);  

Delete this block in OnGroupCollapsed Metod

    //update header 
   int headerPosition = positionStart - 1;  
    notifyItemChanged(headerPosition);
  1. Go com/thoughtbot/expandablerecyclerview/MultiTypeExpandableRecyclerViewAdapter.java

Delete block

      if (isGroupExpanded(group)) { 
        ((GVH) holder).expand();    
      } else {  
        ((GVH) holder).collapse();  
     }
  1. Go com/thoughtbot/expandablerecyclerview/viewholders/GroupViewHolder.java

Replace this line:

listener.onGroupClick(getAdapterPosition());

With block:

      if (listener.onGroupClick(getAdapterPosition())) {
        collapse();
      } else {
        expand();
     }
safeer-ahmed commented 6 years ago

Its not working as expected by the changes you placed above.

l2dev commented 6 years ago

And is the animation arrow working when you are using just a library 'com.thoughtbot:expandablerecyclerview:1.3' ?

safeer-ahmed commented 6 years ago

Yes, animation is working but arrow issue is still there.

nileshtrademonk commented 5 years ago

Is there any prevention for arrow management.

RiteshChandnani commented 5 years ago

Going only with Point 4 fixes the arrow issue for me :)

makazemi commented 5 years ago

@eurbon : How to change Library? Its class are only readable.