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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use springs for RecyclerView.ItemAnimator #751

Merged
merged 4 commits into from Jul 11, 2019

Conversation

nickbutcher
Copy link
Owner

馃摙 Type of change

  • Bugfix
  • New feature
  • Enhancement
  • Refactoring

馃摐 Description

This change updates SlideInItemAnimator which is the base class of all custom RecyclerView.ItemAnimators, to use SpringAnimations when animating adding or moving items.

馃挕 Motivation and Context

This change supports smoother, re-targetable animations. Now if an item moves to a new position while a move is already happening, it respects the velocity of the running animation, smoothly re-targeting to the new end position.

馃挌 How did you test it?

Manually

馃摑 Checklist

  • I ran ./gradlew spotlessApply before submitting the PR
  • I reviewed submitted code
  • I added tests to verify changes
  • All tests passing

馃敭 Next steps

None

馃摳 Screenshots / GIFs

if (springAnim == null) {
springAnim = SpringAnimation(this, property).apply {
spring = SpringForce().apply {
this.dampingRatio = damping
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this can be confusing here. Consider naming the parameters.

Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually, should probably always configure the spring damping/stiffness, even if reusing an existing SpringAnimator. Will update.

@nickbutcher nickbutcher merged commit fb951b6 into master Jul 11, 2019
@nickbutcher nickbutcher deleted the nb/spring-item-animator branch July 11, 2019 09:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants