Animator.java revision 8b699792b677bd4dd8442b32641ac09d48fdd79c
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 /** 1148b699792b677bd4dd8442b32641ac09d48fdd79cChet Haase * Returns whether this Animator is currently running (having been started and gone past any 1158b699792b677bd4dd8442b32641ac09d48fdd79cChet Haase * initial startDelay period and not yet ended). 1168b699792b677bd4dd8442b32641ac09d48fdd79cChet Haase * 117a18a86b43e40e3c15dcca0ae0148d641be9b25feChet Haase * @return Whether the Animator is running. 11817fb4b0d1cfbad1f026fec704c86640f070b4c2fChet Haase */ 119a18a86b43e40e3c15dcca0ae0148d641be9b25feChet Haase public abstract boolean isRunning(); 12017fb4b0d1cfbad1f026fec704c86640f070b4c2fChet Haase 12117fb4b0d1cfbad1f026fec704c86640f070b4c2fChet Haase /** 1228b699792b677bd4dd8442b32641ac09d48fdd79cChet Haase * Returns whether this Animator has been started and not yet ended. This state is a superset 1238b699792b677bd4dd8442b32641ac09d48fdd79cChet Haase * of the state of {@link #isRunning()}, because an Animator with a nonzero 1248b699792b677bd4dd8442b32641ac09d48fdd79cChet Haase * {@link #getStartDelay() startDelay} will return true for {@link #isStarted()} during the 1258b699792b677bd4dd8442b32641ac09d48fdd79cChet Haase * delay phase, whereas {@link #isRunning()} will return true only after the delay phase 1268b699792b677bd4dd8442b32641ac09d48fdd79cChet Haase * is complete. 1278b699792b677bd4dd8442b32641ac09d48fdd79cChet Haase * 1288b699792b677bd4dd8442b32641ac09d48fdd79cChet Haase * @return Whether the Animator has been started and not yet ended. 1298b699792b677bd4dd8442b32641ac09d48fdd79cChet Haase */ 1308b699792b677bd4dd8442b32641ac09d48fdd79cChet Haase public boolean isStarted() { 1318b699792b677bd4dd8442b32641ac09d48fdd79cChet Haase // Default method returns value for isRunning(). Subclasses should override to return a 1328b699792b677bd4dd8442b32641ac09d48fdd79cChet Haase // real value. 1338b699792b677bd4dd8442b32641ac09d48fdd79cChet Haase return isRunning(); 1348b699792b677bd4dd8442b32641ac09d48fdd79cChet Haase } 1358b699792b677bd4dd8442b32641ac09d48fdd79cChet Haase 1368b699792b677bd4dd8442b32641ac09d48fdd79cChet Haase /** 137a18a86b43e40e3c15dcca0ae0148d641be9b25feChet Haase * Adds a listener to the set of listeners that are sent events through the life of an 138a18a86b43e40e3c15dcca0ae0148d641be9b25feChet Haase * animation, such as start, repeat, and end. 13917fb4b0d1cfbad1f026fec704c86640f070b4c2fChet Haase * 14017fb4b0d1cfbad1f026fec704c86640f070b4c2fChet Haase * @param listener the listener to be added to the current set of listeners for this animation. 14117fb4b0d1cfbad1f026fec704c86640f070b4c2fChet Haase */ 142a18a86b43e40e3c15dcca0ae0148d641be9b25feChet Haase public void addListener(AnimatorListener listener) { 143a18a86b43e40e3c15dcca0ae0148d641be9b25feChet Haase if (mListeners == null) { 144a18a86b43e40e3c15dcca0ae0148d641be9b25feChet Haase mListeners = new ArrayList<AnimatorListener>(); 14517fb4b0d1cfbad1f026fec704c86640f070b4c2fChet Haase } 146a18a86b43e40e3c15dcca0ae0148d641be9b25feChet Haase mListeners.add(listener); 14717fb4b0d1cfbad1f026fec704c86640f070b4c2fChet Haase } 14817fb4b0d1cfbad1f026fec704c86640f070b4c2fChet Haase 14917fb4b0d1cfbad1f026fec704c86640f070b4c2fChet Haase /** 150a18a86b43e40e3c15dcca0ae0148d641be9b25feChet Haase * Removes a listener from the set listening to this animation. 15117fb4b0d1cfbad1f026fec704c86640f070b4c2fChet Haase * 152a18a86b43e40e3c15dcca0ae0148d641be9b25feChet Haase * @param listener the listener to be removed from the current set of listeners for this 153a18a86b43e40e3c15dcca0ae0148d641be9b25feChet Haase * animation. 15417fb4b0d1cfbad1f026fec704c86640f070b4c2fChet Haase */ 155a18a86b43e40e3c15dcca0ae0148d641be9b25feChet Haase public void removeListener(AnimatorListener listener) { 156a18a86b43e40e3c15dcca0ae0148d641be9b25feChet Haase if (mListeners == null) { 15717fb4b0d1cfbad1f026fec704c86640f070b4c2fChet Haase return; 15817fb4b0d1cfbad1f026fec704c86640f070b4c2fChet Haase } 159a18a86b43e40e3c15dcca0ae0148d641be9b25feChet Haase mListeners.remove(listener); 160a18a86b43e40e3c15dcca0ae0148d641be9b25feChet Haase if (mListeners.size() == 0) { 161a18a86b43e40e3c15dcca0ae0148d641be9b25feChet Haase mListeners = null; 16217fb4b0d1cfbad1f026fec704c86640f070b4c2fChet Haase } 16317fb4b0d1cfbad1f026fec704c86640f070b4c2fChet Haase } 16417fb4b0d1cfbad1f026fec704c86640f070b4c2fChet Haase 16517fb4b0d1cfbad1f026fec704c86640f070b4c2fChet Haase /** 166a18a86b43e40e3c15dcca0ae0148d641be9b25feChet Haase * Gets the set of {@link android.animation.Animator.AnimatorListener} objects that are currently 167a18a86b43e40e3c15dcca0ae0148d641be9b25feChet Haase * listening for events on this <code>Animator</code> object. 16817fb4b0d1cfbad1f026fec704c86640f070b4c2fChet Haase * 169a18a86b43e40e3c15dcca0ae0148d641be9b25feChet Haase * @return ArrayList<AnimatorListener> The set of listeners. 17017fb4b0d1cfbad1f026fec704c86640f070b4c2fChet Haase */ 171a18a86b43e40e3c15dcca0ae0148d641be9b25feChet Haase public ArrayList<AnimatorListener> getListeners() { 172a18a86b43e40e3c15dcca0ae0148d641be9b25feChet Haase return mListeners; 17317fb4b0d1cfbad1f026fec704c86640f070b4c2fChet Haase } 17417fb4b0d1cfbad1f026fec704c86640f070b4c2fChet Haase 17517fb4b0d1cfbad1f026fec704c86640f070b4c2fChet Haase /** 176a18a86b43e40e3c15dcca0ae0148d641be9b25feChet Haase * Removes all listeners from this object. This is equivalent to calling 177a18a86b43e40e3c15dcca0ae0148d641be9b25feChet Haase * <code>getListeners()</code> followed by calling <code>clear()</code> on the 178a18a86b43e40e3c15dcca0ae0148d641be9b25feChet Haase * returned list of listeners. 179602e4d3824bf8b9cb9f817375d195b969712176aChet Haase */ 180a18a86b43e40e3c15dcca0ae0148d641be9b25feChet Haase public void removeAllListeners() { 18117fb4b0d1cfbad1f026fec704c86640f070b4c2fChet Haase if (mListeners != null) { 182a18a86b43e40e3c15dcca0ae0148d641be9b25feChet Haase mListeners.clear(); 183a18a86b43e40e3c15dcca0ae0148d641be9b25feChet Haase mListeners = null; 18417fb4b0d1cfbad1f026fec704c86640f070b4c2fChet Haase } 18517fb4b0d1cfbad1f026fec704c86640f070b4c2fChet Haase } 18617fb4b0d1cfbad1f026fec704c86640f070b4c2fChet Haase 1875c7649857246333572eb332b505ad617365ef5faChet Haase @Override 188a18a86b43e40e3c15dcca0ae0148d641be9b25feChet Haase public Animator clone() { 189a18a86b43e40e3c15dcca0ae0148d641be9b25feChet Haase try { 190a18a86b43e40e3c15dcca0ae0148d641be9b25feChet Haase final Animator anim = (Animator) super.clone(); 191a18a86b43e40e3c15dcca0ae0148d641be9b25feChet Haase if (mListeners != null) { 192a18a86b43e40e3c15dcca0ae0148d641be9b25feChet Haase ArrayList<AnimatorListener> oldListeners = mListeners; 193a18a86b43e40e3c15dcca0ae0148d641be9b25feChet Haase anim.mListeners = new ArrayList<AnimatorListener>(); 194a18a86b43e40e3c15dcca0ae0148d641be9b25feChet Haase int numListeners = oldListeners.size(); 195a18a86b43e40e3c15dcca0ae0148d641be9b25feChet Haase for (int i = 0; i < numListeners; ++i) { 196a18a86b43e40e3c15dcca0ae0148d641be9b25feChet Haase anim.mListeners.add(oldListeners.get(i)); 197a18a86b43e40e3c15dcca0ae0148d641be9b25feChet Haase } 198673e42fafd4088970ec95e1f13c61dc83132c74eChet Haase } 199a18a86b43e40e3c15dcca0ae0148d641be9b25feChet Haase return anim; 200a18a86b43e40e3c15dcca0ae0148d641be9b25feChet Haase } catch (CloneNotSupportedException e) { 201a18a86b43e40e3c15dcca0ae0148d641be9b25feChet Haase throw new AssertionError(); 202673e42fafd4088970ec95e1f13c61dc83132c74eChet Haase } 2035c7649857246333572eb332b505ad617365ef5faChet Haase } 2045c7649857246333572eb332b505ad617365ef5faChet Haase 2055c7649857246333572eb332b505ad617365ef5faChet Haase /** 206a18a86b43e40e3c15dcca0ae0148d641be9b25feChet Haase * This method tells the object to use appropriate information to extract 207a18a86b43e40e3c15dcca0ae0148d641be9b25feChet Haase * starting values for the animation. For example, a AnimatorSet object will pass 208a18a86b43e40e3c15dcca0ae0148d641be9b25feChet Haase * this call to its child objects to tell them to set up the values. A 209a18a86b43e40e3c15dcca0ae0148d641be9b25feChet Haase * ObjectAnimator object will use the information it has about its target object 210a18a86b43e40e3c15dcca0ae0148d641be9b25feChet Haase * and PropertyValuesHolder objects to get the start values for its properties. 211a18a86b43e40e3c15dcca0ae0148d641be9b25feChet Haase * An ValueAnimator object will ignore the request since it does not have enough 212a18a86b43e40e3c15dcca0ae0148d641be9b25feChet Haase * information (such as a target object) to gather these values. 2135c7649857246333572eb332b505ad617365ef5faChet Haase */ 214a18a86b43e40e3c15dcca0ae0148d641be9b25feChet Haase public void setupStartValues() { 2155c7649857246333572eb332b505ad617365ef5faChet Haase } 2165c7649857246333572eb332b505ad617365ef5faChet Haase 2175c7649857246333572eb332b505ad617365ef5faChet Haase /** 218a18a86b43e40e3c15dcca0ae0148d641be9b25feChet Haase * This method tells the object to use appropriate information to extract 219a18a86b43e40e3c15dcca0ae0148d641be9b25feChet Haase * ending values for the animation. For example, a AnimatorSet object will pass 220a18a86b43e40e3c15dcca0ae0148d641be9b25feChet Haase * this call to its child objects to tell them to set up the values. A 221a18a86b43e40e3c15dcca0ae0148d641be9b25feChet Haase * ObjectAnimator object will use the information it has about its target object 222a18a86b43e40e3c15dcca0ae0148d641be9b25feChet Haase * and PropertyValuesHolder objects to get the start values for its properties. 223a18a86b43e40e3c15dcca0ae0148d641be9b25feChet Haase * An ValueAnimator object will ignore the request since it does not have enough 224a18a86b43e40e3c15dcca0ae0148d641be9b25feChet Haase * information (such as a target object) to gather these values. 22517fb4b0d1cfbad1f026fec704c86640f070b4c2fChet Haase */ 226a18a86b43e40e3c15dcca0ae0148d641be9b25feChet Haase public void setupEndValues() { 22717fb4b0d1cfbad1f026fec704c86640f070b4c2fChet Haase } 22817fb4b0d1cfbad1f026fec704c86640f070b4c2fChet Haase 22917fb4b0d1cfbad1f026fec704c86640f070b4c2fChet Haase /** 230a18a86b43e40e3c15dcca0ae0148d641be9b25feChet Haase * Sets the target object whose property will be animated by this animation. Not all subclasses 231a18a86b43e40e3c15dcca0ae0148d641be9b25feChet Haase * operate on target objects (for example, {@link ValueAnimator}, but this method 232a18a86b43e40e3c15dcca0ae0148d641be9b25feChet Haase * is on the superclass for the convenience of dealing generically with those subclasses 233a18a86b43e40e3c15dcca0ae0148d641be9b25feChet Haase * that do handle targets. 23417fb4b0d1cfbad1f026fec704c86640f070b4c2fChet Haase * 235a18a86b43e40e3c15dcca0ae0148d641be9b25feChet Haase * @param target The object being animated 23617fb4b0d1cfbad1f026fec704c86640f070b4c2fChet Haase */ 237a18a86b43e40e3c15dcca0ae0148d641be9b25feChet Haase public void setTarget(Object target) { 23817fb4b0d1cfbad1f026fec704c86640f070b4c2fChet Haase } 23917fb4b0d1cfbad1f026fec704c86640f070b4c2fChet Haase 24017fb4b0d1cfbad1f026fec704c86640f070b4c2fChet Haase /** 241a18a86b43e40e3c15dcca0ae0148d641be9b25feChet Haase * <p>An animation listener receives notifications from an animation. 242a18a86b43e40e3c15dcca0ae0148d641be9b25feChet Haase * Notifications indicate animation related events, such as the end or the 243a18a86b43e40e3c15dcca0ae0148d641be9b25feChet Haase * repetition of the animation.</p> 24417fb4b0d1cfbad1f026fec704c86640f070b4c2fChet Haase */ 245a18a86b43e40e3c15dcca0ae0148d641be9b25feChet Haase public static interface AnimatorListener { 246a18a86b43e40e3c15dcca0ae0148d641be9b25feChet Haase /** 247a18a86b43e40e3c15dcca0ae0148d641be9b25feChet Haase * <p>Notifies the start of the animation.</p> 248a18a86b43e40e3c15dcca0ae0148d641be9b25feChet Haase * 249a18a86b43e40e3c15dcca0ae0148d641be9b25feChet Haase * @param animation The started animation. 250a18a86b43e40e3c15dcca0ae0148d641be9b25feChet Haase */ 251a18a86b43e40e3c15dcca0ae0148d641be9b25feChet Haase void onAnimationStart(Animator animation); 25217fb4b0d1cfbad1f026fec704c86640f070b4c2fChet Haase 253a18a86b43e40e3c15dcca0ae0148d641be9b25feChet Haase /** 254a18a86b43e40e3c15dcca0ae0148d641be9b25feChet Haase * <p>Notifies the end of the animation. This callback is not invoked 255a18a86b43e40e3c15dcca0ae0148d641be9b25feChet Haase * for animations with repeat count set to INFINITE.</p> 256a18a86b43e40e3c15dcca0ae0148d641be9b25feChet Haase * 257a18a86b43e40e3c15dcca0ae0148d641be9b25feChet Haase * @param animation The animation which reached its end. 258a18a86b43e40e3c15dcca0ae0148d641be9b25feChet Haase */ 259a18a86b43e40e3c15dcca0ae0148d641be9b25feChet Haase void onAnimationEnd(Animator animation); 26017fb4b0d1cfbad1f026fec704c86640f070b4c2fChet Haase 261a18a86b43e40e3c15dcca0ae0148d641be9b25feChet Haase /** 262a18a86b43e40e3c15dcca0ae0148d641be9b25feChet Haase * <p>Notifies the cancellation of the animation. This callback is not invoked 263a18a86b43e40e3c15dcca0ae0148d641be9b25feChet Haase * for animations with repeat count set to INFINITE.</p> 264a18a86b43e40e3c15dcca0ae0148d641be9b25feChet Haase * 265a18a86b43e40e3c15dcca0ae0148d641be9b25feChet Haase * @param animation The animation which was canceled. 266a18a86b43e40e3c15dcca0ae0148d641be9b25feChet Haase */ 267a18a86b43e40e3c15dcca0ae0148d641be9b25feChet Haase void onAnimationCancel(Animator animation); 26849afa5bc100e5d4c069fea980dd6b09501f56397Chet Haase 26917fb4b0d1cfbad1f026fec704c86640f070b4c2fChet Haase /** 270a18a86b43e40e3c15dcca0ae0148d641be9b25feChet Haase * <p>Notifies the repetition of the animation.</p> 27117fb4b0d1cfbad1f026fec704c86640f070b4c2fChet Haase * 27217fb4b0d1cfbad1f026fec704c86640f070b4c2fChet Haase * @param animation The animation which was repeated. 27317fb4b0d1cfbad1f026fec704c86640f070b4c2fChet Haase */ 274a18a86b43e40e3c15dcca0ae0148d641be9b25feChet Haase void onAnimationRepeat(Animator animation); 27517fb4b0d1cfbad1f026fec704c86640f070b4c2fChet Haase } 276a18a86b43e40e3c15dcca0ae0148d641be9b25feChet Haase} 277