ObjectAnimator.java revision 83d6e8213230fb0805aa019d266842253baeb114
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 */
3083d6e8213230fb0805aa019d266842253baeb114Romain Guypublic 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) {
570e0590bf3cb32e73f423c0fe39a180d4b3c4343dChet Haase        // mValues could be null if this is being constructed piecemeal. Just record the
580e0590bf3cb32e73f423c0fe39a180d4b3c4343dChet Haase        // propertyName to be used later when setValues() is called if so.
59d953d08e9299072130d9f4411cbcf6678bbce822Chet Haase        if (mValues != null) {
60602e4d3824bf8b9cb9f817375d195b969712176aChet Haase            PropertyValuesHolder valuesHolder = mValues[0];
61602e4d3824bf8b9cb9f817375d195b969712176aChet Haase            String oldName = valuesHolder.getPropertyName();
62d953d08e9299072130d9f4411cbcf6678bbce822Chet Haase            valuesHolder.setPropertyName(propertyName);
63602e4d3824bf8b9cb9f817375d195b969712176aChet Haase            mValuesMap.remove(oldName);
64602e4d3824bf8b9cb9f817375d195b969712176aChet Haase            mValuesMap.put(propertyName, valuesHolder);
65d953d08e9299072130d9f4411cbcf6678bbce822Chet Haase        }
6617fb4b0d1cfbad1f026fec704c86640f070b4c2fChet Haase        mPropertyName = propertyName;
670e0590bf3cb32e73f423c0fe39a180d4b3c4343dChet Haase        // New property/values/target should cause re-initialization prior to starting
680e0590bf3cb32e73f423c0fe39a180d4b3c4343dChet Haase        mInitialized = false;
6917fb4b0d1cfbad1f026fec704c86640f070b4c2fChet Haase    }
7017fb4b0d1cfbad1f026fec704c86640f070b4c2fChet Haase
7117fb4b0d1cfbad1f026fec704c86640f070b4c2fChet Haase    /**
7217fb4b0d1cfbad1f026fec704c86640f070b4c2fChet Haase     * Gets the name of the property that will be animated. This name will be used to derive
7317fb4b0d1cfbad1f026fec704c86640f070b4c2fChet Haase     * a setter function that will be called to set animated values.
7417fb4b0d1cfbad1f026fec704c86640f070b4c2fChet Haase     * For example, a property name of <code>foo</code> will result
7517fb4b0d1cfbad1f026fec704c86640f070b4c2fChet Haase     * in a call to the function <code>setFoo()</code> on the target object. If either
7617fb4b0d1cfbad1f026fec704c86640f070b4c2fChet Haase     * <code>valueFrom</code> or <code>valueTo</code> is null, then a getter function will
7717fb4b0d1cfbad1f026fec704c86640f070b4c2fChet Haase     * also be derived and called.
7817fb4b0d1cfbad1f026fec704c86640f070b4c2fChet Haase     */
7917fb4b0d1cfbad1f026fec704c86640f070b4c2fChet Haase    public String getPropertyName() {
8017fb4b0d1cfbad1f026fec704c86640f070b4c2fChet Haase        return mPropertyName;
8117fb4b0d1cfbad1f026fec704c86640f070b4c2fChet Haase    }
8217fb4b0d1cfbad1f026fec704c86640f070b4c2fChet Haase
8317fb4b0d1cfbad1f026fec704c86640f070b4c2fChet Haase    /**
8417fb4b0d1cfbad1f026fec704c86640f070b4c2fChet Haase     * Determine the setter or getter function using the JavaBeans convention of setFoo or
8517fb4b0d1cfbad1f026fec704c86640f070b4c2fChet Haase     * getFoo for a property named 'foo'. This function figures out what the name of the
8617fb4b0d1cfbad1f026fec704c86640f070b4c2fChet Haase     * function should be and uses reflection to find the Method with that name on the
8717fb4b0d1cfbad1f026fec704c86640f070b4c2fChet Haase     * target object.
8817fb4b0d1cfbad1f026fec704c86640f070b4c2fChet Haase     *
8917fb4b0d1cfbad1f026fec704c86640f070b4c2fChet Haase     * @param prefix "set" or "get", depending on whether we need a setter or getter.
9017fb4b0d1cfbad1f026fec704c86640f070b4c2fChet Haase     * @return Method the method associated with mPropertyName.
9117fb4b0d1cfbad1f026fec704c86640f070b4c2fChet Haase     */
92fe591563f8529305bd52e1f0640e83b9a93d562fChet Haase    private Method getPropertyFunction(String prefix, Class valueType) {
9317fb4b0d1cfbad1f026fec704c86640f070b4c2fChet Haase        // TODO: faster implementation...
9417fb4b0d1cfbad1f026fec704c86640f070b4c2fChet Haase        Method returnVal = null;
9517fb4b0d1cfbad1f026fec704c86640f070b4c2fChet Haase        String firstLetter = mPropertyName.substring(0, 1);
9617fb4b0d1cfbad1f026fec704c86640f070b4c2fChet Haase        String theRest = mPropertyName.substring(1);
9717fb4b0d1cfbad1f026fec704c86640f070b4c2fChet Haase        firstLetter = firstLetter.toUpperCase();
9817fb4b0d1cfbad1f026fec704c86640f070b4c2fChet Haase        String setterName = prefix + firstLetter + theRest;
99fe591563f8529305bd52e1f0640e83b9a93d562fChet Haase        Class args[] = null;
100fe591563f8529305bd52e1f0640e83b9a93d562fChet Haase        if (valueType != null) {
101fe591563f8529305bd52e1f0640e83b9a93d562fChet Haase            args = new Class[1];
102fe591563f8529305bd52e1f0640e83b9a93d562fChet Haase            args[0] = valueType;
103fe591563f8529305bd52e1f0640e83b9a93d562fChet Haase        }
10417fb4b0d1cfbad1f026fec704c86640f070b4c2fChet Haase        try {
10517fb4b0d1cfbad1f026fec704c86640f070b4c2fChet Haase            returnVal = mTarget.getClass().getMethod(setterName, args);
10617fb4b0d1cfbad1f026fec704c86640f070b4c2fChet Haase        } catch (NoSuchMethodException e) {
107a18a86b43e40e3c15dcca0ae0148d641be9b25feChet Haase            Log.e("ObjectAnimator",
108fe591563f8529305bd52e1f0640e83b9a93d562fChet Haase                    "Couldn't find setter/getter for property " + mPropertyName + ": " + e);
10917fb4b0d1cfbad1f026fec704c86640f070b4c2fChet Haase        }
11017fb4b0d1cfbad1f026fec704c86640f070b4c2fChet Haase        return returnVal;
11117fb4b0d1cfbad1f026fec704c86640f070b4c2fChet Haase    }
11217fb4b0d1cfbad1f026fec704c86640f070b4c2fChet Haase
11317fb4b0d1cfbad1f026fec704c86640f070b4c2fChet Haase    /**
114a18a86b43e40e3c15dcca0ae0148d641be9b25feChet Haase     * Creates a new ObjectAnimator object. This default constructor is primarily for
115d51d368f2d512ab657b8ae45780c82c0dbea94c3Chet Haase     * use internally; the other constructors which take parameters are more generally
116d51d368f2d512ab657b8ae45780c82c0dbea94c3Chet Haase     * useful.
117d51d368f2d512ab657b8ae45780c82c0dbea94c3Chet Haase     */
118a18a86b43e40e3c15dcca0ae0148d641be9b25feChet Haase    public ObjectAnimator() {
119d51d368f2d512ab657b8ae45780c82c0dbea94c3Chet Haase    }
120d51d368f2d512ab657b8ae45780c82c0dbea94c3Chet Haase
121d51d368f2d512ab657b8ae45780c82c0dbea94c3Chet Haase    /**
122d953d08e9299072130d9f4411cbcf6678bbce822Chet Haase     * A constructor that takes a single property name and set of values. This constructor is
123d953d08e9299072130d9f4411cbcf6678bbce822Chet Haase     * used in the simple case of animating a single property.
124fe591563f8529305bd52e1f0640e83b9a93d562fChet Haase     *
12583d6e8213230fb0805aa019d266842253baeb114Romain Guy     * @param duration The length of the animation, in milliseconds.
126fe591563f8529305bd52e1f0640e83b9a93d562fChet Haase     * @param target The object whose property is to be animated. This object should
127d953d08e9299072130d9f4411cbcf6678bbce822Chet Haase     * have a public method on it called <code>setName()</code>, where <code>name</code> is
128d953d08e9299072130d9f4411cbcf6678bbce822Chet Haase     * the value of the <code>propertyName</code> parameter.
129d953d08e9299072130d9f4411cbcf6678bbce822Chet Haase     * @param propertyName The name of the property being animated.
13083d6e8213230fb0805aa019d266842253baeb114Romain Guy     * @param values The set of values to animate between. If there is only one value, it
13183d6e8213230fb0805aa019d266842253baeb114Romain Guy     * is assumed to be the final value being animated to, and the initial value will be
13283d6e8213230fb0805aa019d266842253baeb114Romain Guy     * derived on the fly.
133fe591563f8529305bd52e1f0640e83b9a93d562fChet Haase     */
13483d6e8213230fb0805aa019d266842253baeb114Romain Guy    public ObjectAnimator(long duration, Object target, String propertyName, T...values) {
13583d6e8213230fb0805aa019d266842253baeb114Romain Guy        super(duration, (T[]) values);
136fe591563f8529305bd52e1f0640e83b9a93d562fChet Haase        mTarget = target;
137d953d08e9299072130d9f4411cbcf6678bbce822Chet Haase        setPropertyName(propertyName);
138fe591563f8529305bd52e1f0640e83b9a93d562fChet Haase    }
139fe591563f8529305bd52e1f0640e83b9a93d562fChet Haase
140fe591563f8529305bd52e1f0640e83b9a93d562fChet Haase    /**
141d953d08e9299072130d9f4411cbcf6678bbce822Chet Haase     * A constructor that takes <code>PropertyValueHolder</code> values. This constructor should
142a18a86b43e40e3c15dcca0ae0148d641be9b25feChet Haase     * be used when animating several properties at once with the same ObjectAnimator, since
143d953d08e9299072130d9f4411cbcf6678bbce822Chet Haase     * PropertyValuesHolder allows you to associate a set of animation values with a property
144d953d08e9299072130d9f4411cbcf6678bbce822Chet Haase     * name.
14517fb4b0d1cfbad1f026fec704c86640f070b4c2fChet Haase     *
14683d6e8213230fb0805aa019d266842253baeb114Romain Guy     * @param duration The length of the animation, in milliseconds.
14717fb4b0d1cfbad1f026fec704c86640f070b4c2fChet Haase     * @param target The object whose property is to be animated. This object should
148d953d08e9299072130d9f4411cbcf6678bbce822Chet Haase     * have public methods on it called <code>setName()</code>, where <code>name</code> is
149d953d08e9299072130d9f4411cbcf6678bbce822Chet Haase     * the name of the property passed in as the <code>propertyName</code> parameter for
150d953d08e9299072130d9f4411cbcf6678bbce822Chet Haase     * each of the PropertyValuesHolder objects.
151d953d08e9299072130d9f4411cbcf6678bbce822Chet Haase     * @param values The PropertyValuesHolder objects which hold each the property name and values
152d953d08e9299072130d9f4411cbcf6678bbce822Chet Haase     * to animate that property between.
153d953d08e9299072130d9f4411cbcf6678bbce822Chet Haase     */
15483d6e8213230fb0805aa019d266842253baeb114Romain Guy    public ObjectAnimator(long duration, Object target, PropertyValuesHolder...values) {
15583d6e8213230fb0805aa019d266842253baeb114Romain Guy        super(duration);
15683d6e8213230fb0805aa019d266842253baeb114Romain Guy        setValues(values);
15783d6e8213230fb0805aa019d266842253baeb114Romain Guy        mTarget = target;
1583dd207a6dbd5d9244dc7fe213d5caa3cddaff0dbChet Haase    }
1593dd207a6dbd5d9244dc7fe213d5caa3cddaff0dbChet Haase
16083d6e8213230fb0805aa019d266842253baeb114Romain Guy    @Override
16183d6e8213230fb0805aa019d266842253baeb114Romain Guy    public void setValues(T... values) {
16283d6e8213230fb0805aa019d266842253baeb114Romain Guy        if (mValues == null || mValues.length == 0) {
16383d6e8213230fb0805aa019d266842253baeb114Romain Guy            // No values yet - this animator is being constructed piecemeal. Init the values with
16483d6e8213230fb0805aa019d266842253baeb114Romain Guy            // whatever the current propertyName is
16583d6e8213230fb0805aa019d266842253baeb114Romain Guy            setValues(new PropertyValuesHolder[]{
16683d6e8213230fb0805aa019d266842253baeb114Romain Guy                    new PropertyValuesHolder(mPropertyName, (Object[])values)});
16783d6e8213230fb0805aa019d266842253baeb114Romain Guy        } else {
16883d6e8213230fb0805aa019d266842253baeb114Romain Guy            super.setValues((T[]) values);
16983d6e8213230fb0805aa019d266842253baeb114Romain Guy        }
1700e0590bf3cb32e73f423c0fe39a180d4b3c4343dChet Haase    }
17183d6e8213230fb0805aa019d266842253baeb114Romain Guy
1723dd207a6dbd5d9244dc7fe213d5caa3cddaff0dbChet Haase    /**
17317fb4b0d1cfbad1f026fec704c86640f070b4c2fChet Haase     * This function is called immediately before processing the first animation
17417fb4b0d1cfbad1f026fec704c86640f070b4c2fChet Haase     * frame of an animation. If there is a nonzero <code>startDelay</code>, the
17517fb4b0d1cfbad1f026fec704c86640f070b4c2fChet Haase     * function is called after that delay ends.
17617fb4b0d1cfbad1f026fec704c86640f070b4c2fChet Haase     * It takes care of the final initialization steps for the
17717fb4b0d1cfbad1f026fec704c86640f070b4c2fChet Haase     * animation. This includes setting mEvaluator, if the user has not yet
17817fb4b0d1cfbad1f026fec704c86640f070b4c2fChet Haase     * set it up, and the setter/getter methods, if the user did not supply
17917fb4b0d1cfbad1f026fec704c86640f070b4c2fChet Haase     * them.
18017fb4b0d1cfbad1f026fec704c86640f070b4c2fChet Haase     *
18117fb4b0d1cfbad1f026fec704c86640f070b4c2fChet Haase     *  <p>Overriders of this method should call the superclass method to cause
18217fb4b0d1cfbad1f026fec704c86640f070b4c2fChet Haase     *  internal mechanisms to be set up correctly.</p>
18317fb4b0d1cfbad1f026fec704c86640f070b4c2fChet Haase     */
18417fb4b0d1cfbad1f026fec704c86640f070b4c2fChet Haase    @Override
18517fb4b0d1cfbad1f026fec704c86640f070b4c2fChet Haase    void initAnimation() {
18621cd1389d2ef218b20994b617c57af120841a57fChet Haase        if (!mInitialized) {
18721cd1389d2ef218b20994b617c57af120841a57fChet Haase            // mValueType may change due to setter/getter setup; do this before calling super.init(),
18821cd1389d2ef218b20994b617c57af120841a57fChet Haase            // which uses mValueType to set up the default type evaluator.
18921cd1389d2ef218b20994b617c57af120841a57fChet Haase            int numValues = mValues.length;
19021cd1389d2ef218b20994b617c57af120841a57fChet Haase            for (int i = 0; i < numValues; ++i) {
19121cd1389d2ef218b20994b617c57af120841a57fChet Haase                mValues[i].setupSetterAndGetter(mTarget);
19221cd1389d2ef218b20994b617c57af120841a57fChet Haase            }
19321cd1389d2ef218b20994b617c57af120841a57fChet Haase            super.initAnimation();
19417fb4b0d1cfbad1f026fec704c86640f070b4c2fChet Haase        }
19517fb4b0d1cfbad1f026fec704c86640f070b4c2fChet Haase    }
19617fb4b0d1cfbad1f026fec704c86640f070b4c2fChet Haase
19717fb4b0d1cfbad1f026fec704c86640f070b4c2fChet Haase
19817fb4b0d1cfbad1f026fec704c86640f070b4c2fChet Haase    /**
19917fb4b0d1cfbad1f026fec704c86640f070b4c2fChet Haase     * The target object whose property will be animated by this animation
20017fb4b0d1cfbad1f026fec704c86640f070b4c2fChet Haase     *
20117fb4b0d1cfbad1f026fec704c86640f070b4c2fChet Haase     * @return The object being animated
20217fb4b0d1cfbad1f026fec704c86640f070b4c2fChet Haase     */
20317fb4b0d1cfbad1f026fec704c86640f070b4c2fChet Haase    public Object getTarget() {
20417fb4b0d1cfbad1f026fec704c86640f070b4c2fChet Haase        return mTarget;
20517fb4b0d1cfbad1f026fec704c86640f070b4c2fChet Haase    }
20617fb4b0d1cfbad1f026fec704c86640f070b4c2fChet Haase
20717fb4b0d1cfbad1f026fec704c86640f070b4c2fChet Haase    /**
208f54a8d7c479485174941c38f151ea7083c658da3Chet Haase     * Sets the target object whose property will be animated by this animation
209f54a8d7c479485174941c38f151ea7083c658da3Chet Haase     *
210f54a8d7c479485174941c38f151ea7083c658da3Chet Haase     * @param target The object being animated
211f54a8d7c479485174941c38f151ea7083c658da3Chet Haase     */
21221cd1389d2ef218b20994b617c57af120841a57fChet Haase    @Override
213f54a8d7c479485174941c38f151ea7083c658da3Chet Haase    public void setTarget(Object target) {
214f54a8d7c479485174941c38f151ea7083c658da3Chet Haase        mTarget = target;
2150e0590bf3cb32e73f423c0fe39a180d4b3c4343dChet Haase        // New property/values/target should cause re-initialization prior to starting
2160e0590bf3cb32e73f423c0fe39a180d4b3c4343dChet Haase        mInitialized = false;
217f54a8d7c479485174941c38f151ea7083c658da3Chet Haase    }
218f54a8d7c479485174941c38f151ea7083c658da3Chet Haase
21921cd1389d2ef218b20994b617c57af120841a57fChet Haase    @Override
22021cd1389d2ef218b20994b617c57af120841a57fChet Haase    public void setupStartValues() {
22121cd1389d2ef218b20994b617c57af120841a57fChet Haase        initAnimation();
22221cd1389d2ef218b20994b617c57af120841a57fChet Haase        int numValues = mValues.length;
22321cd1389d2ef218b20994b617c57af120841a57fChet Haase        for (int i = 0; i < numValues; ++i) {
22421cd1389d2ef218b20994b617c57af120841a57fChet Haase            mValues[i].setupStartValue(mTarget);
22521cd1389d2ef218b20994b617c57af120841a57fChet Haase        }
22621cd1389d2ef218b20994b617c57af120841a57fChet Haase    }
22721cd1389d2ef218b20994b617c57af120841a57fChet Haase
22821cd1389d2ef218b20994b617c57af120841a57fChet Haase    @Override
22921cd1389d2ef218b20994b617c57af120841a57fChet Haase    public void setupEndValues() {
23021cd1389d2ef218b20994b617c57af120841a57fChet Haase        initAnimation();
23121cd1389d2ef218b20994b617c57af120841a57fChet Haase        int numValues = mValues.length;
23221cd1389d2ef218b20994b617c57af120841a57fChet Haase        for (int i = 0; i < numValues; ++i) {
23321cd1389d2ef218b20994b617c57af120841a57fChet Haase            mValues[i].setupEndValue(mTarget);
23421cd1389d2ef218b20994b617c57af120841a57fChet Haase        }
23521cd1389d2ef218b20994b617c57af120841a57fChet Haase    }
23621cd1389d2ef218b20994b617c57af120841a57fChet Haase
237f54a8d7c479485174941c38f151ea7083c658da3Chet Haase    /**
23817fb4b0d1cfbad1f026fec704c86640f070b4c2fChet Haase     * This method is called with the elapsed fraction of the animation during every
23917fb4b0d1cfbad1f026fec704c86640f070b4c2fChet Haase     * animation frame. This function turns the elapsed fraction into an interpolated fraction
24017fb4b0d1cfbad1f026fec704c86640f070b4c2fChet Haase     * and then into an animated value (from the evaluator. The function is called mostly during
24117fb4b0d1cfbad1f026fec704c86640f070b4c2fChet Haase     * animation updates, but it is also called when the <code>end()</code>
24217fb4b0d1cfbad1f026fec704c86640f070b4c2fChet Haase     * function is called, to set the final value on the property.
24317fb4b0d1cfbad1f026fec704c86640f070b4c2fChet Haase     *
24417fb4b0d1cfbad1f026fec704c86640f070b4c2fChet Haase     * <p>Overrides of this method must call the superclass to perform the calculation
24517fb4b0d1cfbad1f026fec704c86640f070b4c2fChet Haase     * of the animated value.</p>
24617fb4b0d1cfbad1f026fec704c86640f070b4c2fChet Haase     *
24717fb4b0d1cfbad1f026fec704c86640f070b4c2fChet Haase     * @param fraction The elapsed fraction of the animation.
24817fb4b0d1cfbad1f026fec704c86640f070b4c2fChet Haase     */
24917fb4b0d1cfbad1f026fec704c86640f070b4c2fChet Haase    @Override
25017fb4b0d1cfbad1f026fec704c86640f070b4c2fChet Haase    void animateValue(float fraction) {
25117fb4b0d1cfbad1f026fec704c86640f070b4c2fChet Haase        super.animateValue(fraction);
252602e4d3824bf8b9cb9f817375d195b969712176aChet Haase        int numValues = mValues.length;
253602e4d3824bf8b9cb9f817375d195b969712176aChet Haase        for (int i = 0; i < numValues; ++i) {
254602e4d3824bf8b9cb9f817375d195b969712176aChet Haase            mValues[i].setAnimatedValue(mTarget);
25517fb4b0d1cfbad1f026fec704c86640f070b4c2fChet Haase        }
25617fb4b0d1cfbad1f026fec704c86640f070b4c2fChet Haase    }
25749afa5bc100e5d4c069fea980dd6b09501f56397Chet Haase
25849afa5bc100e5d4c069fea980dd6b09501f56397Chet Haase    @Override
259a18a86b43e40e3c15dcca0ae0148d641be9b25feChet Haase    public ObjectAnimator clone() {
260a18a86b43e40e3c15dcca0ae0148d641be9b25feChet Haase        final ObjectAnimator anim = (ObjectAnimator) super.clone();
26149afa5bc100e5d4c069fea980dd6b09501f56397Chet Haase        return anim;
26249afa5bc100e5d4c069fea980dd6b09501f56397Chet Haase    }
26317fb4b0d1cfbad1f026fec704c86640f070b4c2fChet Haase}
264