Chet Haase | 17fb4b0 | 2010-06-28 17:55:07 -0700 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2010 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.animation; |
| 18 | |
| 19 | /** |
Chet Haase | a18a86b | 2010-09-07 13:20:00 -0700 | [diff] [blame] | 20 | * Interface for use with the {@link ValueAnimator#setEvaluator(TypeEvaluator)} function. Evaluators |
Chet Haase | 17fb4b0 | 2010-06-28 17:55:07 -0700 | [diff] [blame] | 21 | * allow developers to create animations on arbitrary property types, by allowing them to supply |
Sascha Haeberling | bac7526 | 2013-08-15 19:37:32 -0700 | [diff] [blame] | 22 | * custom evaluators for types that are not automatically understood and used by the animation |
Chet Haase | 17fb4b0 | 2010-06-28 17:55:07 -0700 | [diff] [blame] | 23 | * system. |
| 24 | * |
Chet Haase | a18a86b | 2010-09-07 13:20:00 -0700 | [diff] [blame] | 25 | * @see ValueAnimator#setEvaluator(TypeEvaluator) |
Chet Haase | 17fb4b0 | 2010-06-28 17:55:07 -0700 | [diff] [blame] | 26 | */ |
Chet Haase | b39f051 | 2011-05-24 14:36:40 -0700 | [diff] [blame] | 27 | public interface TypeEvaluator<T> { |
Chet Haase | 17fb4b0 | 2010-06-28 17:55:07 -0700 | [diff] [blame] | 28 | |
| 29 | /** |
| 30 | * This function returns the result of linearly interpolating the start and end values, with |
| 31 | * <code>fraction</code> representing the proportion between the start and end values. The |
Chet Haase | 5f9ea81 | 2014-05-06 17:07:16 -0700 | [diff] [blame] | 32 | * calculation is a simple parametric calculation: <code>result = x0 + t * (x1 - x0)</code>, |
Chet Haase | 17fb4b0 | 2010-06-28 17:55:07 -0700 | [diff] [blame] | 33 | * where <code>x0</code> is <code>startValue</code>, <code>x1</code> is <code>endValue</code>, |
| 34 | * and <code>t</code> is <code>fraction</code>. |
| 35 | * |
| 36 | * @param fraction The fraction from the starting to the ending values |
| 37 | * @param startValue The start value. |
| 38 | * @param endValue The end value. |
| 39 | * @return A linear interpolation between the start and end values, given the |
| 40 | * <code>fraction</code> parameter. |
| 41 | */ |
Chet Haase | b39f051 | 2011-05-24 14:36:40 -0700 | [diff] [blame] | 42 | public T evaluate(float fraction, T startValue, T endValue); |
Chet Haase | 17fb4b0 | 2010-06-28 17:55:07 -0700 | [diff] [blame] | 43 | |
Sascha Haeberling | bac7526 | 2013-08-15 19:37:32 -0700 | [diff] [blame] | 44 | } |