Comments (5)
@HoLuong0211 I would recommend using one of the adapter.toggleGroup()
methods to toggle a group. This will ensure the expandCollapseController
is aware of the expanded / collapsed state of all groups. The adapter uses this class to determine whether to call expand
or collapse
animations. So if that controller becomes out of sync, that is one reason why you might be seeing the wrong animations being called.
from expandable-recycler-view.
@mandybess I replaced onGroupClick(holder.getAdapterPosition());
method by toggleGroup(holder.getAdapterPosition())
but it still the same, my indication arrow still not animate the right way.
Could you please explain with a little more detail about your idea for this issue.
Thank you for your help!
from expandable-recycler-view.
If you are calling this method inside onCreateGroupViewHolder
then all of the work is being executed before the group click listener is applied to the group view holder. That might be why you are experiencing some weirdness. I would recommend calling toggleGroup
after the adapter has had a chance to create and bind all view holders
from expandable-recycler-view.
@mandybess I moved all code from ChatGroupAdapter to my Activity:
List<ParentExpandable> expandableList = getListChatGroup(); final ChatGroupAdapter adapter = new ChatGroupAdapter(this, expandableList); recyclerView.setLayoutManager(layoutManager); recyclerView.setAdapter(adapter); if (adapter.getGroups().size() > 0) { new Handler().postDelayed(new Runnable() { @Override public void run() { for (int i = 0; i < adapter.getGroups().size(); i++) { ChatGroupParentVH holder = (ChatGroupParentVH) recyclerView.getChildViewHolder(recyclerView.getChildAt(i)); adapter.toggleGroup(holder.getAdapterPosition()); holder.expand(); } } }, 1000); }
The group items was expanding for the first time and the indication arrow animate the right way, but when I click on the indication arrow for the second time it still when to ChatGroupParentVH.expand()
method.
Or maybe I didn't get your idea. Could you please explain your solution for this issue.
Thank you so much!
from expandable-recycler-view.
I have solution for you @HoLuong1609
Step 1: after recyclerView.setAdapter(adapter);
Please set adapter.toggleGroup()
Step 2: In function onBindGroupViewHolder of Adapter please check:
boolean isExpand = isGroupExpanded(flatPosition);
if(group instanceof ChatGroupParentVH){
if(isExpand){
((ChatGroupParentVH) holder).animateExpand(0);
}else {
((ChatGroupParentVH) holder).animateCollapse(0);
}
}
You can reference the code of animateExapand in below
public ObjectAnimator createRotateAnimator(final View target, final float from, final float to, int duration) {
ObjectAnimator animator = ObjectAnimator.ofFloat(target, "rotation", from, to);
animator.setDuration(duration);
animator.setInterpolator(Utils.createInterpolator(Utils.LINEAR_INTERPOLATOR));
return animator;
}
private void animateExpand(int duration) {
createRotateAnimator(view, 0f, 180f,duration).start();
}
private void animateCollapse(int duration) {
createRotateAnimator(view, 180f, 0f,duration).start();
}
It's worked for me
from expandable-recycler-view.
Related Issues (20)
- when i click on artist itemview and back again recycler view is gone HOT 1
- Add data from api
- Is it possible to put single and multiple check items in one recyclerview?
- Display the same background for Childs
- MultiTypeExpandableRecyclerViewAdapter automatically use animation in OnStart method
- How to use it with Paging HOT 1
- Tried to use preview panel provider (JavaFX WebView), but it is unavailable. Reverting to default
- There is a `toggleGroup` function which will expand a group if it is collapsed
- collapse will be called automaticly when start activity. HOT 1
- Duplicate child when expanding parents multiple times (latest release) HOT 1
- why child's default interval is big and how to setting?
- Strange Behavior on Dynamic Group Header Size
- EXPAND_STATE_MAP is private
- Migrate away from jCenter HOT 5
- Element Sorting
- When app not used for a while, expandablerecyclerview menus are empty HOT 1
- Expand and collapse smoothly HOT 1
- Allow me push access...I have updated the project to latest environment
- Error dowloading library HOT 1
- Unable to add lib in new created project (Android Studio Giraffe | 2022.3.1) HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from expandable-recycler-view.