Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

RecyclerView Animation #81

Closed
16meyrat opened this issue Apr 4, 2017 · 16 comments
Closed

RecyclerView Animation #81

16meyrat opened this issue Apr 4, 2017 · 16 comments

Comments

@16meyrat
Copy link

16meyrat commented Apr 4, 2017

When a RecyclerView is animated, it is first fully displayed, then disapears, and then the animation starts. Is their a way to launch the animation as soon as the Activity starts ?

@bret-fears
Copy link
Collaborator

The current example for recycler is calling the animation start in onLayoutChildren which, as you can see, is applying the animation to the children rather than when they are added. The proper path to take is to run the animation from a RecyclerView.ItemAnimator#animateAdd() call so the children are animated when they are added.

The drawback to using animateAdd is it'd apply the animations one at a time rather than to the group.

The path moving forward is to add native RecyclerView.ItemAnimator support which will hopefully be available in an upcoming release.

Thank you for calling this out!

@filol
Copy link

filol commented Apr 4, 2017

+1
I look forward to this new version

@rf43
Copy link
Member

rf43 commented May 10, 2017

@bret-fears We could probably label this as an Enhancement

@tfonfara
Copy link

+1 looking forward to that!

@tfonfara
Copy link

I think I found an easier solution for that problem than #79 is.

In Spruce.java:71 the animation will be delayed using setStartDelay(). This also delays the "setup" of the items which means the initial hiding.

If I change now

animatorCopy.setStartDelay(childView.getTimeOffset());

to

animatorCopy.start();
animatorCopy.cancel();
animatorCopy.setStartDelay(childView.getTimeOffset());

the animation starts (items will be hidden) but the actual animation is cancelled immediately. After that I can add the start delay and the full animation will be played as expected.

What do you think about that?
CC: @bret-fears

PS: Looks like this change only affects the initial recycler view animation, all other animations (recycler view onClick animation, all sort animations) still work fine and as previously in the sample app.

@bret-fears
Copy link
Collaborator

@tfonfara I like it! It's simple and solves the issue described by @lokither

@tfonfara
Copy link

tfonfara commented May 17, 2017

@bret-fears I'm pleased to hear that :) I noticed that you declined your pr, will you integrate my approach into the main code? ;)

@bret-fears
Copy link
Collaborator

@tfonfara you're welcome to submit a pull request. Otherwise, I'll gladly add that suggested change when I have time to.

@tfonfara
Copy link

@bret-fears there you go ;)

@bret-fears
Copy link
Collaborator

@tfonfara cheers! good work.

@bret-fears
Copy link
Collaborator

Closing this issue for now. Feel free to leave feedback here or open new issues as appropriate.

@tfonfara
Copy link

@bret-fears thanks a lot for approving and merging! Could you create a new release version from the updated master branch so this change is available as gradle dependency?

bret-fears added a commit that referenced this issue May 30, 2017
- Bump version number to 1.0.1 for recycler bug fix #81
@amanzan
Copy link

amanzan commented Jan 13, 2021

Hey @bret-fears I don't think this is fixed in version 1.0.2. In the Recycler Example, I still see what @16meyrat commented: RecyclerView is animated is first almost fully displayed, then disappears, and then the animation starts. It's quick but clearly visible...which is not ideal.

Is there anything I am missing? Attached video of the sample app

Screenrecorder-2021-01-13-15-18-23-263.mp4

@amanzan
Copy link

amanzan commented Jan 13, 2021

Also, @tfonfara fix makes children's setStartDelay to stop working. I added the fix manually, and now all RecyclerView children animate at the same time, instead of one by one!

Spruce.mp4

Edited for adding video.

@bret-fears I see this issue is quite old, maybe there is another way to fix this in the latest version?

@bret-fears
Copy link
Collaborator

@amanzan I have completely forgotten about this. I will re-open and investigate possible options around it so it doesn't interfere with other types of set animations.

@bret-fears bret-fears reopened this Jan 13, 2021
iamjosephmj added a commit to iamjosephmj/spruce-android that referenced this issue Jan 16, 2021
bret-fears added a commit that referenced this issue Jan 16, 2021
- Bump version to 1.0.3
@bret-fears
Copy link
Collaborator

bret-fears commented Jan 16, 2021

Fix has been merged and is available in patch version 1.0.3
https://github.com/willowtreeapps/spruce-android/releases/tag/1.0.3

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

6 participants