Return 1f in Log(Ac/De)celerateInterpolators on a 1f input.

In battery saver mode, animations skip directly to the final values.
For LogDecelerateInterpolator, however, an input of 1f outputs an
interpolated 0.99999994. This meant that the FirstFrameAnimatorHelper
didn't realize that this was the last frame, and messed things up.
Since any interpolator should return 1 on an input of 1, we just
short-circuit in that case for the log interpolators.

Bug: 25666809
Change-Id: I60527e3758cea383fbcf50acb95460a7bd9ab43c
(cherry picked from commit 8dd2409923)
This commit is contained in:
Tony Wickham
2016-05-03 16:03:46 -07:00
parent f9a13f7cf8
commit bd42ba73b2
2 changed files with 6 additions and 2 deletions
@@ -20,6 +20,8 @@ public class LogAccelerateInterpolator implements TimeInterpolator {
@Override
public float getInterpolation(float t) {
return 1 - computeLog(1 - t, mBase, mDrift) * mLogScale;
// Due to rounding issues, the interpolation doesn't quite reach 1 even though it should.
// To account for this, we short-circuit to return 1 if the input is 1.
return Float.compare(t, 1f) == 0 ? 1f : 1 - computeLog(1 - t, mBase, mDrift) * mLogScale;
}
}
@@ -21,6 +21,8 @@ public class LogDecelerateInterpolator implements TimeInterpolator {
@Override
public float getInterpolation(float t) {
return computeLog(t, mBase, mDrift) * mLogScale;
// Due to rounding issues, the interpolation doesn't quite reach 1 even though it should.
// To account for this, we short-circuit to return 1 if the input is 1.
return Float.compare(t, 1f) == 0 ? 1f : computeLog(t, mBase, mDrift) * mLogScale;
}
}