| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
|
| 16 |
|
| 17 |
package android.view.animation; |
| 18 |
|
| 19 |
import android.content.Context; |
| 20 |
import android.graphics.animation.HasNativeInterpolator; |
| 21 |
import android.graphics.animation.NativeInterpolator; |
| 22 |
import android.graphics.animation.NativeInterpolatorFactory; |
| 23 |
import android.util.AttributeSet; |
| 24 |
|
| 25 |
|
| 26 |
|
| 27 |
|
| 28 |
@HasNativeInterpolator |
| 29 |
public class BounceInterpolator extends BaseInterpolator implements NativeInterpolator { |
| 30 |
public BounceInterpolator() { |
| 31 |
} |
| 32 |
|
| 33 |
@SuppressWarnings({"UnusedDeclaration"}) |
| 34 |
public BounceInterpolator(Context context, AttributeSet attrs) { |
| 35 |
} |
| 36 |
|
| 37 |
private static float bounce(float t) { |
| 38 |
return t * t * 8.0f; |
| 39 |
} |
| 40 |
|
| 41 |
public float getInterpolation(float t) { |
| 42 |
|
| 43 |
|
| 44 |
|
| 45 |
|
| 46 |
|
| 47 |
|
| 48 |
t *= 1.1226f; |
| 49 |
if (t < 0.3535f) return bounce(t); |
| 50 |
else if (t < 0.7408f) return bounce(t - 0.54719f) + 0.7f; |
| 51 |
else if (t < 0.9644f) return bounce(t - 0.8526f) + 0.9f; |
| 52 |
else return bounce(t - 1.0435f) + 0.95f; |
| 53 |
} |
| 54 |
|
| 55 |
|
| 56 |
@Override |
| 57 |
public long createNativeInterpolator() { |
| 58 |
return NativeInterpolatorFactory.createBounceInterpolator(); |
| 59 |
} |
| 60 |
} |