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 17package android.support.design.widget; 18 19import android.support.v4.view.animation.FastOutLinearInInterpolator; 20import android.support.v4.view.animation.FastOutSlowInInterpolator; 21import android.support.v4.view.animation.LinearOutSlowInInterpolator; 22import android.view.animation.Animation; 23import android.view.animation.DecelerateInterpolator; 24import android.view.animation.Interpolator; 25import android.view.animation.LinearInterpolator; 26 27class 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 */ 38 static float lerp(float startValue, float endValue, float fraction) { 39 return startValue + (fraction * (endValue - startValue)); 40 } 41 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 48 public void onAnimationStart(Animation animation) { 49 } 50 51 @Override 52 public void onAnimationEnd(Animation animation) { 53 } 54 55 @Override 56 public void onAnimationRepeat(Animation animation) { 57 } 58 } 59 60} 61