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
Collaborator

commented Jul 10, 2019

馃摙 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

nickbutcher added 3 commits Jul 10, 2019
if (springAnim == null) {
springAnim = SpringAnimation(this, property).apply {
spring = SpringForce().apply {
this.dampingRatio = damping

This comment has been minimized.

Copy link
@keyboardsurfer

keyboardsurfer Jul 10, 2019

Member

this can be confusing here. Consider naming the parameters.

This comment has been minimized.

Copy link
@nickbutcher

nickbutcher Jul 11, 2019

Author Collaborator

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

3 checks passed

ci/circleci: build Your tests passed on CircleCI!
Details
ci/circleci: test_instrumented Your tests passed on CircleCI!
Details
cla/google All necessary CLAs are signed

@nickbutcher nickbutcher deleted the nb/spring-item-animator branch Jul 11, 2019

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
3 participants
You can鈥檛 perform that action at this time.