facebookarchive / shimmer-android

An easy, flexible way to add a shimmering effect to any view in an Android app.
http://facebook.github.io/shimmer-android/
Other
5.31k stars 698 forks source link

[bug fix] the repeatDelay does not work right #105

Closed SuperWZ closed 3 years ago

facebook-github-bot commented 3 years ago

Hi @SuperWZ!

Thank you for your pull request and welcome to our community. We require contributors to sign our Contributor License Agreement, and we don't seem to have you on file.

In order for us to review and merge your code, please sign at https://code.facebook.com/cla. If you are contributing on behalf of someone else (eg your employer), the individual CLA may not be sufficient and your employer may need to sign the corporate CLA.

If you have received this in error or have any questions, please contact us at cla@fb.com. Thanks!

SuperWZ commented 3 years ago

just signed the CLA

facebook-github-bot commented 3 years ago

Thank you for signing our Contributor License Agreement. We can now accept your code for this (and any) Facebook open source project. Thanks!

xiphirx commented 3 years ago

Not sure what this is fixing, can you give an explanation?

AurimasSikorskas commented 3 years ago

Hello, I encountered the same bug, so I can add details, in hope that this gets fixed. The ValueAnimators value is already being set to as a fraction

mValueAnimator = ValueAnimator.ofFloat(0f, 1f + (mShimmer!!.repeatDelay / mShimmer!!.animationDuration).toFloat())
...
mValueAnimator.setDuration(mShimmer.animationDuration + mShimmer.repeatDelay);

So currently, because mValueAnimator.getAnimatedFraction() is being used, the repeatDelay gets compeltely ignored.

In short if mValueAnimator.getAnimatedValue() is used instead, we get the correct repeatDelay ex. if animation duration is 500ms and delay is 2000ms, then the animator duration is 2500, and it returns 1f at 500ms point and for the rest 1500ms it returns > 1.0f ("offscreen" values )

xiphirx commented 3 years ago

Thanks for the explanation and fix!

facebook-github-bot commented 3 years ago

@xiphirx merged this pull request in facebook/shimmer-android@fc81e7683009aa54ba9d82584dac32390b93924d.