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
19e60a693d847a160b7a0d70046eb1d0e6d2cb4f10Chet Haaseimport android.annotation.Nullable;
20ac85f90466dd60d2af8ffc3942d503a0de606726Alan Viveretteimport android.content.pm.ActivityInfo.Config;
21d422dc358f0100106dc07d7b903201eb9b043b11Yigit Boyarimport android.content.res.ConstantState;
22d422dc358f0100106dc07d7b903201eb9b043b11Yigit Boyar
2317fb4b0d1cfbad1f026fec704c86640f070b4c2fChet Haaseimport java.util.ArrayList;
2417fb4b0d1cfbad1f026fec704c86640f070b4c2fChet Haase
2517fb4b0d1cfbad1f026fec704c86640f070b4c2fChet Haase/**
26a18a86b43e40e3c15dcca0ae0148d641be9b25feChet Haase * This is the superclass for classes which provide basic support for animations which can be
27a18a86b43e40e3c15dcca0ae0148d641be9b25feChet Haase * started, ended, and have <code>AnimatorListeners</code> added to them.
2817fb4b0d1cfbad1f026fec704c86640f070b4c2fChet Haase */
295c71b8cc4ae3e76ce7c7462fff9426c8e96ea5f7Doris Liupublic abstract class Animator implements Cloneable {
3017fb4b0d1cfbad1f026fec704c86640f070b4c2fChet Haase
3117fb4b0d1cfbad1f026fec704c86640f070b4c2fChet Haase    /**
321309914ebf21e705fc59d7d44014124d8a21a2d2Doris Liu     * The value used to indicate infinite duration (e.g. when Animators repeat infinitely).
331309914ebf21e705fc59d7d44014124d8a21a2d2Doris Liu     */
341309914ebf21e705fc59d7d44014124d8a21a2d2Doris Liu    public static final long DURATION_INFINITE = -1;
351309914ebf21e705fc59d7d44014124d8a21a2d2Doris Liu    /**
3617fb4b0d1cfbad1f026fec704c86640f070b4c2fChet Haase     * The set of listeners to be sent events through the life of an animation.
3717fb4b0d1cfbad1f026fec704c86640f070b4c2fChet Haase     */
38a18a86b43e40e3c15dcca0ae0148d641be9b25feChet Haase    ArrayList<AnimatorListener> mListeners = null;
39d51d368f2d512ab657b8ae45780c82c0dbea94c3Chet Haase
40d51d368f2d512ab657b8ae45780c82c0dbea94c3Chet Haase    /**
418aa1ffb0ed292891030992c65df4e5dc8bd37524Chet Haase     * The set of listeners to be sent pause/resume events through the life
428aa1ffb0ed292891030992c65df4e5dc8bd37524Chet Haase     * of an animation.
438aa1ffb0ed292891030992c65df4e5dc8bd37524Chet Haase     */
448aa1ffb0ed292891030992c65df4e5dc8bd37524Chet Haase    ArrayList<AnimatorPauseListener> mPauseListeners = null;
458aa1ffb0ed292891030992c65df4e5dc8bd37524Chet Haase
468aa1ffb0ed292891030992c65df4e5dc8bd37524Chet Haase    /**
478aa1ffb0ed292891030992c65df4e5dc8bd37524Chet Haase     * Whether this animator is currently in a paused state.
488aa1ffb0ed292891030992c65df4e5dc8bd37524Chet Haase     */
498aa1ffb0ed292891030992c65df4e5dc8bd37524Chet Haase    boolean mPaused = false;
508aa1ffb0ed292891030992c65df4e5dc8bd37524Chet Haase
518aa1ffb0ed292891030992c65df4e5dc8bd37524Chet Haase    /**
52d422dc358f0100106dc07d7b903201eb9b043b11Yigit Boyar     * A set of flags which identify the type of configuration changes that can affect this
53d422dc358f0100106dc07d7b903201eb9b043b11Yigit Boyar     * Animator. Used by the Animator cache.
54d422dc358f0100106dc07d7b903201eb9b043b11Yigit Boyar     */
55ac85f90466dd60d2af8ffc3942d503a0de606726Alan Viverette    @Config int mChangingConfigurations = 0;
56d422dc358f0100106dc07d7b903201eb9b043b11Yigit Boyar
57d422dc358f0100106dc07d7b903201eb9b043b11Yigit Boyar    /**
58d422dc358f0100106dc07d7b903201eb9b043b11Yigit Boyar     * If this animator is inflated from a constant state, keep a reference to it so that
59d422dc358f0100106dc07d7b903201eb9b043b11Yigit Boyar     * ConstantState will not be garbage collected until this animator is collected
60d422dc358f0100106dc07d7b903201eb9b043b11Yigit Boyar     */
61d422dc358f0100106dc07d7b903201eb9b043b11Yigit Boyar    private AnimatorConstantState mConstantState;
62d422dc358f0100106dc07d7b903201eb9b043b11Yigit Boyar
63d422dc358f0100106dc07d7b903201eb9b043b11Yigit Boyar    /**
64a18a86b43e40e3c15dcca0ae0148d641be9b25feChet Haase     * Starts this animation. If the animation has a nonzero startDelay, the animation will start
65b8f574a165bf6ec5b316734b367ac274ded4809bChet Haase     * running after that delay elapses. A non-delayed animation will have its initial
66b8f574a165bf6ec5b316734b367ac274ded4809bChet Haase     * value(s) set immediately, followed by calls to
67b8f574a165bf6ec5b316734b367ac274ded4809bChet Haase     * {@link AnimatorListener#onAnimationStart(Animator)} for any listeners of this animator.
68e2ab7ccd385cdb6517955c719e1d2b49771bedb6Chet Haase     *
69e2ab7ccd385cdb6517955c719e1d2b49771bedb6Chet Haase     * <p>The animation started by calling this method will be run on the thread that called
70e2ab7ccd385cdb6517955c719e1d2b49771bedb6Chet Haase     * this method. This thread should have a Looper on it (a runtime exception will be thrown if
71e2ab7ccd385cdb6517955c719e1d2b49771bedb6Chet Haase     * this is not the case). Also, if the animation will animate
72e2ab7ccd385cdb6517955c719e1d2b49771bedb6Chet Haase     * properties of objects in the view hierarchy, then the calling thread should be the UI
73e2ab7ccd385cdb6517955c719e1d2b49771bedb6Chet Haase     * thread for that view hierarchy.</p>
74e2ab7ccd385cdb6517955c719e1d2b49771bedb6Chet Haase     *
75d51d368f2d512ab657b8ae45780c82c0dbea94c3Chet Haase     */
76a18a86b43e40e3c15dcca0ae0148d641be9b25feChet Haase    public void start() {
775d7b50b800b9898f5ca0b2b4d8b73ed6a4ee1749Chet Haase    }
785d7b50b800b9898f5ca0b2b4d8b73ed6a4ee1749Chet Haase
795d7b50b800b9898f5ca0b2b4d8b73ed6a4ee1749Chet Haase    /**
80a18a86b43e40e3c15dcca0ae0148d641be9b25feChet Haase     * Cancels the animation. Unlike {@link #end()}, <code>cancel()</code> causes the animation to
81e2ab7ccd385cdb6517955c719e1d2b49771bedb6Chet Haase     * stop in its tracks, sending an
82e2ab7ccd385cdb6517955c719e1d2b49771bedb6Chet Haase     * {@link android.animation.Animator.AnimatorListener#onAnimationCancel(Animator)} to
83e2ab7ccd385cdb6517955c719e1d2b49771bedb6Chet Haase     * its listeners, followed by an
84e2ab7ccd385cdb6517955c719e1d2b49771bedb6Chet Haase     * {@link android.animation.Animator.AnimatorListener#onAnimationEnd(Animator)} message.
85e2ab7ccd385cdb6517955c719e1d2b49771bedb6Chet Haase     *
86e2ab7ccd385cdb6517955c719e1d2b49771bedb6Chet Haase     * <p>This method must be called on the thread that is running the animation.</p>
875d7b50b800b9898f5ca0b2b4d8b73ed6a4ee1749Chet Haase     */
88a18a86b43e40e3c15dcca0ae0148d641be9b25feChet Haase    public void cancel() {
89fe591563f8529305bd52e1f0640e83b9a93d562fChet Haase    }
90fe591563f8529305bd52e1f0640e83b9a93d562fChet Haase
91fe591563f8529305bd52e1f0640e83b9a93d562fChet Haase    /**
92a18a86b43e40e3c15dcca0ae0148d641be9b25feChet Haase     * Ends the animation. This causes the animation to assign the end value of the property being
93e2ab7ccd385cdb6517955c719e1d2b49771bedb6Chet Haase     * animated, then calling the
94e2ab7ccd385cdb6517955c719e1d2b49771bedb6Chet Haase     * {@link android.animation.Animator.AnimatorListener#onAnimationEnd(Animator)} method on
95a18a86b43e40e3c15dcca0ae0148d641be9b25feChet Haase     * its listeners.
96e2ab7ccd385cdb6517955c719e1d2b49771bedb6Chet Haase     *
97e2ab7ccd385cdb6517955c719e1d2b49771bedb6Chet Haase     * <p>This method must be called on the thread that is running the animation.</p>
9817fb4b0d1cfbad1f026fec704c86640f070b4c2fChet Haase     */
99a18a86b43e40e3c15dcca0ae0148d641be9b25feChet Haase    public void end() {
10017fb4b0d1cfbad1f026fec704c86640f070b4c2fChet Haase    }
10117fb4b0d1cfbad1f026fec704c86640f070b4c2fChet Haase
10217fb4b0d1cfbad1f026fec704c86640f070b4c2fChet Haase    /**
1038aa1ffb0ed292891030992c65df4e5dc8bd37524Chet Haase     * Pauses a running animation. This method should only be called on the same thread on
1048aa1ffb0ed292891030992c65df4e5dc8bd37524Chet Haase     * which the animation was started. If the animation has not yet been {@link
1058aa1ffb0ed292891030992c65df4e5dc8bd37524Chet Haase     * #isStarted() started} or has since ended, then the call is ignored. Paused
1068aa1ffb0ed292891030992c65df4e5dc8bd37524Chet Haase     * animations can be resumed by calling {@link #resume()}.
1078aa1ffb0ed292891030992c65df4e5dc8bd37524Chet Haase     *
1088aa1ffb0ed292891030992c65df4e5dc8bd37524Chet Haase     * @see #resume()
1098aa1ffb0ed292891030992c65df4e5dc8bd37524Chet Haase     * @see #isPaused()
1108aa1ffb0ed292891030992c65df4e5dc8bd37524Chet Haase     * @see AnimatorPauseListener
1118aa1ffb0ed292891030992c65df4e5dc8bd37524Chet Haase     */
1128aa1ffb0ed292891030992c65df4e5dc8bd37524Chet Haase    public void pause() {
1138aa1ffb0ed292891030992c65df4e5dc8bd37524Chet Haase        if (isStarted() && !mPaused) {
1148aa1ffb0ed292891030992c65df4e5dc8bd37524Chet Haase            mPaused = true;
1158aa1ffb0ed292891030992c65df4e5dc8bd37524Chet Haase            if (mPauseListeners != null) {
1168aa1ffb0ed292891030992c65df4e5dc8bd37524Chet Haase                ArrayList<AnimatorPauseListener> tmpListeners =
1178aa1ffb0ed292891030992c65df4e5dc8bd37524Chet Haase                        (ArrayList<AnimatorPauseListener>) mPauseListeners.clone();
1188aa1ffb0ed292891030992c65df4e5dc8bd37524Chet Haase                int numListeners = tmpListeners.size();
1198aa1ffb0ed292891030992c65df4e5dc8bd37524Chet Haase                for (int i = 0; i < numListeners; ++i) {
1208aa1ffb0ed292891030992c65df4e5dc8bd37524Chet Haase                    tmpListeners.get(i).onAnimationPause(this);
1218aa1ffb0ed292891030992c65df4e5dc8bd37524Chet Haase                }
1228aa1ffb0ed292891030992c65df4e5dc8bd37524Chet Haase            }
1238aa1ffb0ed292891030992c65df4e5dc8bd37524Chet Haase        }
1248aa1ffb0ed292891030992c65df4e5dc8bd37524Chet Haase    }
1258aa1ffb0ed292891030992c65df4e5dc8bd37524Chet Haase
1268aa1ffb0ed292891030992c65df4e5dc8bd37524Chet Haase    /**
1278aa1ffb0ed292891030992c65df4e5dc8bd37524Chet Haase     * Resumes a paused animation, causing the animator to pick up where it left off
1288aa1ffb0ed292891030992c65df4e5dc8bd37524Chet Haase     * when it was paused. This method should only be called on the same thread on
1298aa1ffb0ed292891030992c65df4e5dc8bd37524Chet Haase     * which the animation was started. Calls to resume() on an animator that is
1308aa1ffb0ed292891030992c65df4e5dc8bd37524Chet Haase     * not currently paused will be ignored.
1318aa1ffb0ed292891030992c65df4e5dc8bd37524Chet Haase     *
1328aa1ffb0ed292891030992c65df4e5dc8bd37524Chet Haase     * @see #pause()
1338aa1ffb0ed292891030992c65df4e5dc8bd37524Chet Haase     * @see #isPaused()
1348aa1ffb0ed292891030992c65df4e5dc8bd37524Chet Haase     * @see AnimatorPauseListener
1358aa1ffb0ed292891030992c65df4e5dc8bd37524Chet Haase     */
1368aa1ffb0ed292891030992c65df4e5dc8bd37524Chet Haase    public void resume() {
1378aa1ffb0ed292891030992c65df4e5dc8bd37524Chet Haase        if (mPaused) {
1388aa1ffb0ed292891030992c65df4e5dc8bd37524Chet Haase            mPaused = false;
1398aa1ffb0ed292891030992c65df4e5dc8bd37524Chet Haase            if (mPauseListeners != null) {
1408aa1ffb0ed292891030992c65df4e5dc8bd37524Chet Haase                ArrayList<AnimatorPauseListener> tmpListeners =
1418aa1ffb0ed292891030992c65df4e5dc8bd37524Chet Haase                        (ArrayList<AnimatorPauseListener>) mPauseListeners.clone();
1428aa1ffb0ed292891030992c65df4e5dc8bd37524Chet Haase                int numListeners = tmpListeners.size();
1438aa1ffb0ed292891030992c65df4e5dc8bd37524Chet Haase                for (int i = 0; i < numListeners; ++i) {
1448aa1ffb0ed292891030992c65df4e5dc8bd37524Chet Haase                    tmpListeners.get(i).onAnimationResume(this);
1458aa1ffb0ed292891030992c65df4e5dc8bd37524Chet Haase                }
1468aa1ffb0ed292891030992c65df4e5dc8bd37524Chet Haase            }
1478aa1ffb0ed292891030992c65df4e5dc8bd37524Chet Haase        }
1488aa1ffb0ed292891030992c65df4e5dc8bd37524Chet Haase    }
1498aa1ffb0ed292891030992c65df4e5dc8bd37524Chet Haase
1508aa1ffb0ed292891030992c65df4e5dc8bd37524Chet Haase    /**
1518aa1ffb0ed292891030992c65df4e5dc8bd37524Chet Haase     * Returns whether this animator is currently in a paused state.
1528aa1ffb0ed292891030992c65df4e5dc8bd37524Chet Haase     *
1538aa1ffb0ed292891030992c65df4e5dc8bd37524Chet Haase     * @return True if the animator is currently paused, false otherwise.
1548aa1ffb0ed292891030992c65df4e5dc8bd37524Chet Haase     *
1558aa1ffb0ed292891030992c65df4e5dc8bd37524Chet Haase     * @see #pause()
1568aa1ffb0ed292891030992c65df4e5dc8bd37524Chet Haase     * @see #resume()
1578aa1ffb0ed292891030992c65df4e5dc8bd37524Chet Haase     */
1588aa1ffb0ed292891030992c65df4e5dc8bd37524Chet Haase    public boolean isPaused() {
1598aa1ffb0ed292891030992c65df4e5dc8bd37524Chet Haase        return mPaused;
1608aa1ffb0ed292891030992c65df4e5dc8bd37524Chet Haase    }
1618aa1ffb0ed292891030992c65df4e5dc8bd37524Chet Haase
1628aa1ffb0ed292891030992c65df4e5dc8bd37524Chet Haase    /**
163e8cee38c6a8dd54cc222cbbd8655ae32a66a8e73Chet Haase     * The amount of time, in milliseconds, to delay processing the animation
164e8cee38c6a8dd54cc222cbbd8655ae32a66a8e73Chet Haase     * after {@link #start()} is called.
165e8cee38c6a8dd54cc222cbbd8655ae32a66a8e73Chet Haase     *
166e8cee38c6a8dd54cc222cbbd8655ae32a66a8e73Chet Haase     * @return the number of milliseconds to delay running the animation
167e8cee38c6a8dd54cc222cbbd8655ae32a66a8e73Chet Haase     */
168e8cee38c6a8dd54cc222cbbd8655ae32a66a8e73Chet Haase    public abstract long getStartDelay();
169e8cee38c6a8dd54cc222cbbd8655ae32a66a8e73Chet Haase
170e8cee38c6a8dd54cc222cbbd8655ae32a66a8e73Chet Haase    /**
171e8cee38c6a8dd54cc222cbbd8655ae32a66a8e73Chet Haase     * The amount of time, in milliseconds, to delay processing the animation
172e8cee38c6a8dd54cc222cbbd8655ae32a66a8e73Chet Haase     * after {@link #start()} is called.
173e8cee38c6a8dd54cc222cbbd8655ae32a66a8e73Chet Haase
174e8cee38c6a8dd54cc222cbbd8655ae32a66a8e73Chet Haase     * @param startDelay The amount of the delay, in milliseconds
175e8cee38c6a8dd54cc222cbbd8655ae32a66a8e73Chet Haase     */
176e8cee38c6a8dd54cc222cbbd8655ae32a66a8e73Chet Haase    public abstract void setStartDelay(long startDelay);
177e8cee38c6a8dd54cc222cbbd8655ae32a66a8e73Chet Haase
178e8cee38c6a8dd54cc222cbbd8655ae32a66a8e73Chet Haase    /**
179e8cee38c6a8dd54cc222cbbd8655ae32a66a8e73Chet Haase     * Sets the duration of the animation.
180e8cee38c6a8dd54cc222cbbd8655ae32a66a8e73Chet Haase     *
181e8cee38c6a8dd54cc222cbbd8655ae32a66a8e73Chet Haase     * @param duration The length of the animation, in milliseconds.
182e8cee38c6a8dd54cc222cbbd8655ae32a66a8e73Chet Haase     */
183e8cee38c6a8dd54cc222cbbd8655ae32a66a8e73Chet Haase    public abstract Animator setDuration(long duration);
184e8cee38c6a8dd54cc222cbbd8655ae32a66a8e73Chet Haase
185e8cee38c6a8dd54cc222cbbd8655ae32a66a8e73Chet Haase    /**
186e8cee38c6a8dd54cc222cbbd8655ae32a66a8e73Chet Haase     * Gets the duration of the animation.
187e8cee38c6a8dd54cc222cbbd8655ae32a66a8e73Chet Haase     *
188e8cee38c6a8dd54cc222cbbd8655ae32a66a8e73Chet Haase     * @return The length of the animation, in milliseconds.
189e8cee38c6a8dd54cc222cbbd8655ae32a66a8e73Chet Haase     */
190e8cee38c6a8dd54cc222cbbd8655ae32a66a8e73Chet Haase    public abstract long getDuration();
191e8cee38c6a8dd54cc222cbbd8655ae32a66a8e73Chet Haase
192e8cee38c6a8dd54cc222cbbd8655ae32a66a8e73Chet Haase    /**
1931309914ebf21e705fc59d7d44014124d8a21a2d2Doris Liu     * Gets the total duration of the animation, accounting for animation sequences, start delay,
1941309914ebf21e705fc59d7d44014124d8a21a2d2Doris Liu     * and repeating. Return {@link #DURATION_INFINITE} if the duration is infinite.
1958b7c99cca2c9996a0ac2d87f24bd3ef83fd10be5Doris Liu     *
1968b7c99cca2c9996a0ac2d87f24bd3ef83fd10be5Doris Liu     * @return  Total time an animation takes to finish, starting from the time {@link #start()}
1978b7c99cca2c9996a0ac2d87f24bd3ef83fd10be5Doris Liu     *          is called. {@link #DURATION_INFINITE} will be returned if the animation or any
1988b7c99cca2c9996a0ac2d87f24bd3ef83fd10be5Doris Liu     *          child animation repeats infinite times.
1991309914ebf21e705fc59d7d44014124d8a21a2d2Doris Liu     */
2001309914ebf21e705fc59d7d44014124d8a21a2d2Doris Liu    public long getTotalDuration() {
2018b7c99cca2c9996a0ac2d87f24bd3ef83fd10be5Doris Liu        long duration = getDuration();
2028b7c99cca2c9996a0ac2d87f24bd3ef83fd10be5Doris Liu        if (duration == DURATION_INFINITE) {
2038b7c99cca2c9996a0ac2d87f24bd3ef83fd10be5Doris Liu            return DURATION_INFINITE;
2048b7c99cca2c9996a0ac2d87f24bd3ef83fd10be5Doris Liu        } else {
2058b7c99cca2c9996a0ac2d87f24bd3ef83fd10be5Doris Liu            return getStartDelay() + duration;
2068b7c99cca2c9996a0ac2d87f24bd3ef83fd10be5Doris Liu        }
2071309914ebf21e705fc59d7d44014124d8a21a2d2Doris Liu    }
2081309914ebf21e705fc59d7d44014124d8a21a2d2Doris Liu
2091309914ebf21e705fc59d7d44014124d8a21a2d2Doris Liu    /**
210e8cee38c6a8dd54cc222cbbd8655ae32a66a8e73Chet Haase     * The time interpolator used in calculating the elapsed fraction of the
211e8cee38c6a8dd54cc222cbbd8655ae32a66a8e73Chet Haase     * animation. The interpolator determines whether the animation runs with
212e8cee38c6a8dd54cc222cbbd8655ae32a66a8e73Chet Haase     * linear or non-linear motion, such as acceleration and deceleration. The
213e8cee38c6a8dd54cc222cbbd8655ae32a66a8e73Chet Haase     * default value is {@link android.view.animation.AccelerateDecelerateInterpolator}.
214e8cee38c6a8dd54cc222cbbd8655ae32a66a8e73Chet Haase     *
215e8cee38c6a8dd54cc222cbbd8655ae32a66a8e73Chet Haase     * @param value the interpolator to be used by this animation
216e8cee38c6a8dd54cc222cbbd8655ae32a66a8e73Chet Haase     */
217e8cee38c6a8dd54cc222cbbd8655ae32a66a8e73Chet Haase    public abstract void setInterpolator(TimeInterpolator value);
218e8cee38c6a8dd54cc222cbbd8655ae32a66a8e73Chet Haase
219e8cee38c6a8dd54cc222cbbd8655ae32a66a8e73Chet Haase    /**
220e8cee38c6a8dd54cc222cbbd8655ae32a66a8e73Chet Haase     * Returns the timing interpolator that this animation uses.
221e8cee38c6a8dd54cc222cbbd8655ae32a66a8e73Chet Haase     *
222e8cee38c6a8dd54cc222cbbd8655ae32a66a8e73Chet Haase     * @return The timing interpolator for this animation.
223e8cee38c6a8dd54cc222cbbd8655ae32a66a8e73Chet Haase     */
224e8cee38c6a8dd54cc222cbbd8655ae32a66a8e73Chet Haase    public TimeInterpolator getInterpolator() {
225e8cee38c6a8dd54cc222cbbd8655ae32a66a8e73Chet Haase        return null;
226e8cee38c6a8dd54cc222cbbd8655ae32a66a8e73Chet Haase    }
227e8cee38c6a8dd54cc222cbbd8655ae32a66a8e73Chet Haase
228e8cee38c6a8dd54cc222cbbd8655ae32a66a8e73Chet Haase    /**
2298b699792b677bd4dd8442b32641ac09d48fdd79cChet Haase     * Returns whether this Animator is currently running (having been started and gone past any
2308b699792b677bd4dd8442b32641ac09d48fdd79cChet Haase     * initial startDelay period and not yet ended).
2318b699792b677bd4dd8442b32641ac09d48fdd79cChet Haase     *
232a18a86b43e40e3c15dcca0ae0148d641be9b25feChet Haase     * @return Whether the Animator is running.
23317fb4b0d1cfbad1f026fec704c86640f070b4c2fChet Haase     */
234a18a86b43e40e3c15dcca0ae0148d641be9b25feChet Haase    public abstract boolean isRunning();
23517fb4b0d1cfbad1f026fec704c86640f070b4c2fChet Haase
23617fb4b0d1cfbad1f026fec704c86640f070b4c2fChet Haase    /**
2374ddd9257d60c378ddcf5b537ea2a03b80629f097Chet Haase     * Returns whether this Animator has been started and not yet ended. For reusable
2384ddd9257d60c378ddcf5b537ea2a03b80629f097Chet Haase     * Animators (which most Animators are, apart from the one-shot animator produced by
2394ddd9257d60c378ddcf5b537ea2a03b80629f097Chet Haase     * {@link android.view.ViewAnimationUtils#createCircularReveal(
2404ddd9257d60c378ddcf5b537ea2a03b80629f097Chet Haase     * android.view.View, int, int, float, float) createCircularReveal()}),
2414ddd9257d60c378ddcf5b537ea2a03b80629f097Chet Haase     * this state is a superset of {@link #isRunning()}, because an Animator with a
2424ddd9257d60c378ddcf5b537ea2a03b80629f097Chet Haase     * nonzero {@link #getStartDelay() startDelay} will return true for {@link #isStarted()} during
2434ddd9257d60c378ddcf5b537ea2a03b80629f097Chet Haase     * the delay phase, whereas {@link #isRunning()} will return true only after the delay phase
2444ddd9257d60c378ddcf5b537ea2a03b80629f097Chet Haase     * is complete. Non-reusable animators will always return true after they have been
2454ddd9257d60c378ddcf5b537ea2a03b80629f097Chet Haase     * started, because they cannot return to a non-started state.
2468b699792b677bd4dd8442b32641ac09d48fdd79cChet Haase     *
2478b699792b677bd4dd8442b32641ac09d48fdd79cChet Haase     * @return Whether the Animator has been started and not yet ended.
2488b699792b677bd4dd8442b32641ac09d48fdd79cChet Haase     */
2498b699792b677bd4dd8442b32641ac09d48fdd79cChet Haase    public boolean isStarted() {
2508b699792b677bd4dd8442b32641ac09d48fdd79cChet Haase        // Default method returns value for isRunning(). Subclasses should override to return a
2518b699792b677bd4dd8442b32641ac09d48fdd79cChet Haase        // real value.
2528b699792b677bd4dd8442b32641ac09d48fdd79cChet Haase        return isRunning();
2538b699792b677bd4dd8442b32641ac09d48fdd79cChet Haase    }
2548b699792b677bd4dd8442b32641ac09d48fdd79cChet Haase
2558b699792b677bd4dd8442b32641ac09d48fdd79cChet Haase    /**
256a18a86b43e40e3c15dcca0ae0148d641be9b25feChet Haase     * Adds a listener to the set of listeners that are sent events through the life of an
257a18a86b43e40e3c15dcca0ae0148d641be9b25feChet Haase     * animation, such as start, repeat, and end.
25817fb4b0d1cfbad1f026fec704c86640f070b4c2fChet Haase     *
25917fb4b0d1cfbad1f026fec704c86640f070b4c2fChet Haase     * @param listener the listener to be added to the current set of listeners for this animation.
26017fb4b0d1cfbad1f026fec704c86640f070b4c2fChet Haase     */
261a18a86b43e40e3c15dcca0ae0148d641be9b25feChet Haase    public void addListener(AnimatorListener listener) {
262a18a86b43e40e3c15dcca0ae0148d641be9b25feChet Haase        if (mListeners == null) {
263a18a86b43e40e3c15dcca0ae0148d641be9b25feChet Haase            mListeners = new ArrayList<AnimatorListener>();
26417fb4b0d1cfbad1f026fec704c86640f070b4c2fChet Haase        }
265a18a86b43e40e3c15dcca0ae0148d641be9b25feChet Haase        mListeners.add(listener);
26617fb4b0d1cfbad1f026fec704c86640f070b4c2fChet Haase    }
26717fb4b0d1cfbad1f026fec704c86640f070b4c2fChet Haase
26817fb4b0d1cfbad1f026fec704c86640f070b4c2fChet Haase    /**
269a18a86b43e40e3c15dcca0ae0148d641be9b25feChet Haase     * Removes a listener from the set listening to this animation.
27017fb4b0d1cfbad1f026fec704c86640f070b4c2fChet Haase     *
271a18a86b43e40e3c15dcca0ae0148d641be9b25feChet Haase     * @param listener the listener to be removed from the current set of listeners for this
272a18a86b43e40e3c15dcca0ae0148d641be9b25feChet Haase     *                 animation.
27317fb4b0d1cfbad1f026fec704c86640f070b4c2fChet Haase     */
274a18a86b43e40e3c15dcca0ae0148d641be9b25feChet Haase    public void removeListener(AnimatorListener listener) {
275a18a86b43e40e3c15dcca0ae0148d641be9b25feChet Haase        if (mListeners == null) {
27617fb4b0d1cfbad1f026fec704c86640f070b4c2fChet Haase            return;
27717fb4b0d1cfbad1f026fec704c86640f070b4c2fChet Haase        }
278a18a86b43e40e3c15dcca0ae0148d641be9b25feChet Haase        mListeners.remove(listener);
279a18a86b43e40e3c15dcca0ae0148d641be9b25feChet Haase        if (mListeners.size() == 0) {
280a18a86b43e40e3c15dcca0ae0148d641be9b25feChet Haase            mListeners = null;
28117fb4b0d1cfbad1f026fec704c86640f070b4c2fChet Haase        }
28217fb4b0d1cfbad1f026fec704c86640f070b4c2fChet Haase    }
28317fb4b0d1cfbad1f026fec704c86640f070b4c2fChet Haase
28417fb4b0d1cfbad1f026fec704c86640f070b4c2fChet Haase    /**
285a18a86b43e40e3c15dcca0ae0148d641be9b25feChet Haase     * Gets the set of {@link android.animation.Animator.AnimatorListener} objects that are currently
286a18a86b43e40e3c15dcca0ae0148d641be9b25feChet Haase     * listening for events on this <code>Animator</code> object.
28717fb4b0d1cfbad1f026fec704c86640f070b4c2fChet Haase     *
288a18a86b43e40e3c15dcca0ae0148d641be9b25feChet Haase     * @return ArrayList<AnimatorListener> The set of listeners.
28917fb4b0d1cfbad1f026fec704c86640f070b4c2fChet Haase     */
290a18a86b43e40e3c15dcca0ae0148d641be9b25feChet Haase    public ArrayList<AnimatorListener> getListeners() {
291a18a86b43e40e3c15dcca0ae0148d641be9b25feChet Haase        return mListeners;
29217fb4b0d1cfbad1f026fec704c86640f070b4c2fChet Haase    }
29317fb4b0d1cfbad1f026fec704c86640f070b4c2fChet Haase
29417fb4b0d1cfbad1f026fec704c86640f070b4c2fChet Haase    /**
2958aa1ffb0ed292891030992c65df4e5dc8bd37524Chet Haase     * Adds a pause listener to this animator.
2968aa1ffb0ed292891030992c65df4e5dc8bd37524Chet Haase     *
2978aa1ffb0ed292891030992c65df4e5dc8bd37524Chet Haase     * @param listener the listener to be added to the current set of pause listeners
2988aa1ffb0ed292891030992c65df4e5dc8bd37524Chet Haase     * for this animation.
2998aa1ffb0ed292891030992c65df4e5dc8bd37524Chet Haase     */
3008aa1ffb0ed292891030992c65df4e5dc8bd37524Chet Haase    public void addPauseListener(AnimatorPauseListener listener) {
3018aa1ffb0ed292891030992c65df4e5dc8bd37524Chet Haase        if (mPauseListeners == null) {
3028aa1ffb0ed292891030992c65df4e5dc8bd37524Chet Haase            mPauseListeners = new ArrayList<AnimatorPauseListener>();
3038aa1ffb0ed292891030992c65df4e5dc8bd37524Chet Haase        }
3048aa1ffb0ed292891030992c65df4e5dc8bd37524Chet Haase        mPauseListeners.add(listener);
3058aa1ffb0ed292891030992c65df4e5dc8bd37524Chet Haase    }
3068aa1ffb0ed292891030992c65df4e5dc8bd37524Chet Haase
3078aa1ffb0ed292891030992c65df4e5dc8bd37524Chet Haase    /**
3088aa1ffb0ed292891030992c65df4e5dc8bd37524Chet Haase     * Removes a pause listener from the set listening to this animation.
3098aa1ffb0ed292891030992c65df4e5dc8bd37524Chet Haase     *
3108aa1ffb0ed292891030992c65df4e5dc8bd37524Chet Haase     * @param listener the listener to be removed from the current set of pause
3118aa1ffb0ed292891030992c65df4e5dc8bd37524Chet Haase     * listeners for this animation.
3128aa1ffb0ed292891030992c65df4e5dc8bd37524Chet Haase     */
3138aa1ffb0ed292891030992c65df4e5dc8bd37524Chet Haase    public void removePauseListener(AnimatorPauseListener listener) {
3148aa1ffb0ed292891030992c65df4e5dc8bd37524Chet Haase        if (mPauseListeners == null) {
3158aa1ffb0ed292891030992c65df4e5dc8bd37524Chet Haase            return;
3168aa1ffb0ed292891030992c65df4e5dc8bd37524Chet Haase        }
3178aa1ffb0ed292891030992c65df4e5dc8bd37524Chet Haase        mPauseListeners.remove(listener);
3188aa1ffb0ed292891030992c65df4e5dc8bd37524Chet Haase        if (mPauseListeners.size() == 0) {
3198aa1ffb0ed292891030992c65df4e5dc8bd37524Chet Haase            mPauseListeners = null;
3208aa1ffb0ed292891030992c65df4e5dc8bd37524Chet Haase        }
3218aa1ffb0ed292891030992c65df4e5dc8bd37524Chet Haase    }
3228aa1ffb0ed292891030992c65df4e5dc8bd37524Chet Haase
3238aa1ffb0ed292891030992c65df4e5dc8bd37524Chet Haase    /**
324d82c8ac4db7091d2e976af4c89a1734465d20cd2Chet Haase     * Removes all {@link #addListener(android.animation.Animator.AnimatorListener) listeners}
325d82c8ac4db7091d2e976af4c89a1734465d20cd2Chet Haase     * and {@link #addPauseListener(android.animation.Animator.AnimatorPauseListener)
326d82c8ac4db7091d2e976af4c89a1734465d20cd2Chet Haase     * pauseListeners} from this object.
327602e4d3824bf8b9cb9f817375d195b969712176aChet Haase     */
328a18a86b43e40e3c15dcca0ae0148d641be9b25feChet Haase    public void removeAllListeners() {
32917fb4b0d1cfbad1f026fec704c86640f070b4c2fChet Haase        if (mListeners != null) {
330a18a86b43e40e3c15dcca0ae0148d641be9b25feChet Haase            mListeners.clear();
331a18a86b43e40e3c15dcca0ae0148d641be9b25feChet Haase            mListeners = null;
33217fb4b0d1cfbad1f026fec704c86640f070b4c2fChet Haase        }
3338aa1ffb0ed292891030992c65df4e5dc8bd37524Chet Haase        if (mPauseListeners != null) {
3348aa1ffb0ed292891030992c65df4e5dc8bd37524Chet Haase            mPauseListeners.clear();
3358aa1ffb0ed292891030992c65df4e5dc8bd37524Chet Haase            mPauseListeners = null;
3368aa1ffb0ed292891030992c65df4e5dc8bd37524Chet Haase        }
33717fb4b0d1cfbad1f026fec704c86640f070b4c2fChet Haase    }
33817fb4b0d1cfbad1f026fec704c86640f070b4c2fChet Haase
339d422dc358f0100106dc07d7b903201eb9b043b11Yigit Boyar    /**
340d422dc358f0100106dc07d7b903201eb9b043b11Yigit Boyar     * Return a mask of the configuration parameters for which this animator may change, requiring
341d422dc358f0100106dc07d7b903201eb9b043b11Yigit Boyar     * that it should be re-created from Resources. The default implementation returns whatever
342d422dc358f0100106dc07d7b903201eb9b043b11Yigit Boyar     * value was provided through setChangingConfigurations(int) or 0 by default.
343d422dc358f0100106dc07d7b903201eb9b043b11Yigit Boyar     *
344d422dc358f0100106dc07d7b903201eb9b043b11Yigit Boyar     * @return Returns a mask of the changing configuration parameters, as defined by
345d422dc358f0100106dc07d7b903201eb9b043b11Yigit Boyar     * {@link android.content.pm.ActivityInfo}.
346d422dc358f0100106dc07d7b903201eb9b043b11Yigit Boyar     * @see android.content.pm.ActivityInfo
347d422dc358f0100106dc07d7b903201eb9b043b11Yigit Boyar     * @hide
348d422dc358f0100106dc07d7b903201eb9b043b11Yigit Boyar     */
349ac85f90466dd60d2af8ffc3942d503a0de606726Alan Viverette    public @Config int getChangingConfigurations() {
350d422dc358f0100106dc07d7b903201eb9b043b11Yigit Boyar        return mChangingConfigurations;
351d422dc358f0100106dc07d7b903201eb9b043b11Yigit Boyar    }
352d422dc358f0100106dc07d7b903201eb9b043b11Yigit Boyar
353d422dc358f0100106dc07d7b903201eb9b043b11Yigit Boyar    /**
354d422dc358f0100106dc07d7b903201eb9b043b11Yigit Boyar     * Set a mask of the configuration parameters for which this animator may change, requiring
355d422dc358f0100106dc07d7b903201eb9b043b11Yigit Boyar     * that it be re-created from resource.
356d422dc358f0100106dc07d7b903201eb9b043b11Yigit Boyar     *
357d422dc358f0100106dc07d7b903201eb9b043b11Yigit Boyar     * @param configs A mask of the changing configuration parameters, as
358d422dc358f0100106dc07d7b903201eb9b043b11Yigit Boyar     * defined by {@link android.content.pm.ActivityInfo}.
359d422dc358f0100106dc07d7b903201eb9b043b11Yigit Boyar     *
360d422dc358f0100106dc07d7b903201eb9b043b11Yigit Boyar     * @see android.content.pm.ActivityInfo
361d422dc358f0100106dc07d7b903201eb9b043b11Yigit Boyar     * @hide
362d422dc358f0100106dc07d7b903201eb9b043b11Yigit Boyar     */
363ac85f90466dd60d2af8ffc3942d503a0de606726Alan Viverette    public void setChangingConfigurations(@Config int configs) {
364d422dc358f0100106dc07d7b903201eb9b043b11Yigit Boyar        mChangingConfigurations = configs;
365d422dc358f0100106dc07d7b903201eb9b043b11Yigit Boyar    }
366d422dc358f0100106dc07d7b903201eb9b043b11Yigit Boyar
367d422dc358f0100106dc07d7b903201eb9b043b11Yigit Boyar    /**
368d422dc358f0100106dc07d7b903201eb9b043b11Yigit Boyar     * Sets the changing configurations value to the union of the current changing configurations
369d422dc358f0100106dc07d7b903201eb9b043b11Yigit Boyar     * and the provided configs.
370d422dc358f0100106dc07d7b903201eb9b043b11Yigit Boyar     * This method is called while loading the animator.
371d422dc358f0100106dc07d7b903201eb9b043b11Yigit Boyar     * @hide
372d422dc358f0100106dc07d7b903201eb9b043b11Yigit Boyar     */
373ac85f90466dd60d2af8ffc3942d503a0de606726Alan Viverette    public void appendChangingConfigurations(@Config int configs) {
374d422dc358f0100106dc07d7b903201eb9b043b11Yigit Boyar        mChangingConfigurations |= configs;
375d422dc358f0100106dc07d7b903201eb9b043b11Yigit Boyar    }
376d422dc358f0100106dc07d7b903201eb9b043b11Yigit Boyar
377d422dc358f0100106dc07d7b903201eb9b043b11Yigit Boyar    /**
378d422dc358f0100106dc07d7b903201eb9b043b11Yigit Boyar     * Return a {@link android.content.res.ConstantState} instance that holds the shared state of
379d422dc358f0100106dc07d7b903201eb9b043b11Yigit Boyar     * this Animator.
380d422dc358f0100106dc07d7b903201eb9b043b11Yigit Boyar     * <p>
381d422dc358f0100106dc07d7b903201eb9b043b11Yigit Boyar     * This constant state is used to create new instances of this animator when needed, instead
382d422dc358f0100106dc07d7b903201eb9b043b11Yigit Boyar     * of re-loading it from resources. Default implementation creates a new
383d422dc358f0100106dc07d7b903201eb9b043b11Yigit Boyar     * {@link AnimatorConstantState}. You can override this method to provide your custom logic or
384d422dc358f0100106dc07d7b903201eb9b043b11Yigit Boyar     * return null if you don't want this animator to be cached.
385d422dc358f0100106dc07d7b903201eb9b043b11Yigit Boyar     *
386d422dc358f0100106dc07d7b903201eb9b043b11Yigit Boyar     * @return The ConfigurationBoundResourceCache.BaseConstantState associated to this Animator.
387d422dc358f0100106dc07d7b903201eb9b043b11Yigit Boyar     * @see android.content.res.ConstantState
388d422dc358f0100106dc07d7b903201eb9b043b11Yigit Boyar     * @see #clone()
389d422dc358f0100106dc07d7b903201eb9b043b11Yigit Boyar     * @hide
390d422dc358f0100106dc07d7b903201eb9b043b11Yigit Boyar     */
391d422dc358f0100106dc07d7b903201eb9b043b11Yigit Boyar    public ConstantState<Animator> createConstantState() {
392d422dc358f0100106dc07d7b903201eb9b043b11Yigit Boyar        return new AnimatorConstantState(this);
393d422dc358f0100106dc07d7b903201eb9b043b11Yigit Boyar    }
394d422dc358f0100106dc07d7b903201eb9b043b11Yigit Boyar
3955c7649857246333572eb332b505ad617365ef5faChet Haase    @Override
396a18a86b43e40e3c15dcca0ae0148d641be9b25feChet Haase    public Animator clone() {
397a18a86b43e40e3c15dcca0ae0148d641be9b25feChet Haase        try {
398a18a86b43e40e3c15dcca0ae0148d641be9b25feChet Haase            final Animator anim = (Animator) super.clone();
399a18a86b43e40e3c15dcca0ae0148d641be9b25feChet Haase            if (mListeners != null) {
400d422dc358f0100106dc07d7b903201eb9b043b11Yigit Boyar                anim.mListeners = new ArrayList<AnimatorListener>(mListeners);
401673e42fafd4088970ec95e1f13c61dc83132c74eChet Haase            }
4028aa1ffb0ed292891030992c65df4e5dc8bd37524Chet Haase            if (mPauseListeners != null) {
403d422dc358f0100106dc07d7b903201eb9b043b11Yigit Boyar                anim.mPauseListeners = new ArrayList<AnimatorPauseListener>(mPauseListeners);
4048aa1ffb0ed292891030992c65df4e5dc8bd37524Chet Haase            }
405a18a86b43e40e3c15dcca0ae0148d641be9b25feChet Haase            return anim;
406a18a86b43e40e3c15dcca0ae0148d641be9b25feChet Haase        } catch (CloneNotSupportedException e) {
407a18a86b43e40e3c15dcca0ae0148d641be9b25feChet Haase           throw new AssertionError();
408673e42fafd4088970ec95e1f13c61dc83132c74eChet Haase        }
4095c7649857246333572eb332b505ad617365ef5faChet Haase    }
4105c7649857246333572eb332b505ad617365ef5faChet Haase
4115c7649857246333572eb332b505ad617365ef5faChet Haase    /**
412a18a86b43e40e3c15dcca0ae0148d641be9b25feChet Haase     * This method tells the object to use appropriate information to extract
413a18a86b43e40e3c15dcca0ae0148d641be9b25feChet Haase     * starting values for the animation. For example, a AnimatorSet object will pass
414a18a86b43e40e3c15dcca0ae0148d641be9b25feChet Haase     * this call to its child objects to tell them to set up the values. A
415a18a86b43e40e3c15dcca0ae0148d641be9b25feChet Haase     * ObjectAnimator object will use the information it has about its target object
416a18a86b43e40e3c15dcca0ae0148d641be9b25feChet Haase     * and PropertyValuesHolder objects to get the start values for its properties.
417f76a50ce8fdc6aea22cabc77b2977a1a15a79630Ken Wakasa     * A ValueAnimator object will ignore the request since it does not have enough
418a18a86b43e40e3c15dcca0ae0148d641be9b25feChet Haase     * information (such as a target object) to gather these values.
4195c7649857246333572eb332b505ad617365ef5faChet Haase     */
420a18a86b43e40e3c15dcca0ae0148d641be9b25feChet Haase    public void setupStartValues() {
4215c7649857246333572eb332b505ad617365ef5faChet Haase    }
4225c7649857246333572eb332b505ad617365ef5faChet Haase
4235c7649857246333572eb332b505ad617365ef5faChet Haase    /**
424a18a86b43e40e3c15dcca0ae0148d641be9b25feChet Haase     * This method tells the object to use appropriate information to extract
425a18a86b43e40e3c15dcca0ae0148d641be9b25feChet Haase     * ending values for the animation. For example, a AnimatorSet object will pass
426a18a86b43e40e3c15dcca0ae0148d641be9b25feChet Haase     * this call to its child objects to tell them to set up the values. A
427a18a86b43e40e3c15dcca0ae0148d641be9b25feChet Haase     * ObjectAnimator object will use the information it has about its target object
428a18a86b43e40e3c15dcca0ae0148d641be9b25feChet Haase     * and PropertyValuesHolder objects to get the start values for its properties.
429f76a50ce8fdc6aea22cabc77b2977a1a15a79630Ken Wakasa     * A ValueAnimator object will ignore the request since it does not have enough
430a18a86b43e40e3c15dcca0ae0148d641be9b25feChet Haase     * information (such as a target object) to gather these values.
43117fb4b0d1cfbad1f026fec704c86640f070b4c2fChet Haase     */
432a18a86b43e40e3c15dcca0ae0148d641be9b25feChet Haase    public void setupEndValues() {
43317fb4b0d1cfbad1f026fec704c86640f070b4c2fChet Haase    }
43417fb4b0d1cfbad1f026fec704c86640f070b4c2fChet Haase
43517fb4b0d1cfbad1f026fec704c86640f070b4c2fChet Haase    /**
436a18a86b43e40e3c15dcca0ae0148d641be9b25feChet Haase     * Sets the target object whose property will be animated by this animation. Not all subclasses
437a18a86b43e40e3c15dcca0ae0148d641be9b25feChet Haase     * operate on target objects (for example, {@link ValueAnimator}, but this method
438a18a86b43e40e3c15dcca0ae0148d641be9b25feChet Haase     * is on the superclass for the convenience of dealing generically with those subclasses
439a18a86b43e40e3c15dcca0ae0148d641be9b25feChet Haase     * that do handle targets.
440e60a693d847a160b7a0d70046eb1d0e6d2cb4f10Chet Haase     * <p>
441e60a693d847a160b7a0d70046eb1d0e6d2cb4f10Chet Haase     * <strong>Note:</strong> The target is stored as a weak reference internally to avoid leaking
442e60a693d847a160b7a0d70046eb1d0e6d2cb4f10Chet Haase     * resources by having animators directly reference old targets. Therefore, you should
443e60a693d847a160b7a0d70046eb1d0e6d2cb4f10Chet Haase     * ensure that animator targets always have a hard reference elsewhere.
44417fb4b0d1cfbad1f026fec704c86640f070b4c2fChet Haase     *
445a18a86b43e40e3c15dcca0ae0148d641be9b25feChet Haase     * @param target The object being animated
44617fb4b0d1cfbad1f026fec704c86640f070b4c2fChet Haase     */
447e60a693d847a160b7a0d70046eb1d0e6d2cb4f10Chet Haase    public void setTarget(@Nullable Object target) {
4487bc6a3f023ca3e1dde91fc97b6036dee3ba538a2ztenghui    }
4497bc6a3f023ca3e1dde91fc97b6036dee3ba538a2ztenghui
4507bc6a3f023ca3e1dde91fc97b6036dee3ba538a2ztenghui    // Hide reverse() and canReverse() for now since reverse() only work for simple
4517bc6a3f023ca3e1dde91fc97b6036dee3ba538a2ztenghui    // cases, like we don't support sequential, neither startDelay.
4527bc6a3f023ca3e1dde91fc97b6036dee3ba538a2ztenghui    // TODO: make reverse() works for all the Animators.
4537bc6a3f023ca3e1dde91fc97b6036dee3ba538a2ztenghui    /**
4547bc6a3f023ca3e1dde91fc97b6036dee3ba538a2ztenghui     * @hide
4557bc6a3f023ca3e1dde91fc97b6036dee3ba538a2ztenghui     */
4567bc6a3f023ca3e1dde91fc97b6036dee3ba538a2ztenghui    public boolean canReverse() {
4577bc6a3f023ca3e1dde91fc97b6036dee3ba538a2ztenghui        return false;
4587bc6a3f023ca3e1dde91fc97b6036dee3ba538a2ztenghui    }
4597bc6a3f023ca3e1dde91fc97b6036dee3ba538a2ztenghui
4607bc6a3f023ca3e1dde91fc97b6036dee3ba538a2ztenghui    /**
4617bc6a3f023ca3e1dde91fc97b6036dee3ba538a2ztenghui     * @hide
4627bc6a3f023ca3e1dde91fc97b6036dee3ba538a2ztenghui     */
4637bc6a3f023ca3e1dde91fc97b6036dee3ba538a2ztenghui    public void reverse() {
464291161ac3815fb853fd6af21055d60f57a869608John Reck        throw new IllegalStateException("Reverse is not supported");
46517fb4b0d1cfbad1f026fec704c86640f070b4c2fChet Haase    }
46617fb4b0d1cfbad1f026fec704c86640f070b4c2fChet Haase
4675c71b8cc4ae3e76ce7c7462fff9426c8e96ea5f7Doris Liu    // Pulse an animation frame into the animation.
4685c71b8cc4ae3e76ce7c7462fff9426c8e96ea5f7Doris Liu    boolean pulseAnimationFrame(long frameTime) {
4696ba5ed322c04f260c51d58f2e49c6189b672f2d3Doris Liu        // TODO: Need to find a better signal than this. There's a bug in SystemUI that's preventing
4706ba5ed322c04f260c51d58f2e49c6189b672f2d3Doris Liu        // returning !isStarted() from working.
4716ba5ed322c04f260c51d58f2e49c6189b672f2d3Doris Liu        return false;
47213351997aa36eb53e5ff0fcee3f5e3da83787278Doris Liu    }
47313351997aa36eb53e5ff0fcee3f5e3da83787278Doris Liu
47413351997aa36eb53e5ff0fcee3f5e3da83787278Doris Liu    /**
47513351997aa36eb53e5ff0fcee3f5e3da83787278Doris Liu     * Internal use only.
47613351997aa36eb53e5ff0fcee3f5e3da83787278Doris Liu     * This call starts the animation in regular or reverse direction without requiring them to
47713351997aa36eb53e5ff0fcee3f5e3da83787278Doris Liu     * register frame callbacks. The caller will be responsible for all the subsequent animation
47813351997aa36eb53e5ff0fcee3f5e3da83787278Doris Liu     * pulses. Specifically, the caller needs to call doAnimationFrame(...) for the animation on
47913351997aa36eb53e5ff0fcee3f5e3da83787278Doris Liu     * every frame.
48013351997aa36eb53e5ff0fcee3f5e3da83787278Doris Liu     *
48113351997aa36eb53e5ff0fcee3f5e3da83787278Doris Liu     * @param inReverse whether the animation should play in reverse direction
48213351997aa36eb53e5ff0fcee3f5e3da83787278Doris Liu     */
48313351997aa36eb53e5ff0fcee3f5e3da83787278Doris Liu    void startWithoutPulsing(boolean inReverse) {
48413351997aa36eb53e5ff0fcee3f5e3da83787278Doris Liu        if (inReverse) {
48513351997aa36eb53e5ff0fcee3f5e3da83787278Doris Liu            reverse();
48613351997aa36eb53e5ff0fcee3f5e3da83787278Doris Liu        } else {
48713351997aa36eb53e5ff0fcee3f5e3da83787278Doris Liu            start();
48813351997aa36eb53e5ff0fcee3f5e3da83787278Doris Liu        }
48913351997aa36eb53e5ff0fcee3f5e3da83787278Doris Liu    }
49013351997aa36eb53e5ff0fcee3f5e3da83787278Doris Liu
49113351997aa36eb53e5ff0fcee3f5e3da83787278Doris Liu    /**
49213351997aa36eb53e5ff0fcee3f5e3da83787278Doris Liu     * Internal use only.
49313351997aa36eb53e5ff0fcee3f5e3da83787278Doris Liu     * Skips the animation value to end/start, depending on whether the play direction is forward
49413351997aa36eb53e5ff0fcee3f5e3da83787278Doris Liu     * or backward.
49513351997aa36eb53e5ff0fcee3f5e3da83787278Doris Liu     *
49613351997aa36eb53e5ff0fcee3f5e3da83787278Doris Liu     * @param inReverse whether the end value is based on a reverse direction. If yes, this is
49713351997aa36eb53e5ff0fcee3f5e3da83787278Doris Liu     *                  equivalent to skip to start value in a forward playing direction.
49813351997aa36eb53e5ff0fcee3f5e3da83787278Doris Liu     */
49913351997aa36eb53e5ff0fcee3f5e3da83787278Doris Liu    void skipToEndValue(boolean inReverse) {}
50013351997aa36eb53e5ff0fcee3f5e3da83787278Doris Liu
50113351997aa36eb53e5ff0fcee3f5e3da83787278Doris Liu
50213351997aa36eb53e5ff0fcee3f5e3da83787278Doris Liu    /**
50313351997aa36eb53e5ff0fcee3f5e3da83787278Doris Liu     * Internal use only.
50413351997aa36eb53e5ff0fcee3f5e3da83787278Doris Liu     *
50513351997aa36eb53e5ff0fcee3f5e3da83787278Doris Liu     * Returns whether the animation has start/end values setup. For most of the animations, this
50613351997aa36eb53e5ff0fcee3f5e3da83787278Doris Liu     * should always be true. For ObjectAnimators, the start values are setup in the initialization
50713351997aa36eb53e5ff0fcee3f5e3da83787278Doris Liu     * of the animation.
50813351997aa36eb53e5ff0fcee3f5e3da83787278Doris Liu     */
50913351997aa36eb53e5ff0fcee3f5e3da83787278Doris Liu    boolean isInitialized() {
51013351997aa36eb53e5ff0fcee3f5e3da83787278Doris Liu        return true;
51113351997aa36eb53e5ff0fcee3f5e3da83787278Doris Liu    }
51213351997aa36eb53e5ff0fcee3f5e3da83787278Doris Liu
51313351997aa36eb53e5ff0fcee3f5e3da83787278Doris Liu    /**
51413351997aa36eb53e5ff0fcee3f5e3da83787278Doris Liu     * Internal use only.
51513351997aa36eb53e5ff0fcee3f5e3da83787278Doris Liu     */
51613351997aa36eb53e5ff0fcee3f5e3da83787278Doris Liu    void animateBasedOnPlayTime(long currentPlayTime, long lastPlayTime, boolean inReverse) {}
51713351997aa36eb53e5ff0fcee3f5e3da83787278Doris Liu
51813351997aa36eb53e5ff0fcee3f5e3da83787278Doris Liu    /**
519a18a86b43e40e3c15dcca0ae0148d641be9b25feChet Haase     * <p>An animation listener receives notifications from an animation.
520a18a86b43e40e3c15dcca0ae0148d641be9b25feChet Haase     * Notifications indicate animation related events, such as the end or the
521a18a86b43e40e3c15dcca0ae0148d641be9b25feChet Haase     * repetition of the animation.</p>
52217fb4b0d1cfbad1f026fec704c86640f070b4c2fChet Haase     */
523a18a86b43e40e3c15dcca0ae0148d641be9b25feChet Haase    public static interface AnimatorListener {
52413351997aa36eb53e5ff0fcee3f5e3da83787278Doris Liu
52513351997aa36eb53e5ff0fcee3f5e3da83787278Doris Liu        /**
52613351997aa36eb53e5ff0fcee3f5e3da83787278Doris Liu         * <p>Notifies the start of the animation as well as the animation's overall play direction.
52713351997aa36eb53e5ff0fcee3f5e3da83787278Doris Liu         * This method's default behavior is to call {@link #onAnimationStart(Animator)}. This
52813351997aa36eb53e5ff0fcee3f5e3da83787278Doris Liu         * method can be overridden, though not required, to get the additional play direction info
52913351997aa36eb53e5ff0fcee3f5e3da83787278Doris Liu         * when an animation starts. Skipping calling super when overriding this method results in
53013351997aa36eb53e5ff0fcee3f5e3da83787278Doris Liu         * {@link #onAnimationStart(Animator)} not getting called.
53113351997aa36eb53e5ff0fcee3f5e3da83787278Doris Liu         *
53213351997aa36eb53e5ff0fcee3f5e3da83787278Doris Liu         * @param animation The started animation.
53313351997aa36eb53e5ff0fcee3f5e3da83787278Doris Liu         * @param isReverse Whether the animation is playing in reverse.
53413351997aa36eb53e5ff0fcee3f5e3da83787278Doris Liu         */
53513351997aa36eb53e5ff0fcee3f5e3da83787278Doris Liu        default void onAnimationStart(Animator animation, boolean isReverse) {
53613351997aa36eb53e5ff0fcee3f5e3da83787278Doris Liu            onAnimationStart(animation);
53713351997aa36eb53e5ff0fcee3f5e3da83787278Doris Liu        }
53813351997aa36eb53e5ff0fcee3f5e3da83787278Doris Liu
53913351997aa36eb53e5ff0fcee3f5e3da83787278Doris Liu        /**
54013351997aa36eb53e5ff0fcee3f5e3da83787278Doris Liu         * <p>Notifies the end of the animation. This callback is not invoked
54113351997aa36eb53e5ff0fcee3f5e3da83787278Doris Liu         * for animations with repeat count set to INFINITE.</p>
54213351997aa36eb53e5ff0fcee3f5e3da83787278Doris Liu         *
54313351997aa36eb53e5ff0fcee3f5e3da83787278Doris Liu         * <p>This method's default behavior is to call {@link #onAnimationEnd(Animator)}. This
54413351997aa36eb53e5ff0fcee3f5e3da83787278Doris Liu         * method can be overridden, though not required, to get the additional play direction info
54513351997aa36eb53e5ff0fcee3f5e3da83787278Doris Liu         * when an animation ends. Skipping calling super when overriding this method results in
54613351997aa36eb53e5ff0fcee3f5e3da83787278Doris Liu         * {@link #onAnimationEnd(Animator)} not getting called.
54713351997aa36eb53e5ff0fcee3f5e3da83787278Doris Liu         *
54813351997aa36eb53e5ff0fcee3f5e3da83787278Doris Liu         * @param animation The animation which reached its end.
54913351997aa36eb53e5ff0fcee3f5e3da83787278Doris Liu         * @param isReverse Whether the animation is playing in reverse.
55013351997aa36eb53e5ff0fcee3f5e3da83787278Doris Liu         */
55113351997aa36eb53e5ff0fcee3f5e3da83787278Doris Liu        default void onAnimationEnd(Animator animation, boolean isReverse) {
55213351997aa36eb53e5ff0fcee3f5e3da83787278Doris Liu            onAnimationEnd(animation);
55313351997aa36eb53e5ff0fcee3f5e3da83787278Doris Liu        }
55413351997aa36eb53e5ff0fcee3f5e3da83787278Doris Liu
555a18a86b43e40e3c15dcca0ae0148d641be9b25feChet Haase        /**
556a18a86b43e40e3c15dcca0ae0148d641be9b25feChet Haase         * <p>Notifies the start of the animation.</p>
557a18a86b43e40e3c15dcca0ae0148d641be9b25feChet Haase         *
558a18a86b43e40e3c15dcca0ae0148d641be9b25feChet Haase         * @param animation The started animation.
559a18a86b43e40e3c15dcca0ae0148d641be9b25feChet Haase         */
560a18a86b43e40e3c15dcca0ae0148d641be9b25feChet Haase        void onAnimationStart(Animator animation);
56117fb4b0d1cfbad1f026fec704c86640f070b4c2fChet Haase
562a18a86b43e40e3c15dcca0ae0148d641be9b25feChet Haase        /**
563a18a86b43e40e3c15dcca0ae0148d641be9b25feChet Haase         * <p>Notifies the end of the animation. This callback is not invoked
564a18a86b43e40e3c15dcca0ae0148d641be9b25feChet Haase         * for animations with repeat count set to INFINITE.</p>
565a18a86b43e40e3c15dcca0ae0148d641be9b25feChet Haase         *
566a18a86b43e40e3c15dcca0ae0148d641be9b25feChet Haase         * @param animation The animation which reached its end.
567a18a86b43e40e3c15dcca0ae0148d641be9b25feChet Haase         */
568a18a86b43e40e3c15dcca0ae0148d641be9b25feChet Haase        void onAnimationEnd(Animator animation);
56917fb4b0d1cfbad1f026fec704c86640f070b4c2fChet Haase
570a18a86b43e40e3c15dcca0ae0148d641be9b25feChet Haase        /**
571a18a86b43e40e3c15dcca0ae0148d641be9b25feChet Haase         * <p>Notifies the cancellation of the animation. This callback is not invoked
572a18a86b43e40e3c15dcca0ae0148d641be9b25feChet Haase         * for animations with repeat count set to INFINITE.</p>
573a18a86b43e40e3c15dcca0ae0148d641be9b25feChet Haase         *
574a18a86b43e40e3c15dcca0ae0148d641be9b25feChet Haase         * @param animation The animation which was canceled.
575a18a86b43e40e3c15dcca0ae0148d641be9b25feChet Haase         */
576a18a86b43e40e3c15dcca0ae0148d641be9b25feChet Haase        void onAnimationCancel(Animator animation);
57749afa5bc100e5d4c069fea980dd6b09501f56397Chet Haase
57817fb4b0d1cfbad1f026fec704c86640f070b4c2fChet Haase        /**
579a18a86b43e40e3c15dcca0ae0148d641be9b25feChet Haase         * <p>Notifies the repetition of the animation.</p>
58017fb4b0d1cfbad1f026fec704c86640f070b4c2fChet Haase         *
58117fb4b0d1cfbad1f026fec704c86640f070b4c2fChet Haase         * @param animation The animation which was repeated.
58217fb4b0d1cfbad1f026fec704c86640f070b4c2fChet Haase         */
583a18a86b43e40e3c15dcca0ae0148d641be9b25feChet Haase        void onAnimationRepeat(Animator animation);
58417fb4b0d1cfbad1f026fec704c86640f070b4c2fChet Haase    }
5858aa1ffb0ed292891030992c65df4e5dc8bd37524Chet Haase
5868aa1ffb0ed292891030992c65df4e5dc8bd37524Chet Haase    /**
5878aa1ffb0ed292891030992c65df4e5dc8bd37524Chet Haase     * A pause listener receives notifications from an animation when the
5888aa1ffb0ed292891030992c65df4e5dc8bd37524Chet Haase     * animation is {@link #pause() paused} or {@link #resume() resumed}.
5898aa1ffb0ed292891030992c65df4e5dc8bd37524Chet Haase     *
5908aa1ffb0ed292891030992c65df4e5dc8bd37524Chet Haase     * @see #addPauseListener(AnimatorPauseListener)
5918aa1ffb0ed292891030992c65df4e5dc8bd37524Chet Haase     */
5928aa1ffb0ed292891030992c65df4e5dc8bd37524Chet Haase    public static interface AnimatorPauseListener {
5938aa1ffb0ed292891030992c65df4e5dc8bd37524Chet Haase        /**
5948aa1ffb0ed292891030992c65df4e5dc8bd37524Chet Haase         * <p>Notifies that the animation was paused.</p>
5958aa1ffb0ed292891030992c65df4e5dc8bd37524Chet Haase         *
5968aa1ffb0ed292891030992c65df4e5dc8bd37524Chet Haase         * @param animation The animaton being paused.
5978aa1ffb0ed292891030992c65df4e5dc8bd37524Chet Haase         * @see #pause()
5988aa1ffb0ed292891030992c65df4e5dc8bd37524Chet Haase         */
5998aa1ffb0ed292891030992c65df4e5dc8bd37524Chet Haase        void onAnimationPause(Animator animation);
6008aa1ffb0ed292891030992c65df4e5dc8bd37524Chet Haase
6018aa1ffb0ed292891030992c65df4e5dc8bd37524Chet Haase        /**
6028aa1ffb0ed292891030992c65df4e5dc8bd37524Chet Haase         * <p>Notifies that the animation was resumed, after being
6038aa1ffb0ed292891030992c65df4e5dc8bd37524Chet Haase         * previously paused.</p>
6048aa1ffb0ed292891030992c65df4e5dc8bd37524Chet Haase         *
6058aa1ffb0ed292891030992c65df4e5dc8bd37524Chet Haase         * @param animation The animation being resumed.
6068aa1ffb0ed292891030992c65df4e5dc8bd37524Chet Haase         * @see #resume()
6078aa1ffb0ed292891030992c65df4e5dc8bd37524Chet Haase         */
6088aa1ffb0ed292891030992c65df4e5dc8bd37524Chet Haase        void onAnimationResume(Animator animation);
6098aa1ffb0ed292891030992c65df4e5dc8bd37524Chet Haase    }
610c01bd1167a1b08d59557f214ddc48cf24d3b8d0aJohn Reck
611c01bd1167a1b08d59557f214ddc48cf24d3b8d0aJohn Reck    /**
612c01bd1167a1b08d59557f214ddc48cf24d3b8d0aJohn Reck     * <p>Whether or not the Animator is allowed to run asynchronously off of
613c01bd1167a1b08d59557f214ddc48cf24d3b8d0aJohn Reck     * the UI thread. This is a hint that informs the Animator that it is
614c01bd1167a1b08d59557f214ddc48cf24d3b8d0aJohn Reck     * OK to run the animation off-thread, however the Animator may decide
615c01bd1167a1b08d59557f214ddc48cf24d3b8d0aJohn Reck     * that it must run the animation on the UI thread anyway.
616c01bd1167a1b08d59557f214ddc48cf24d3b8d0aJohn Reck     *
617c01bd1167a1b08d59557f214ddc48cf24d3b8d0aJohn Reck     * <p>Regardless of whether or not the animation runs asynchronously, all
618c01bd1167a1b08d59557f214ddc48cf24d3b8d0aJohn Reck     * listener callbacks will be called on the UI thread.</p>
619c01bd1167a1b08d59557f214ddc48cf24d3b8d0aJohn Reck     *
620c01bd1167a1b08d59557f214ddc48cf24d3b8d0aJohn Reck     * <p>To be able to use this hint the following must be true:</p>
621c01bd1167a1b08d59557f214ddc48cf24d3b8d0aJohn Reck     * <ol>
622c01bd1167a1b08d59557f214ddc48cf24d3b8d0aJohn Reck     * <li>The animator is immutable while {@link #isStarted()} is true. Requests
623c01bd1167a1b08d59557f214ddc48cf24d3b8d0aJohn Reck     *    to change duration, delay, etc... may be ignored.</li>
624c01bd1167a1b08d59557f214ddc48cf24d3b8d0aJohn Reck     * <li>Lifecycle callback events may be asynchronous. Events such as
625c01bd1167a1b08d59557f214ddc48cf24d3b8d0aJohn Reck     *    {@link Animator.AnimatorListener#onAnimationEnd(Animator)} or
626c01bd1167a1b08d59557f214ddc48cf24d3b8d0aJohn Reck     *    {@link Animator.AnimatorListener#onAnimationRepeat(Animator)} may end up delayed
627c01bd1167a1b08d59557f214ddc48cf24d3b8d0aJohn Reck     *    as they must be posted back to the UI thread, and any actions performed
628c01bd1167a1b08d59557f214ddc48cf24d3b8d0aJohn Reck     *    by those callbacks (such as starting new animations) will not happen
629c01bd1167a1b08d59557f214ddc48cf24d3b8d0aJohn Reck     *    in the same frame.</li>
630c01bd1167a1b08d59557f214ddc48cf24d3b8d0aJohn Reck     * <li>State change requests ({@link #cancel()}, {@link #end()}, {@link #reverse()}, etc...)
631c01bd1167a1b08d59557f214ddc48cf24d3b8d0aJohn Reck     *    may be asynchronous. It is guaranteed that all state changes that are
632c01bd1167a1b08d59557f214ddc48cf24d3b8d0aJohn Reck     *    performed on the UI thread in the same frame will be applied as a single
633c01bd1167a1b08d59557f214ddc48cf24d3b8d0aJohn Reck     *    atomic update, however that frame may be the current frame,
634c01bd1167a1b08d59557f214ddc48cf24d3b8d0aJohn Reck     *    the next frame, or some future frame. This will also impact the observed
635c01bd1167a1b08d59557f214ddc48cf24d3b8d0aJohn Reck     *    state of the Animator. For example, {@link #isStarted()} may still return true
636c01bd1167a1b08d59557f214ddc48cf24d3b8d0aJohn Reck     *    after a call to {@link #end()}. Using the lifecycle callbacks is preferred over
637c01bd1167a1b08d59557f214ddc48cf24d3b8d0aJohn Reck     *    queries to {@link #isStarted()}, {@link #isRunning()}, and {@link #isPaused()}
638c01bd1167a1b08d59557f214ddc48cf24d3b8d0aJohn Reck     *    for this reason.</li>
639c01bd1167a1b08d59557f214ddc48cf24d3b8d0aJohn Reck     * </ol>
640c01bd1167a1b08d59557f214ddc48cf24d3b8d0aJohn Reck     * @hide
641c01bd1167a1b08d59557f214ddc48cf24d3b8d0aJohn Reck     */
642c01bd1167a1b08d59557f214ddc48cf24d3b8d0aJohn Reck    public void setAllowRunningAsynchronously(boolean mayRunAsync) {
643c01bd1167a1b08d59557f214ddc48cf24d3b8d0aJohn Reck        // It is up to subclasses to support this, if they can.
644c01bd1167a1b08d59557f214ddc48cf24d3b8d0aJohn Reck    }
645d422dc358f0100106dc07d7b903201eb9b043b11Yigit Boyar
646d422dc358f0100106dc07d7b903201eb9b043b11Yigit Boyar    /**
647d422dc358f0100106dc07d7b903201eb9b043b11Yigit Boyar     * Creates a {@link ConstantState} which holds changing configurations information associated
648d422dc358f0100106dc07d7b903201eb9b043b11Yigit Boyar     * with the given Animator.
649d422dc358f0100106dc07d7b903201eb9b043b11Yigit Boyar     * <p>
650d422dc358f0100106dc07d7b903201eb9b043b11Yigit Boyar     * When {@link #newInstance()} is called, default implementation clones the Animator.
651d422dc358f0100106dc07d7b903201eb9b043b11Yigit Boyar     */
652d422dc358f0100106dc07d7b903201eb9b043b11Yigit Boyar    private static class AnimatorConstantState extends ConstantState<Animator> {
653d422dc358f0100106dc07d7b903201eb9b043b11Yigit Boyar
654d422dc358f0100106dc07d7b903201eb9b043b11Yigit Boyar        final Animator mAnimator;
655ac85f90466dd60d2af8ffc3942d503a0de606726Alan Viverette        @Config int mChangingConf;
656d422dc358f0100106dc07d7b903201eb9b043b11Yigit Boyar
657d422dc358f0100106dc07d7b903201eb9b043b11Yigit Boyar        public AnimatorConstantState(Animator animator) {
658d422dc358f0100106dc07d7b903201eb9b043b11Yigit Boyar            mAnimator = animator;
659d422dc358f0100106dc07d7b903201eb9b043b11Yigit Boyar            // ensure a reference back to here so that constante state is not gc'ed.
660d422dc358f0100106dc07d7b903201eb9b043b11Yigit Boyar            mAnimator.mConstantState = this;
661d422dc358f0100106dc07d7b903201eb9b043b11Yigit Boyar            mChangingConf = mAnimator.getChangingConfigurations();
662d422dc358f0100106dc07d7b903201eb9b043b11Yigit Boyar        }
663d422dc358f0100106dc07d7b903201eb9b043b11Yigit Boyar
664d422dc358f0100106dc07d7b903201eb9b043b11Yigit Boyar        @Override
665ac85f90466dd60d2af8ffc3942d503a0de606726Alan Viverette        public @Config int getChangingConfigurations() {
666d422dc358f0100106dc07d7b903201eb9b043b11Yigit Boyar            return mChangingConf;
667d422dc358f0100106dc07d7b903201eb9b043b11Yigit Boyar        }
668d422dc358f0100106dc07d7b903201eb9b043b11Yigit Boyar
669d422dc358f0100106dc07d7b903201eb9b043b11Yigit Boyar        @Override
670d422dc358f0100106dc07d7b903201eb9b043b11Yigit Boyar        public Animator newInstance() {
671d422dc358f0100106dc07d7b903201eb9b043b11Yigit Boyar            final Animator clone = mAnimator.clone();
672d422dc358f0100106dc07d7b903201eb9b043b11Yigit Boyar            clone.mConstantState = this;
673d422dc358f0100106dc07d7b903201eb9b043b11Yigit Boyar            return clone;
674d422dc358f0100106dc07d7b903201eb9b043b11Yigit Boyar        }
675d422dc358f0100106dc07d7b903201eb9b043b11Yigit Boyar    }
676a18a86b43e40e3c15dcca0ae0148d641be9b25feChet Haase}
677