ObjectAnimator.java revision a18a86b43e40e3c15dcca0ae0148d641be9b25fe
117fb4b0d1cfbad1f026fec704c86640f070b4c2fChet Haase/*
217fb4b0d1cfbad1f026fec704c86640f070b4c2fChet Haase * Copyright (C) 2010 The Android Open Source Project
317fb4b0d1cfbad1f026fec704c86640f070b4c2fChet Haase *
417fb4b0d1cfbad1f026fec704c86640f070b4c2fChet Haase * Licensed under the Apache License, Version 2.0 (the "License");
517fb4b0d1cfbad1f026fec704c86640f070b4c2fChet Haase * you may not use this file except in compliance with the License.
617fb4b0d1cfbad1f026fec704c86640f070b4c2fChet Haase * You may obtain a copy of the License at
717fb4b0d1cfbad1f026fec704c86640f070b4c2fChet Haase *
817fb4b0d1cfbad1f026fec704c86640f070b4c2fChet Haase *      http://www.apache.org/licenses/LICENSE-2.0
917fb4b0d1cfbad1f026fec704c86640f070b4c2fChet Haase *
1017fb4b0d1cfbad1f026fec704c86640f070b4c2fChet Haase * Unless required by applicable law or agreed to in writing, software
1117fb4b0d1cfbad1f026fec704c86640f070b4c2fChet Haase * distributed under the License is distributed on an "AS IS" BASIS,
1217fb4b0d1cfbad1f026fec704c86640f070b4c2fChet Haase * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1317fb4b0d1cfbad1f026fec704c86640f070b4c2fChet Haase * See the License for the specific language governing permissions and
1417fb4b0d1cfbad1f026fec704c86640f070b4c2fChet Haase * limitations under the License.
1517fb4b0d1cfbad1f026fec704c86640f070b4c2fChet Haase */
1617fb4b0d1cfbad1f026fec704c86640f070b4c2fChet Haase
1717fb4b0d1cfbad1f026fec704c86640f070b4c2fChet Haasepackage android.animation;
1817fb4b0d1cfbad1f026fec704c86640f070b4c2fChet Haase
1917fb4b0d1cfbad1f026fec704c86640f070b4c2fChet Haaseimport android.util.Log;
2017fb4b0d1cfbad1f026fec704c86640f070b4c2fChet Haase
2117fb4b0d1cfbad1f026fec704c86640f070b4c2fChet Haaseimport java.lang.reflect.Method;
2217fb4b0d1cfbad1f026fec704c86640f070b4c2fChet Haase
2317fb4b0d1cfbad1f026fec704c86640f070b4c2fChet Haase/**
24a18a86b43e40e3c15dcca0ae0148d641be9b25feChet Haase * This subclass of {@link ValueAnimator} provides support for animating properties on target objects.
2517fb4b0d1cfbad1f026fec704c86640f070b4c2fChet Haase * The constructors of this class take parameters to define the target object that will be animated
2617fb4b0d1cfbad1f026fec704c86640f070b4c2fChet Haase * as well as the name of the property that will be animated. Appropriate set/get functions
2717fb4b0d1cfbad1f026fec704c86640f070b4c2fChet Haase * are then determined internally and the animation will call these functions as necessary to
2817fb4b0d1cfbad1f026fec704c86640f070b4c2fChet Haase * animate the property.
2917fb4b0d1cfbad1f026fec704c86640f070b4c2fChet Haase */
30a18a86b43e40e3c15dcca0ae0148d641be9b25feChet Haasepublic final class ObjectAnimator<T> extends ValueAnimator<T> {
3117fb4b0d1cfbad1f026fec704c86640f070b4c2fChet Haase
3217fb4b0d1cfbad1f026fec704c86640f070b4c2fChet Haase    // The target object on which the property exists, set in the constructor
3317fb4b0d1cfbad1f026fec704c86640f070b4c2fChet Haase    private Object mTarget;
3417fb4b0d1cfbad1f026fec704c86640f070b4c2fChet Haase
3517fb4b0d1cfbad1f026fec704c86640f070b4c2fChet Haase    private String mPropertyName;
3617fb4b0d1cfbad1f026fec704c86640f070b4c2fChet Haase
3717fb4b0d1cfbad1f026fec704c86640f070b4c2fChet Haase    /**
3817fb4b0d1cfbad1f026fec704c86640f070b4c2fChet Haase     * Sets the name of the property that will be animated. This name is used to derive
3917fb4b0d1cfbad1f026fec704c86640f070b4c2fChet Haase     * a setter function that will be called to set animated values.
4017fb4b0d1cfbad1f026fec704c86640f070b4c2fChet Haase     * For example, a property name of <code>foo</code> will result
4117fb4b0d1cfbad1f026fec704c86640f070b4c2fChet Haase     * in a call to the function <code>setFoo()</code> on the target object. If either
4217fb4b0d1cfbad1f026fec704c86640f070b4c2fChet Haase     * <code>valueFrom</code> or <code>valueTo</code> is null, then a getter function will
4317fb4b0d1cfbad1f026fec704c86640f070b4c2fChet Haase     * also be derived and called.
4417fb4b0d1cfbad1f026fec704c86640f070b4c2fChet Haase     *
4517fb4b0d1cfbad1f026fec704c86640f070b4c2fChet Haase     * <p>Note that the setter function derived from this property name
4617fb4b0d1cfbad1f026fec704c86640f070b4c2fChet Haase     * must take the same parameter type as the
4717fb4b0d1cfbad1f026fec704c86640f070b4c2fChet Haase     * <code>valueFrom</code> and <code>valueTo</code> properties, otherwise the call to
4817fb4b0d1cfbad1f026fec704c86640f070b4c2fChet Haase     * the setter function will fail.</p>
4917fb4b0d1cfbad1f026fec704c86640f070b4c2fChet Haase     *
50a18a86b43e40e3c15dcca0ae0148d641be9b25feChet Haase     * <p>If this ObjectAnimator has been set up to animate several properties together,
51d953d08e9299072130d9f4411cbcf6678bbce822Chet Haase     * using more than one PropertyValuesHolder objects, then setting the propertyName simply
52d953d08e9299072130d9f4411cbcf6678bbce822Chet Haase     * sets the propertyName in the first of those PropertyValuesHolder objects.</p>
53d953d08e9299072130d9f4411cbcf6678bbce822Chet Haase     *
5417fb4b0d1cfbad1f026fec704c86640f070b4c2fChet Haase     * @param propertyName The name of the property being animated.
5517fb4b0d1cfbad1f026fec704c86640f070b4c2fChet Haase     */
5617fb4b0d1cfbad1f026fec704c86640f070b4c2fChet Haase    public void setPropertyName(String propertyName) {
57d953d08e9299072130d9f4411cbcf6678bbce822Chet Haase        if (mValues != null) {
58602e4d3824bf8b9cb9f817375d195b969712176aChet Haase            // mValues should always be non-null
59602e4d3824bf8b9cb9f817375d195b969712176aChet Haase            PropertyValuesHolder valuesHolder = mValues[0];
60602e4d3824bf8b9cb9f817375d195b969712176aChet Haase            String oldName = valuesHolder.getPropertyName();
61d953d08e9299072130d9f4411cbcf6678bbce822Chet Haase            valuesHolder.setPropertyName(propertyName);
62602e4d3824bf8b9cb9f817375d195b969712176aChet Haase            mValuesMap.remove(oldName);
63602e4d3824bf8b9cb9f817375d195b969712176aChet Haase            mValuesMap.put(propertyName, valuesHolder);
64d953d08e9299072130d9f4411cbcf6678bbce822Chet Haase        }
6517fb4b0d1cfbad1f026fec704c86640f070b4c2fChet Haase        mPropertyName = propertyName;
6617fb4b0d1cfbad1f026fec704c86640f070b4c2fChet Haase    }
6717fb4b0d1cfbad1f026fec704c86640f070b4c2fChet Haase
6817fb4b0d1cfbad1f026fec704c86640f070b4c2fChet Haase    /**
6917fb4b0d1cfbad1f026fec704c86640f070b4c2fChet Haase     * Gets the name of the property that will be animated. This name will be used to derive
7017fb4b0d1cfbad1f026fec704c86640f070b4c2fChet Haase     * a setter function that will be called to set animated values.
7117fb4b0d1cfbad1f026fec704c86640f070b4c2fChet Haase     * For example, a property name of <code>foo</code> will result
7217fb4b0d1cfbad1f026fec704c86640f070b4c2fChet Haase     * in a call to the function <code>setFoo()</code> on the target object. If either
7317fb4b0d1cfbad1f026fec704c86640f070b4c2fChet Haase     * <code>valueFrom</code> or <code>valueTo</code> is null, then a getter function will
7417fb4b0d1cfbad1f026fec704c86640f070b4c2fChet Haase     * also be derived and called.
7517fb4b0d1cfbad1f026fec704c86640f070b4c2fChet Haase     */
7617fb4b0d1cfbad1f026fec704c86640f070b4c2fChet Haase    public String getPropertyName() {
7717fb4b0d1cfbad1f026fec704c86640f070b4c2fChet Haase        return mPropertyName;
7817fb4b0d1cfbad1f026fec704c86640f070b4c2fChet Haase    }
7917fb4b0d1cfbad1f026fec704c86640f070b4c2fChet Haase
8017fb4b0d1cfbad1f026fec704c86640f070b4c2fChet Haase    /**
8117fb4b0d1cfbad1f026fec704c86640f070b4c2fChet Haase     * Determine the setter or getter function using the JavaBeans convention of setFoo or
8217fb4b0d1cfbad1f026fec704c86640f070b4c2fChet Haase     * getFoo for a property named 'foo'. This function figures out what the name of the
8317fb4b0d1cfbad1f026fec704c86640f070b4c2fChet Haase     * function should be and uses reflection to find the Method with that name on the
8417fb4b0d1cfbad1f026fec704c86640f070b4c2fChet Haase     * target object.
8517fb4b0d1cfbad1f026fec704c86640f070b4c2fChet Haase     *
8617fb4b0d1cfbad1f026fec704c86640f070b4c2fChet Haase     * @param prefix "set" or "get", depending on whether we need a setter or getter.
8717fb4b0d1cfbad1f026fec704c86640f070b4c2fChet Haase     * @return Method the method associated with mPropertyName.
8817fb4b0d1cfbad1f026fec704c86640f070b4c2fChet Haase     */
89fe591563f8529305bd52e1f0640e83b9a93d562fChet Haase    private Method getPropertyFunction(String prefix, Class valueType) {
9017fb4b0d1cfbad1f026fec704c86640f070b4c2fChet Haase        // TODO: faster implementation...
9117fb4b0d1cfbad1f026fec704c86640f070b4c2fChet Haase        Method returnVal = null;
9217fb4b0d1cfbad1f026fec704c86640f070b4c2fChet Haase        String firstLetter = mPropertyName.substring(0, 1);
9317fb4b0d1cfbad1f026fec704c86640f070b4c2fChet Haase        String theRest = mPropertyName.substring(1);
9417fb4b0d1cfbad1f026fec704c86640f070b4c2fChet Haase        firstLetter = firstLetter.toUpperCase();
9517fb4b0d1cfbad1f026fec704c86640f070b4c2fChet Haase        String setterName = prefix + firstLetter + theRest;
96fe591563f8529305bd52e1f0640e83b9a93d562fChet Haase        Class args[] = null;
97fe591563f8529305bd52e1f0640e83b9a93d562fChet Haase        if (valueType != null) {
98fe591563f8529305bd52e1f0640e83b9a93d562fChet Haase            args = new Class[1];
99fe591563f8529305bd52e1f0640e83b9a93d562fChet Haase            args[0] = valueType;
100fe591563f8529305bd52e1f0640e83b9a93d562fChet Haase        }
10117fb4b0d1cfbad1f026fec704c86640f070b4c2fChet Haase        try {
10217fb4b0d1cfbad1f026fec704c86640f070b4c2fChet Haase            returnVal = mTarget.getClass().getMethod(setterName, args);
10317fb4b0d1cfbad1f026fec704c86640f070b4c2fChet Haase        } catch (NoSuchMethodException e) {
104a18a86b43e40e3c15dcca0ae0148d641be9b25feChet Haase            Log.e("ObjectAnimator",
105fe591563f8529305bd52e1f0640e83b9a93d562fChet Haase                    "Couldn't find setter/getter for property " + mPropertyName + ": " + e);
10617fb4b0d1cfbad1f026fec704c86640f070b4c2fChet Haase        }
10717fb4b0d1cfbad1f026fec704c86640f070b4c2fChet Haase        return returnVal;
10817fb4b0d1cfbad1f026fec704c86640f070b4c2fChet Haase    }
10917fb4b0d1cfbad1f026fec704c86640f070b4c2fChet Haase
11017fb4b0d1cfbad1f026fec704c86640f070b4c2fChet Haase    /**
111a18a86b43e40e3c15dcca0ae0148d641be9b25feChet Haase     * Creates a new ObjectAnimator object. This default constructor is primarily for
112d51d368f2d512ab657b8ae45780c82c0dbea94c3Chet Haase     * use internally; the other constructors which take parameters are more generally
113d51d368f2d512ab657b8ae45780c82c0dbea94c3Chet Haase     * useful.
114d51d368f2d512ab657b8ae45780c82c0dbea94c3Chet Haase     */
115a18a86b43e40e3c15dcca0ae0148d641be9b25feChet Haase    public ObjectAnimator() {
116d51d368f2d512ab657b8ae45780c82c0dbea94c3Chet Haase    }
117d51d368f2d512ab657b8ae45780c82c0dbea94c3Chet Haase
118d51d368f2d512ab657b8ae45780c82c0dbea94c3Chet Haase    /**
119d953d08e9299072130d9f4411cbcf6678bbce822Chet Haase     * A constructor that takes a single property name and set of values. This constructor is
120d953d08e9299072130d9f4411cbcf6678bbce822Chet Haase     * used in the simple case of animating a single property.
121fe591563f8529305bd52e1f0640e83b9a93d562fChet Haase     *
122fe591563f8529305bd52e1f0640e83b9a93d562fChet Haase     * @param duration The length of the animation, in milliseconds.
123fe591563f8529305bd52e1f0640e83b9a93d562fChet Haase     * @param target The object whose property is to be animated. This object should
124d953d08e9299072130d9f4411cbcf6678bbce822Chet Haase     * have a public method on it called <code>setName()</code>, where <code>name</code> is
125d953d08e9299072130d9f4411cbcf6678bbce822Chet Haase     * the value of the <code>propertyName</code> parameter.
126d953d08e9299072130d9f4411cbcf6678bbce822Chet Haase     * @param propertyName The name of the property being animated.
127d953d08e9299072130d9f4411cbcf6678bbce822Chet Haase     * @param values The set of values to animate between. If there is only one value, it
128d953d08e9299072130d9f4411cbcf6678bbce822Chet Haase     * is assumed to be the final value being animated to, and the initial value will be
129d953d08e9299072130d9f4411cbcf6678bbce822Chet Haase     * derived on the fly.
130fe591563f8529305bd52e1f0640e83b9a93d562fChet Haase     */
131a18a86b43e40e3c15dcca0ae0148d641be9b25feChet Haase    public ObjectAnimator(long duration, Object target, String propertyName, T...values) {
132d953d08e9299072130d9f4411cbcf6678bbce822Chet Haase        super(duration, (T[]) values);
133fe591563f8529305bd52e1f0640e83b9a93d562fChet Haase        mTarget = target;
134d953d08e9299072130d9f4411cbcf6678bbce822Chet Haase        setPropertyName(propertyName);
135fe591563f8529305bd52e1f0640e83b9a93d562fChet Haase    }
136fe591563f8529305bd52e1f0640e83b9a93d562fChet Haase
137fe591563f8529305bd52e1f0640e83b9a93d562fChet Haase    /**
138d953d08e9299072130d9f4411cbcf6678bbce822Chet Haase     * A constructor that takes <code>PropertyValueHolder</code> values. This constructor should
139a18a86b43e40e3c15dcca0ae0148d641be9b25feChet Haase     * be used when animating several properties at once with the same ObjectAnimator, since
140d953d08e9299072130d9f4411cbcf6678bbce822Chet Haase     * PropertyValuesHolder allows you to associate a set of animation values with a property
141d953d08e9299072130d9f4411cbcf6678bbce822Chet Haase     * name.
14217fb4b0d1cfbad1f026fec704c86640f070b4c2fChet Haase     *
14317fb4b0d1cfbad1f026fec704c86640f070b4c2fChet Haase     * @param duration The length of the animation, in milliseconds.
14417fb4b0d1cfbad1f026fec704c86640f070b4c2fChet Haase     * @param target The object whose property is to be animated. This object should
145d953d08e9299072130d9f4411cbcf6678bbce822Chet Haase     * have public methods on it called <code>setName()</code>, where <code>name</code> is
146d953d08e9299072130d9f4411cbcf6678bbce822Chet Haase     * the name of the property passed in as the <code>propertyName</code> parameter for
147d953d08e9299072130d9f4411cbcf6678bbce822Chet Haase     * each of the PropertyValuesHolder objects.
148d953d08e9299072130d9f4411cbcf6678bbce822Chet Haase     * @param values The PropertyValuesHolder objects which hold each the property name and values
149d953d08e9299072130d9f4411cbcf6678bbce822Chet Haase     * to animate that property between.
150d953d08e9299072130d9f4411cbcf6678bbce822Chet Haase     */
151a18a86b43e40e3c15dcca0ae0148d641be9b25feChet Haase    public ObjectAnimator(long duration, Object target, PropertyValuesHolder...values) {
152d953d08e9299072130d9f4411cbcf6678bbce822Chet Haase        super(duration);
153d953d08e9299072130d9f4411cbcf6678bbce822Chet Haase        setValues(values);
15417fb4b0d1cfbad1f026fec704c86640f070b4c2fChet Haase        mTarget = target;
1553dd207a6dbd5d9244dc7fe213d5caa3cddaff0dbChet Haase    }
1563dd207a6dbd5d9244dc7fe213d5caa3cddaff0dbChet Haase
1573dd207a6dbd5d9244dc7fe213d5caa3cddaff0dbChet Haase    /**
15817fb4b0d1cfbad1f026fec704c86640f070b4c2fChet Haase     * This function is called immediately before processing the first animation
15917fb4b0d1cfbad1f026fec704c86640f070b4c2fChet Haase     * frame of an animation. If there is a nonzero <code>startDelay</code>, the
16017fb4b0d1cfbad1f026fec704c86640f070b4c2fChet Haase     * function is called after that delay ends.
16117fb4b0d1cfbad1f026fec704c86640f070b4c2fChet Haase     * It takes care of the final initialization steps for the
16217fb4b0d1cfbad1f026fec704c86640f070b4c2fChet Haase     * animation. This includes setting mEvaluator, if the user has not yet
16317fb4b0d1cfbad1f026fec704c86640f070b4c2fChet Haase     * set it up, and the setter/getter methods, if the user did not supply
16417fb4b0d1cfbad1f026fec704c86640f070b4c2fChet Haase     * them.
16517fb4b0d1cfbad1f026fec704c86640f070b4c2fChet Haase     *
16617fb4b0d1cfbad1f026fec704c86640f070b4c2fChet Haase     *  <p>Overriders of this method should call the superclass method to cause
16717fb4b0d1cfbad1f026fec704c86640f070b4c2fChet Haase     *  internal mechanisms to be set up correctly.</p>
16817fb4b0d1cfbad1f026fec704c86640f070b4c2fChet Haase     */
16917fb4b0d1cfbad1f026fec704c86640f070b4c2fChet Haase    @Override
17017fb4b0d1cfbad1f026fec704c86640f070b4c2fChet Haase    void initAnimation() {
17121cd1389d2ef218b20994b617c57af120841a57fChet Haase        if (!mInitialized) {
17221cd1389d2ef218b20994b617c57af120841a57fChet Haase            // mValueType may change due to setter/getter setup; do this before calling super.init(),
17321cd1389d2ef218b20994b617c57af120841a57fChet Haase            // which uses mValueType to set up the default type evaluator.
17421cd1389d2ef218b20994b617c57af120841a57fChet Haase            int numValues = mValues.length;
17521cd1389d2ef218b20994b617c57af120841a57fChet Haase            for (int i = 0; i < numValues; ++i) {
17621cd1389d2ef218b20994b617c57af120841a57fChet Haase                mValues[i].setupSetterAndGetter(mTarget);
17721cd1389d2ef218b20994b617c57af120841a57fChet Haase            }
17821cd1389d2ef218b20994b617c57af120841a57fChet Haase            super.initAnimation();
17917fb4b0d1cfbad1f026fec704c86640f070b4c2fChet Haase        }
18017fb4b0d1cfbad1f026fec704c86640f070b4c2fChet Haase    }
18117fb4b0d1cfbad1f026fec704c86640f070b4c2fChet Haase
18217fb4b0d1cfbad1f026fec704c86640f070b4c2fChet Haase
18317fb4b0d1cfbad1f026fec704c86640f070b4c2fChet Haase    /**
18417fb4b0d1cfbad1f026fec704c86640f070b4c2fChet Haase     * The target object whose property will be animated by this animation
18517fb4b0d1cfbad1f026fec704c86640f070b4c2fChet Haase     *
18617fb4b0d1cfbad1f026fec704c86640f070b4c2fChet Haase     * @return The object being animated
18717fb4b0d1cfbad1f026fec704c86640f070b4c2fChet Haase     */
18817fb4b0d1cfbad1f026fec704c86640f070b4c2fChet Haase    public Object getTarget() {
18917fb4b0d1cfbad1f026fec704c86640f070b4c2fChet Haase        return mTarget;
19017fb4b0d1cfbad1f026fec704c86640f070b4c2fChet Haase    }
19117fb4b0d1cfbad1f026fec704c86640f070b4c2fChet Haase
19217fb4b0d1cfbad1f026fec704c86640f070b4c2fChet Haase    /**
193f54a8d7c479485174941c38f151ea7083c658da3Chet Haase     * Sets the target object whose property will be animated by this animation
194f54a8d7c479485174941c38f151ea7083c658da3Chet Haase     *
195f54a8d7c479485174941c38f151ea7083c658da3Chet Haase     * @param target The object being animated
196f54a8d7c479485174941c38f151ea7083c658da3Chet Haase     */
19721cd1389d2ef218b20994b617c57af120841a57fChet Haase    @Override
198f54a8d7c479485174941c38f151ea7083c658da3Chet Haase    public void setTarget(Object target) {
199f54a8d7c479485174941c38f151ea7083c658da3Chet Haase        mTarget = target;
200f54a8d7c479485174941c38f151ea7083c658da3Chet Haase    }
201f54a8d7c479485174941c38f151ea7083c658da3Chet Haase
20221cd1389d2ef218b20994b617c57af120841a57fChet Haase    @Override
20321cd1389d2ef218b20994b617c57af120841a57fChet Haase    public void setupStartValues() {
20421cd1389d2ef218b20994b617c57af120841a57fChet Haase        initAnimation();
20521cd1389d2ef218b20994b617c57af120841a57fChet Haase        int numValues = mValues.length;
20621cd1389d2ef218b20994b617c57af120841a57fChet Haase        for (int i = 0; i < numValues; ++i) {
20721cd1389d2ef218b20994b617c57af120841a57fChet Haase            mValues[i].setupStartValue(mTarget);
20821cd1389d2ef218b20994b617c57af120841a57fChet Haase        }
20921cd1389d2ef218b20994b617c57af120841a57fChet Haase    }
21021cd1389d2ef218b20994b617c57af120841a57fChet Haase
21121cd1389d2ef218b20994b617c57af120841a57fChet Haase    @Override
21221cd1389d2ef218b20994b617c57af120841a57fChet Haase    public void setupEndValues() {
21321cd1389d2ef218b20994b617c57af120841a57fChet Haase        initAnimation();
21421cd1389d2ef218b20994b617c57af120841a57fChet Haase        int numValues = mValues.length;
21521cd1389d2ef218b20994b617c57af120841a57fChet Haase        for (int i = 0; i < numValues; ++i) {
21621cd1389d2ef218b20994b617c57af120841a57fChet Haase            mValues[i].setupEndValue(mTarget);
21721cd1389d2ef218b20994b617c57af120841a57fChet Haase        }
21821cd1389d2ef218b20994b617c57af120841a57fChet Haase    }
21921cd1389d2ef218b20994b617c57af120841a57fChet Haase
220f54a8d7c479485174941c38f151ea7083c658da3Chet Haase    /**
22117fb4b0d1cfbad1f026fec704c86640f070b4c2fChet Haase     * This method is called with the elapsed fraction of the animation during every
22217fb4b0d1cfbad1f026fec704c86640f070b4c2fChet Haase     * animation frame. This function turns the elapsed fraction into an interpolated fraction
22317fb4b0d1cfbad1f026fec704c86640f070b4c2fChet Haase     * and then into an animated value (from the evaluator. The function is called mostly during
22417fb4b0d1cfbad1f026fec704c86640f070b4c2fChet Haase     * animation updates, but it is also called when the <code>end()</code>
22517fb4b0d1cfbad1f026fec704c86640f070b4c2fChet Haase     * function is called, to set the final value on the property.
22617fb4b0d1cfbad1f026fec704c86640f070b4c2fChet Haase     *
22717fb4b0d1cfbad1f026fec704c86640f070b4c2fChet Haase     * <p>Overrides of this method must call the superclass to perform the calculation
22817fb4b0d1cfbad1f026fec704c86640f070b4c2fChet Haase     * of the animated value.</p>
22917fb4b0d1cfbad1f026fec704c86640f070b4c2fChet Haase     *
23017fb4b0d1cfbad1f026fec704c86640f070b4c2fChet Haase     * @param fraction The elapsed fraction of the animation.
23117fb4b0d1cfbad1f026fec704c86640f070b4c2fChet Haase     */
23217fb4b0d1cfbad1f026fec704c86640f070b4c2fChet Haase    @Override
23317fb4b0d1cfbad1f026fec704c86640f070b4c2fChet Haase    void animateValue(float fraction) {
23417fb4b0d1cfbad1f026fec704c86640f070b4c2fChet Haase        super.animateValue(fraction);
235602e4d3824bf8b9cb9f817375d195b969712176aChet Haase        int numValues = mValues.length;
236602e4d3824bf8b9cb9f817375d195b969712176aChet Haase        for (int i = 0; i < numValues; ++i) {
237602e4d3824bf8b9cb9f817375d195b969712176aChet Haase            mValues[i].setAnimatedValue(mTarget);
23817fb4b0d1cfbad1f026fec704c86640f070b4c2fChet Haase        }
23917fb4b0d1cfbad1f026fec704c86640f070b4c2fChet Haase    }
24049afa5bc100e5d4c069fea980dd6b09501f56397Chet Haase
24149afa5bc100e5d4c069fea980dd6b09501f56397Chet Haase    @Override
242a18a86b43e40e3c15dcca0ae0148d641be9b25feChet Haase    public ObjectAnimator clone() {
243a18a86b43e40e3c15dcca0ae0148d641be9b25feChet Haase        final ObjectAnimator anim = (ObjectAnimator) super.clone();
24449afa5bc100e5d4c069fea980dd6b09501f56397Chet Haase        return anim;
24549afa5bc100e5d4c069fea980dd6b09501f56397Chet Haase    }
24617fb4b0d1cfbad1f026fec704c86640f070b4c2fChet Haase}
247