mirror of
https://github.com/LawnchairLauncher/lawnchair.git
synced 2026-03-01 00:06:47 +00:00
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
29 lines
838 B
Java
29 lines
838 B
Java
package com.android.launcher3;
|
|
|
|
import android.animation.TimeInterpolator;
|
|
|
|
public class LogDecelerateInterpolator implements TimeInterpolator {
|
|
|
|
int mBase;
|
|
int mDrift;
|
|
final float mLogScale;
|
|
|
|
public LogDecelerateInterpolator(int base, int drift) {
|
|
mBase = base;
|
|
mDrift = drift;
|
|
|
|
mLogScale = 1f / computeLog(1, mBase, mDrift);
|
|
}
|
|
|
|
static float computeLog(float t, int base, int drift) {
|
|
return (float) -Math.pow(base, -t) + 1 + (drift * t);
|
|
}
|
|
|
|
@Override
|
|
public float getInterpolation(float t) {
|
|
// 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;
|
|
}
|
|
}
|