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.DecelerateInterpolator; 23 import android.view.animation.Interpolator; 24 import android.view.animation.LinearInterpolator; 25 26 class AnimationUtils { 27 28 static final Interpolator LINEAR_INTERPOLATOR = new LinearInterpolator(); 29 static final Interpolator FAST_OUT_SLOW_IN_INTERPOLATOR = new FastOutSlowInInterpolator(); 30 static final Interpolator FAST_OUT_LINEAR_IN_INTERPOLATOR = new FastOutLinearInInterpolator(); 31 static final Interpolator LINEAR_OUT_SLOW_IN_INTERPOLATOR = new LinearOutSlowInInterpolator(); 32 static final Interpolator DECELERATE_INTERPOLATOR = new DecelerateInterpolator(); 33 34 /** 35 * Linear interpolation between {@code startValue} and {@code endValue} by {@code fraction}. 36 */ lerp(float startValue, float endValue, float fraction)37 static float lerp(float startValue, float endValue, float fraction) { 38 return startValue + (fraction * (endValue - startValue)); 39 } 40 lerp(int startValue, int endValue, float fraction)41 static int lerp(int startValue, int endValue, float fraction) { 42 return startValue + Math.round(fraction * (endValue - startValue)); 43 } 44 45 } 46