18b7af7188228ca88838e31e070f0fca0d1f90581Yao Chen/* 28b7af7188228ca88838e31e070f0fca0d1f90581Yao Chen * Copyright (C) 2015 The Android Open Source Project 38b7af7188228ca88838e31e070f0fca0d1f90581Yao Chen * 48b7af7188228ca88838e31e070f0fca0d1f90581Yao Chen * Licensed under the Apache License, Version 2.0 (the "License"); 58b7af7188228ca88838e31e070f0fca0d1f90581Yao Chen * you may not use this file except in compliance with the License. 68b7af7188228ca88838e31e070f0fca0d1f90581Yao Chen * You may obtain a copy of the License at 78b7af7188228ca88838e31e070f0fca0d1f90581Yao Chen * 88b7af7188228ca88838e31e070f0fca0d1f90581Yao Chen * http://www.apache.org/licenses/LICENSE-2.0 98b7af7188228ca88838e31e070f0fca0d1f90581Yao Chen * 108b7af7188228ca88838e31e070f0fca0d1f90581Yao Chen * Unless required by applicable law or agreed to in writing, software 118b7af7188228ca88838e31e070f0fca0d1f90581Yao Chen * distributed under the License is distributed on an "AS IS" BASIS, 128b7af7188228ca88838e31e070f0fca0d1f90581Yao Chen * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 138b7af7188228ca88838e31e070f0fca0d1f90581Yao Chen * See the License for the specific language governing permissions and 148b7af7188228ca88838e31e070f0fca0d1f90581Yao Chen * limitations under the License. 158b7af7188228ca88838e31e070f0fca0d1f90581Yao Chen */ 168b7af7188228ca88838e31e070f0fca0d1f90581Yao Chenpackage android.support.car.ui; 178b7af7188228ca88838e31e070f0fca0d1f90581Yao Chen 188b7af7188228ca88838e31e070f0fca0d1f90581Yao Chen 198b7af7188228ca88838e31e070f0fca0d1f90581Yao Chenimport android.animation.TimeInterpolator; 208b7af7188228ca88838e31e070f0fca0d1f90581Yao Chenimport android.support.annotation.NonNull; 218b7af7188228ca88838e31e070f0fca0d1f90581Yao Chen 228b7af7188228ca88838e31e070f0fca0d1f90581Yao Chen/** 238b7af7188228ca88838e31e070f0fca0d1f90581Yao Chen * Interpolator that can provide custom interpolations for forward and reverse animations 248b7af7188228ca88838e31e070f0fca0d1f90581Yao Chen */ 258b7af7188228ca88838e31e070f0fca0d1f90581Yao Chenpublic class ReversibleInterpolator { 268b7af7188228ca88838e31e070f0fca0d1f90581Yao Chen 278b7af7188228ca88838e31e070f0fca0d1f90581Yao Chen private final TimeInterpolator mForwardInterpolator; 288b7af7188228ca88838e31e070f0fca0d1f90581Yao Chen private final TimeInterpolator mReverseInterpolator; 298b7af7188228ca88838e31e070f0fca0d1f90581Yao Chen 308b7af7188228ca88838e31e070f0fca0d1f90581Yao Chen public ReversibleInterpolator(@NonNull TimeInterpolator forwardInterpolator, 318b7af7188228ca88838e31e070f0fca0d1f90581Yao Chen @NonNull TimeInterpolator reverseInterpolator) { 328b7af7188228ca88838e31e070f0fca0d1f90581Yao Chen mForwardInterpolator = forwardInterpolator; 338b7af7188228ca88838e31e070f0fca0d1f90581Yao Chen mReverseInterpolator = reverseInterpolator; 348b7af7188228ca88838e31e070f0fca0d1f90581Yao Chen } 358b7af7188228ca88838e31e070f0fca0d1f90581Yao Chen 368b7af7188228ca88838e31e070f0fca0d1f90581Yao Chen public float getForwardInterpolation(float input) { 378b7af7188228ca88838e31e070f0fca0d1f90581Yao Chen return mForwardInterpolator.getInterpolation(input); 388b7af7188228ca88838e31e070f0fca0d1f90581Yao Chen } 398b7af7188228ca88838e31e070f0fca0d1f90581Yao Chen 408b7af7188228ca88838e31e070f0fca0d1f90581Yao Chen public float getReverseInterpolation(float input) { 418b7af7188228ca88838e31e070f0fca0d1f90581Yao Chen return mReverseInterpolator.getInterpolation(input); 428b7af7188228ca88838e31e070f0fca0d1f90581Yao Chen } 438b7af7188228ca88838e31e070f0fca0d1f90581Yao Chen} 44