1 /*
2  * Copyright (C) 2015 The Android Open Source Project
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  *      http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 
17 package android.support.design.widget;
18 
19 import android.support.v4.view.animation.FastOutLinearInInterpolator;
20 import android.support.v4.view.animation.FastOutSlowInInterpolator;
21 import android.support.v4.view.animation.LinearOutSlowInInterpolator;
22 import android.view.animation.Animation;
23 import android.view.animation.DecelerateInterpolator;
24 import android.view.animation.Interpolator;
25 import android.view.animation.LinearInterpolator;
26 
27 class AnimationUtils {
28 
29     static final Interpolator LINEAR_INTERPOLATOR = new LinearInterpolator();
30     static final Interpolator FAST_OUT_SLOW_IN_INTERPOLATOR = new FastOutSlowInInterpolator();
31     static final Interpolator FAST_OUT_LINEAR_IN_INTERPOLATOR = new FastOutLinearInInterpolator();
32     static final Interpolator LINEAR_OUT_SLOW_IN_INTERPOLATOR = new LinearOutSlowInInterpolator();
33     static final Interpolator DECELERATE_INTERPOLATOR = new DecelerateInterpolator();
34 
35     /**
36      * Linear interpolation between {@code startValue} and {@code endValue} by {@code fraction}.
37      */
lerp(float startValue, float endValue, float fraction)38     static float lerp(float startValue, float endValue, float fraction) {
39         return startValue + (fraction * (endValue - startValue));
40     }
41 
lerp(int startValue, int endValue, float fraction)42     static int lerp(int startValue, int endValue, float fraction) {
43         return startValue + Math.round(fraction * (endValue - startValue));
44     }
45 
46     static class AnimationListenerAdapter implements Animation.AnimationListener {
47         @Override
onAnimationStart(Animation animation)48         public void onAnimationStart(Animation animation) {
49         }
50 
51         @Override
onAnimationEnd(Animation animation)52         public void onAnimationEnd(Animation animation) {
53         }
54 
55         @Override
onAnimationRepeat(Animation animation)56         public void onAnimationRepeat(Animation animation) {
57         }
58     }
59 
60 }
61