Animator.java revision b8f574a165bf6ec5b316734b367ac274ded4809b
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 java.util.ArrayList;
2017fb4b0d1cfbad1f026fec704c86640f070b4c2fChet Haase
2117fb4b0d1cfbad1f026fec704c86640f070b4c2fChet Haase/**
22a18a86b43e40e3c15dcca0ae0148d641be9b25feChet Haase * This is the superclass for classes which provide basic support for animations which can be
23a18a86b43e40e3c15dcca0ae0148d641be9b25feChet Haase * started, ended, and have <code>AnimatorListeners</code> added to them.
2417fb4b0d1cfbad1f026fec704c86640f070b4c2fChet Haase */
25a18a86b43e40e3c15dcca0ae0148d641be9b25feChet Haasepublic abstract class Animator implements Cloneable {
2617fb4b0d1cfbad1f026fec704c86640f070b4c2fChet Haase
2717fb4b0d1cfbad1f026fec704c86640f070b4c2fChet Haase
2817fb4b0d1cfbad1f026fec704c86640f070b4c2fChet Haase    /**
2917fb4b0d1cfbad1f026fec704c86640f070b4c2fChet Haase     * The set of listeners to be sent events through the life of an animation.
3017fb4b0d1cfbad1f026fec704c86640f070b4c2fChet Haase     */
31a18a86b43e40e3c15dcca0ae0148d641be9b25feChet Haase    ArrayList<AnimatorListener> mListeners = null;
32d51d368f2d512ab657b8ae45780c82c0dbea94c3Chet Haase
33d51d368f2d512ab657b8ae45780c82c0dbea94c3Chet Haase    /**
34a18a86b43e40e3c15dcca0ae0148d641be9b25feChet Haase     * Starts this animation. If the animation has a nonzero startDelay, the animation will start
35b8f574a165bf6ec5b316734b367ac274ded4809bChet Haase     * running after that delay elapses. A non-delayed animation will have its initial
36b8f574a165bf6ec5b316734b367ac274ded4809bChet Haase     * value(s) set immediately, followed by calls to
37b8f574a165bf6ec5b316734b367ac274ded4809bChet Haase     * {@link AnimatorListener#onAnimationStart(Animator)} for any listeners of this animator.
38e2ab7ccd385cdb6517955c719e1d2b49771bedb6Chet Haase     *
39e2ab7ccd385cdb6517955c719e1d2b49771bedb6Chet Haase     * <p>The animation started by calling this method will be run on the thread that called
40e2ab7ccd385cdb6517955c719e1d2b49771bedb6Chet Haase     * this method. This thread should have a Looper on it (a runtime exception will be thrown if
41e2ab7ccd385cdb6517955c719e1d2b49771bedb6Chet Haase     * this is not the case). Also, if the animation will animate
42e2ab7ccd385cdb6517955c719e1d2b49771bedb6Chet Haase     * properties of objects in the view hierarchy, then the calling thread should be the UI
43e2ab7ccd385cdb6517955c719e1d2b49771bedb6Chet Haase     * thread for that view hierarchy.</p>
44e2ab7ccd385cdb6517955c719e1d2b49771bedb6Chet Haase     *
45d51d368f2d512ab657b8ae45780c82c0dbea94c3Chet Haase     */
46a18a86b43e40e3c15dcca0ae0148d641be9b25feChet Haase    public void start() {
475d7b50b800b9898f5ca0b2b4d8b73ed6a4ee1749Chet Haase    }
485d7b50b800b9898f5ca0b2b4d8b73ed6a4ee1749Chet Haase
495d7b50b800b9898f5ca0b2b4d8b73ed6a4ee1749Chet Haase    /**
50a18a86b43e40e3c15dcca0ae0148d641be9b25feChet Haase     * Cancels the animation. Unlike {@link #end()}, <code>cancel()</code> causes the animation to
51e2ab7ccd385cdb6517955c719e1d2b49771bedb6Chet Haase     * stop in its tracks, sending an
52e2ab7ccd385cdb6517955c719e1d2b49771bedb6Chet Haase     * {@link android.animation.Animator.AnimatorListener#onAnimationCancel(Animator)} to
53e2ab7ccd385cdb6517955c719e1d2b49771bedb6Chet Haase     * its listeners, followed by an
54e2ab7ccd385cdb6517955c719e1d2b49771bedb6Chet Haase     * {@link android.animation.Animator.AnimatorListener#onAnimationEnd(Animator)} message.
55e2ab7ccd385cdb6517955c719e1d2b49771bedb6Chet Haase     *
56e2ab7ccd385cdb6517955c719e1d2b49771bedb6Chet Haase     * <p>This method must be called on the thread that is running the animation.</p>
575d7b50b800b9898f5ca0b2b4d8b73ed6a4ee1749Chet Haase     */
58a18a86b43e40e3c15dcca0ae0148d641be9b25feChet Haase    public void cancel() {
59fe591563f8529305bd52e1f0640e83b9a93d562fChet Haase    }
60fe591563f8529305bd52e1f0640e83b9a93d562fChet Haase
61fe591563f8529305bd52e1f0640e83b9a93d562fChet Haase    /**
62a18a86b43e40e3c15dcca0ae0148d641be9b25feChet Haase     * Ends the animation. This causes the animation to assign the end value of the property being
63e2ab7ccd385cdb6517955c719e1d2b49771bedb6Chet Haase     * animated, then calling the
64e2ab7ccd385cdb6517955c719e1d2b49771bedb6Chet Haase     * {@link android.animation.Animator.AnimatorListener#onAnimationEnd(Animator)} method on
65a18a86b43e40e3c15dcca0ae0148d641be9b25feChet Haase     * its listeners.
66e2ab7ccd385cdb6517955c719e1d2b49771bedb6Chet Haase     *
67e2ab7ccd385cdb6517955c719e1d2b49771bedb6Chet Haase     * <p>This method must be called on the thread that is running the animation.</p>
6817fb4b0d1cfbad1f026fec704c86640f070b4c2fChet Haase     */
69a18a86b43e40e3c15dcca0ae0148d641be9b25feChet Haase    public void end() {
7017fb4b0d1cfbad1f026fec704c86640f070b4c2fChet Haase    }
7117fb4b0d1cfbad1f026fec704c86640f070b4c2fChet Haase
7217fb4b0d1cfbad1f026fec704c86640f070b4c2fChet Haase    /**
7317fb4b0d1cfbad1f026fec704c86640f070b4c2fChet Haase     * The amount of time, in milliseconds, to delay starting the animation after
7417fb4b0d1cfbad1f026fec704c86640f070b4c2fChet Haase     * {@link #start()} is called.
7517fb4b0d1cfbad1f026fec704c86640f070b4c2fChet Haase     *
7617fb4b0d1cfbad1f026fec704c86640f070b4c2fChet Haase     * @return the number of milliseconds to delay running the animation
7717fb4b0d1cfbad1f026fec704c86640f070b4c2fChet Haase     */
78a18a86b43e40e3c15dcca0ae0148d641be9b25feChet Haase    public abstract long getStartDelay();
7917fb4b0d1cfbad1f026fec704c86640f070b4c2fChet Haase
8017fb4b0d1cfbad1f026fec704c86640f070b4c2fChet Haase    /**
8117fb4b0d1cfbad1f026fec704c86640f070b4c2fChet Haase     * The amount of time, in milliseconds, to delay starting the animation after
8217fb4b0d1cfbad1f026fec704c86640f070b4c2fChet Haase     * {@link #start()} is called.
8317fb4b0d1cfbad1f026fec704c86640f070b4c2fChet Haase
8417fb4b0d1cfbad1f026fec704c86640f070b4c2fChet Haase     * @param startDelay The amount of the delay, in milliseconds
8517fb4b0d1cfbad1f026fec704c86640f070b4c2fChet Haase     */
86a18a86b43e40e3c15dcca0ae0148d641be9b25feChet Haase    public abstract void setStartDelay(long startDelay);
8717fb4b0d1cfbad1f026fec704c86640f070b4c2fChet Haase
8817fb4b0d1cfbad1f026fec704c86640f070b4c2fChet Haase
8917fb4b0d1cfbad1f026fec704c86640f070b4c2fChet Haase    /**
90a18a86b43e40e3c15dcca0ae0148d641be9b25feChet Haase     * Sets the length of the animation.
91d953d08e9299072130d9f4411cbcf6678bbce822Chet Haase     *
92a18a86b43e40e3c15dcca0ae0148d641be9b25feChet Haase     * @param duration The length of the animation, in milliseconds.
93d953d08e9299072130d9f4411cbcf6678bbce822Chet Haase     */
942794eb3b02e2404d453d3ad22a8a85a138130a07Chet Haase    public abstract Animator setDuration(long duration);
9517fb4b0d1cfbad1f026fec704c86640f070b4c2fChet Haase
9617fb4b0d1cfbad1f026fec704c86640f070b4c2fChet Haase    /**
97a18a86b43e40e3c15dcca0ae0148d641be9b25feChet Haase     * Gets the length of the animation.
9817fb4b0d1cfbad1f026fec704c86640f070b4c2fChet Haase     *
99a18a86b43e40e3c15dcca0ae0148d641be9b25feChet Haase     * @return The length of the animation, in milliseconds.
10017fb4b0d1cfbad1f026fec704c86640f070b4c2fChet Haase     */
101a18a86b43e40e3c15dcca0ae0148d641be9b25feChet Haase    public abstract long getDuration();
10217fb4b0d1cfbad1f026fec704c86640f070b4c2fChet Haase
10317fb4b0d1cfbad1f026fec704c86640f070b4c2fChet Haase    /**
104a18a86b43e40e3c15dcca0ae0148d641be9b25feChet Haase     * The time interpolator used in calculating the elapsed fraction of this animation. The
105a18a86b43e40e3c15dcca0ae0148d641be9b25feChet Haase     * interpolator determines whether the animation runs with linear or non-linear motion,
106a18a86b43e40e3c15dcca0ae0148d641be9b25feChet Haase     * such as acceleration and deceleration. The default value is
107a18a86b43e40e3c15dcca0ae0148d641be9b25feChet Haase     * {@link android.view.animation.AccelerateDecelerateInterpolator}
10817fb4b0d1cfbad1f026fec704c86640f070b4c2fChet Haase     *
109a18a86b43e40e3c15dcca0ae0148d641be9b25feChet Haase     * @param value the interpolator to be used by this animation
11017fb4b0d1cfbad1f026fec704c86640f070b4c2fChet Haase     */
111e0ee2e9f3102c3c14c873a75a7b04e49787e0fb9Chet Haase    public abstract void setInterpolator(TimeInterpolator value);
11217fb4b0d1cfbad1f026fec704c86640f070b4c2fChet Haase
11317fb4b0d1cfbad1f026fec704c86640f070b4c2fChet Haase    /**
114a18a86b43e40e3c15dcca0ae0148d641be9b25feChet Haase     * Returns whether this Animator is currently running (having been started and not yet ended).
115a18a86b43e40e3c15dcca0ae0148d641be9b25feChet Haase     * @return Whether the Animator is running.
11617fb4b0d1cfbad1f026fec704c86640f070b4c2fChet Haase     */
117a18a86b43e40e3c15dcca0ae0148d641be9b25feChet Haase    public abstract boolean isRunning();
11817fb4b0d1cfbad1f026fec704c86640f070b4c2fChet Haase
11917fb4b0d1cfbad1f026fec704c86640f070b4c2fChet Haase    /**
120a18a86b43e40e3c15dcca0ae0148d641be9b25feChet Haase     * Adds a listener to the set of listeners that are sent events through the life of an
121a18a86b43e40e3c15dcca0ae0148d641be9b25feChet Haase     * animation, such as start, repeat, and end.
12217fb4b0d1cfbad1f026fec704c86640f070b4c2fChet Haase     *
12317fb4b0d1cfbad1f026fec704c86640f070b4c2fChet Haase     * @param listener the listener to be added to the current set of listeners for this animation.
12417fb4b0d1cfbad1f026fec704c86640f070b4c2fChet Haase     */
125a18a86b43e40e3c15dcca0ae0148d641be9b25feChet Haase    public void addListener(AnimatorListener listener) {
126a18a86b43e40e3c15dcca0ae0148d641be9b25feChet Haase        if (mListeners == null) {
127a18a86b43e40e3c15dcca0ae0148d641be9b25feChet Haase            mListeners = new ArrayList<AnimatorListener>();
12817fb4b0d1cfbad1f026fec704c86640f070b4c2fChet Haase        }
129a18a86b43e40e3c15dcca0ae0148d641be9b25feChet Haase        mListeners.add(listener);
13017fb4b0d1cfbad1f026fec704c86640f070b4c2fChet Haase    }
13117fb4b0d1cfbad1f026fec704c86640f070b4c2fChet Haase
13217fb4b0d1cfbad1f026fec704c86640f070b4c2fChet Haase    /**
133a18a86b43e40e3c15dcca0ae0148d641be9b25feChet Haase     * Removes a listener from the set listening to this animation.
13417fb4b0d1cfbad1f026fec704c86640f070b4c2fChet Haase     *
135a18a86b43e40e3c15dcca0ae0148d641be9b25feChet Haase     * @param listener the listener to be removed from the current set of listeners for this
136a18a86b43e40e3c15dcca0ae0148d641be9b25feChet Haase     *                 animation.
13717fb4b0d1cfbad1f026fec704c86640f070b4c2fChet Haase     */
138a18a86b43e40e3c15dcca0ae0148d641be9b25feChet Haase    public void removeListener(AnimatorListener listener) {
139a18a86b43e40e3c15dcca0ae0148d641be9b25feChet Haase        if (mListeners == null) {
14017fb4b0d1cfbad1f026fec704c86640f070b4c2fChet Haase            return;
14117fb4b0d1cfbad1f026fec704c86640f070b4c2fChet Haase        }
142a18a86b43e40e3c15dcca0ae0148d641be9b25feChet Haase        mListeners.remove(listener);
143a18a86b43e40e3c15dcca0ae0148d641be9b25feChet Haase        if (mListeners.size() == 0) {
144a18a86b43e40e3c15dcca0ae0148d641be9b25feChet Haase            mListeners = null;
14517fb4b0d1cfbad1f026fec704c86640f070b4c2fChet Haase        }
14617fb4b0d1cfbad1f026fec704c86640f070b4c2fChet Haase    }
14717fb4b0d1cfbad1f026fec704c86640f070b4c2fChet Haase
14817fb4b0d1cfbad1f026fec704c86640f070b4c2fChet Haase    /**
149a18a86b43e40e3c15dcca0ae0148d641be9b25feChet Haase     * Gets the set of {@link android.animation.Animator.AnimatorListener} objects that are currently
150a18a86b43e40e3c15dcca0ae0148d641be9b25feChet Haase     * listening for events on this <code>Animator</code> object.
15117fb4b0d1cfbad1f026fec704c86640f070b4c2fChet Haase     *
152a18a86b43e40e3c15dcca0ae0148d641be9b25feChet Haase     * @return ArrayList<AnimatorListener> The set of listeners.
15317fb4b0d1cfbad1f026fec704c86640f070b4c2fChet Haase     */
154a18a86b43e40e3c15dcca0ae0148d641be9b25feChet Haase    public ArrayList<AnimatorListener> getListeners() {
155a18a86b43e40e3c15dcca0ae0148d641be9b25feChet Haase        return mListeners;
15617fb4b0d1cfbad1f026fec704c86640f070b4c2fChet Haase    }
15717fb4b0d1cfbad1f026fec704c86640f070b4c2fChet Haase
15817fb4b0d1cfbad1f026fec704c86640f070b4c2fChet Haase    /**
159a18a86b43e40e3c15dcca0ae0148d641be9b25feChet Haase     * Removes all listeners from this object. This is equivalent to calling
160a18a86b43e40e3c15dcca0ae0148d641be9b25feChet Haase     * <code>getListeners()</code> followed by calling <code>clear()</code> on the
161a18a86b43e40e3c15dcca0ae0148d641be9b25feChet Haase     * returned list of listeners.
162602e4d3824bf8b9cb9f817375d195b969712176aChet Haase     */
163a18a86b43e40e3c15dcca0ae0148d641be9b25feChet Haase    public void removeAllListeners() {
16417fb4b0d1cfbad1f026fec704c86640f070b4c2fChet Haase        if (mListeners != null) {
165a18a86b43e40e3c15dcca0ae0148d641be9b25feChet Haase            mListeners.clear();
166a18a86b43e40e3c15dcca0ae0148d641be9b25feChet Haase            mListeners = null;
16717fb4b0d1cfbad1f026fec704c86640f070b4c2fChet Haase        }
16817fb4b0d1cfbad1f026fec704c86640f070b4c2fChet Haase    }
16917fb4b0d1cfbad1f026fec704c86640f070b4c2fChet Haase
1705c7649857246333572eb332b505ad617365ef5faChet Haase    @Override
171a18a86b43e40e3c15dcca0ae0148d641be9b25feChet Haase    public Animator clone() {
172a18a86b43e40e3c15dcca0ae0148d641be9b25feChet Haase        try {
173a18a86b43e40e3c15dcca0ae0148d641be9b25feChet Haase            final Animator anim = (Animator) super.clone();
174a18a86b43e40e3c15dcca0ae0148d641be9b25feChet Haase            if (mListeners != null) {
175a18a86b43e40e3c15dcca0ae0148d641be9b25feChet Haase                ArrayList<AnimatorListener> oldListeners = mListeners;
176a18a86b43e40e3c15dcca0ae0148d641be9b25feChet Haase                anim.mListeners = new ArrayList<AnimatorListener>();
177a18a86b43e40e3c15dcca0ae0148d641be9b25feChet Haase                int numListeners = oldListeners.size();
178a18a86b43e40e3c15dcca0ae0148d641be9b25feChet Haase                for (int i = 0; i < numListeners; ++i) {
179a18a86b43e40e3c15dcca0ae0148d641be9b25feChet Haase                    anim.mListeners.add(oldListeners.get(i));
180a18a86b43e40e3c15dcca0ae0148d641be9b25feChet Haase                }
181673e42fafd4088970ec95e1f13c61dc83132c74eChet Haase            }
182a18a86b43e40e3c15dcca0ae0148d641be9b25feChet Haase            return anim;
183a18a86b43e40e3c15dcca0ae0148d641be9b25feChet Haase        } catch (CloneNotSupportedException e) {
184a18a86b43e40e3c15dcca0ae0148d641be9b25feChet Haase           throw new AssertionError();
185673e42fafd4088970ec95e1f13c61dc83132c74eChet Haase        }
1865c7649857246333572eb332b505ad617365ef5faChet Haase    }
1875c7649857246333572eb332b505ad617365ef5faChet Haase
1885c7649857246333572eb332b505ad617365ef5faChet Haase    /**
189a18a86b43e40e3c15dcca0ae0148d641be9b25feChet Haase     * This method tells the object to use appropriate information to extract
190a18a86b43e40e3c15dcca0ae0148d641be9b25feChet Haase     * starting values for the animation. For example, a AnimatorSet object will pass
191a18a86b43e40e3c15dcca0ae0148d641be9b25feChet Haase     * this call to its child objects to tell them to set up the values. A
192a18a86b43e40e3c15dcca0ae0148d641be9b25feChet Haase     * ObjectAnimator object will use the information it has about its target object
193a18a86b43e40e3c15dcca0ae0148d641be9b25feChet Haase     * and PropertyValuesHolder objects to get the start values for its properties.
194a18a86b43e40e3c15dcca0ae0148d641be9b25feChet Haase     * An ValueAnimator object will ignore the request since it does not have enough
195a18a86b43e40e3c15dcca0ae0148d641be9b25feChet Haase     * information (such as a target object) to gather these values.
1965c7649857246333572eb332b505ad617365ef5faChet Haase     */
197a18a86b43e40e3c15dcca0ae0148d641be9b25feChet Haase    public void setupStartValues() {
1985c7649857246333572eb332b505ad617365ef5faChet Haase    }
1995c7649857246333572eb332b505ad617365ef5faChet Haase
2005c7649857246333572eb332b505ad617365ef5faChet Haase    /**
201a18a86b43e40e3c15dcca0ae0148d641be9b25feChet Haase     * This method tells the object to use appropriate information to extract
202a18a86b43e40e3c15dcca0ae0148d641be9b25feChet Haase     * ending values for the animation. For example, a AnimatorSet object will pass
203a18a86b43e40e3c15dcca0ae0148d641be9b25feChet Haase     * this call to its child objects to tell them to set up the values. A
204a18a86b43e40e3c15dcca0ae0148d641be9b25feChet Haase     * ObjectAnimator object will use the information it has about its target object
205a18a86b43e40e3c15dcca0ae0148d641be9b25feChet Haase     * and PropertyValuesHolder objects to get the start values for its properties.
206a18a86b43e40e3c15dcca0ae0148d641be9b25feChet Haase     * An ValueAnimator object will ignore the request since it does not have enough
207a18a86b43e40e3c15dcca0ae0148d641be9b25feChet Haase     * information (such as a target object) to gather these values.
20817fb4b0d1cfbad1f026fec704c86640f070b4c2fChet Haase     */
209a18a86b43e40e3c15dcca0ae0148d641be9b25feChet Haase    public void setupEndValues() {
21017fb4b0d1cfbad1f026fec704c86640f070b4c2fChet Haase    }
21117fb4b0d1cfbad1f026fec704c86640f070b4c2fChet Haase
21217fb4b0d1cfbad1f026fec704c86640f070b4c2fChet Haase    /**
213a18a86b43e40e3c15dcca0ae0148d641be9b25feChet Haase     * Sets the target object whose property will be animated by this animation. Not all subclasses
214a18a86b43e40e3c15dcca0ae0148d641be9b25feChet Haase     * operate on target objects (for example, {@link ValueAnimator}, but this method
215a18a86b43e40e3c15dcca0ae0148d641be9b25feChet Haase     * is on the superclass for the convenience of dealing generically with those subclasses
216a18a86b43e40e3c15dcca0ae0148d641be9b25feChet Haase     * that do handle targets.
21717fb4b0d1cfbad1f026fec704c86640f070b4c2fChet Haase     *
218a18a86b43e40e3c15dcca0ae0148d641be9b25feChet Haase     * @param target The object being animated
21917fb4b0d1cfbad1f026fec704c86640f070b4c2fChet Haase     */
220a18a86b43e40e3c15dcca0ae0148d641be9b25feChet Haase    public void setTarget(Object target) {
22117fb4b0d1cfbad1f026fec704c86640f070b4c2fChet Haase    }
22217fb4b0d1cfbad1f026fec704c86640f070b4c2fChet Haase
22317fb4b0d1cfbad1f026fec704c86640f070b4c2fChet Haase    /**
224a18a86b43e40e3c15dcca0ae0148d641be9b25feChet Haase     * <p>An animation listener receives notifications from an animation.
225a18a86b43e40e3c15dcca0ae0148d641be9b25feChet Haase     * Notifications indicate animation related events, such as the end or the
226a18a86b43e40e3c15dcca0ae0148d641be9b25feChet Haase     * repetition of the animation.</p>
22717fb4b0d1cfbad1f026fec704c86640f070b4c2fChet Haase     */
228a18a86b43e40e3c15dcca0ae0148d641be9b25feChet Haase    public static interface AnimatorListener {
229a18a86b43e40e3c15dcca0ae0148d641be9b25feChet Haase        /**
230a18a86b43e40e3c15dcca0ae0148d641be9b25feChet Haase         * <p>Notifies the start of the animation.</p>
231a18a86b43e40e3c15dcca0ae0148d641be9b25feChet Haase         *
232a18a86b43e40e3c15dcca0ae0148d641be9b25feChet Haase         * @param animation The started animation.
233a18a86b43e40e3c15dcca0ae0148d641be9b25feChet Haase         */
234a18a86b43e40e3c15dcca0ae0148d641be9b25feChet Haase        void onAnimationStart(Animator animation);
23517fb4b0d1cfbad1f026fec704c86640f070b4c2fChet Haase
236a18a86b43e40e3c15dcca0ae0148d641be9b25feChet Haase        /**
237a18a86b43e40e3c15dcca0ae0148d641be9b25feChet Haase         * <p>Notifies the end of the animation. This callback is not invoked
238a18a86b43e40e3c15dcca0ae0148d641be9b25feChet Haase         * for animations with repeat count set to INFINITE.</p>
239a18a86b43e40e3c15dcca0ae0148d641be9b25feChet Haase         *
240a18a86b43e40e3c15dcca0ae0148d641be9b25feChet Haase         * @param animation The animation which reached its end.
241a18a86b43e40e3c15dcca0ae0148d641be9b25feChet Haase         */
242a18a86b43e40e3c15dcca0ae0148d641be9b25feChet Haase        void onAnimationEnd(Animator animation);
24317fb4b0d1cfbad1f026fec704c86640f070b4c2fChet Haase
244a18a86b43e40e3c15dcca0ae0148d641be9b25feChet Haase        /**
245a18a86b43e40e3c15dcca0ae0148d641be9b25feChet Haase         * <p>Notifies the cancellation of the animation. This callback is not invoked
246a18a86b43e40e3c15dcca0ae0148d641be9b25feChet Haase         * for animations with repeat count set to INFINITE.</p>
247a18a86b43e40e3c15dcca0ae0148d641be9b25feChet Haase         *
248a18a86b43e40e3c15dcca0ae0148d641be9b25feChet Haase         * @param animation The animation which was canceled.
249a18a86b43e40e3c15dcca0ae0148d641be9b25feChet Haase         */
250a18a86b43e40e3c15dcca0ae0148d641be9b25feChet Haase        void onAnimationCancel(Animator animation);
25149afa5bc100e5d4c069fea980dd6b09501f56397Chet Haase
25217fb4b0d1cfbad1f026fec704c86640f070b4c2fChet Haase        /**
253a18a86b43e40e3c15dcca0ae0148d641be9b25feChet Haase         * <p>Notifies the repetition of the animation.</p>
25417fb4b0d1cfbad1f026fec704c86640f070b4c2fChet Haase         *
25517fb4b0d1cfbad1f026fec704c86640f070b4c2fChet Haase         * @param animation The animation which was repeated.
25617fb4b0d1cfbad1f026fec704c86640f070b4c2fChet Haase         */
257a18a86b43e40e3c15dcca0ae0148d641be9b25feChet Haase        void onAnimationRepeat(Animator animation);
25817fb4b0d1cfbad1f026fec704c86640f070b4c2fChet Haase    }
259a18a86b43e40e3c15dcca0ae0148d641be9b25feChet Haase}
260