Animator.java revision e8cee38c6a8dd54cc222cbbd8655ae32a66a8e73
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 */ 25e8cee38c6a8dd54cc222cbbd8655ae32a66a8e73Chet Haasepublic abstract class Animator implements Cloneable { 2617fb4b0d1cfbad1f026fec704c86640f070b4c2fChet Haase 2717fb4b0d1cfbad1f026fec704c86640f070b4c2fChet Haase /** 2817fb4b0d1cfbad1f026fec704c86640f070b4c2fChet Haase * The set of listeners to be sent events through the life of an animation. 2917fb4b0d1cfbad1f026fec704c86640f070b4c2fChet Haase */ 30a18a86b43e40e3c15dcca0ae0148d641be9b25feChet Haase ArrayList<AnimatorListener> mListeners = null; 31d51d368f2d512ab657b8ae45780c82c0dbea94c3Chet Haase 32d51d368f2d512ab657b8ae45780c82c0dbea94c3Chet Haase /** 33a18a86b43e40e3c15dcca0ae0148d641be9b25feChet Haase * Starts this animation. If the animation has a nonzero startDelay, the animation will start 34b8f574a165bf6ec5b316734b367ac274ded4809bChet Haase * running after that delay elapses. A non-delayed animation will have its initial 35b8f574a165bf6ec5b316734b367ac274ded4809bChet Haase * value(s) set immediately, followed by calls to 36b8f574a165bf6ec5b316734b367ac274ded4809bChet Haase * {@link AnimatorListener#onAnimationStart(Animator)} for any listeners of this animator. 37e2ab7ccd385cdb6517955c719e1d2b49771bedb6Chet Haase * 38e2ab7ccd385cdb6517955c719e1d2b49771bedb6Chet Haase * <p>The animation started by calling this method will be run on the thread that called 39e2ab7ccd385cdb6517955c719e1d2b49771bedb6Chet Haase * this method. This thread should have a Looper on it (a runtime exception will be thrown if 40e2ab7ccd385cdb6517955c719e1d2b49771bedb6Chet Haase * this is not the case). Also, if the animation will animate 41e2ab7ccd385cdb6517955c719e1d2b49771bedb6Chet Haase * properties of objects in the view hierarchy, then the calling thread should be the UI 42e2ab7ccd385cdb6517955c719e1d2b49771bedb6Chet Haase * thread for that view hierarchy.</p> 43e2ab7ccd385cdb6517955c719e1d2b49771bedb6Chet Haase * 44d51d368f2d512ab657b8ae45780c82c0dbea94c3Chet Haase */ 45a18a86b43e40e3c15dcca0ae0148d641be9b25feChet Haase public void start() { 465d7b50b800b9898f5ca0b2b4d8b73ed6a4ee1749Chet Haase } 475d7b50b800b9898f5ca0b2b4d8b73ed6a4ee1749Chet Haase 485d7b50b800b9898f5ca0b2b4d8b73ed6a4ee1749Chet Haase /** 49a18a86b43e40e3c15dcca0ae0148d641be9b25feChet Haase * Cancels the animation. Unlike {@link #end()}, <code>cancel()</code> causes the animation to 50e2ab7ccd385cdb6517955c719e1d2b49771bedb6Chet Haase * stop in its tracks, sending an 51e2ab7ccd385cdb6517955c719e1d2b49771bedb6Chet Haase * {@link android.animation.Animator.AnimatorListener#onAnimationCancel(Animator)} to 52e2ab7ccd385cdb6517955c719e1d2b49771bedb6Chet Haase * its listeners, followed by an 53e2ab7ccd385cdb6517955c719e1d2b49771bedb6Chet Haase * {@link android.animation.Animator.AnimatorListener#onAnimationEnd(Animator)} message. 54e2ab7ccd385cdb6517955c719e1d2b49771bedb6Chet Haase * 55e2ab7ccd385cdb6517955c719e1d2b49771bedb6Chet Haase * <p>This method must be called on the thread that is running the animation.</p> 565d7b50b800b9898f5ca0b2b4d8b73ed6a4ee1749Chet Haase */ 57a18a86b43e40e3c15dcca0ae0148d641be9b25feChet Haase public void cancel() { 58fe591563f8529305bd52e1f0640e83b9a93d562fChet Haase } 59fe591563f8529305bd52e1f0640e83b9a93d562fChet Haase 60fe591563f8529305bd52e1f0640e83b9a93d562fChet Haase /** 61a18a86b43e40e3c15dcca0ae0148d641be9b25feChet Haase * Ends the animation. This causes the animation to assign the end value of the property being 62e2ab7ccd385cdb6517955c719e1d2b49771bedb6Chet Haase * animated, then calling the 63e2ab7ccd385cdb6517955c719e1d2b49771bedb6Chet Haase * {@link android.animation.Animator.AnimatorListener#onAnimationEnd(Animator)} method on 64a18a86b43e40e3c15dcca0ae0148d641be9b25feChet Haase * its listeners. 65e2ab7ccd385cdb6517955c719e1d2b49771bedb6Chet Haase * 66e2ab7ccd385cdb6517955c719e1d2b49771bedb6Chet Haase * <p>This method must be called on the thread that is running the animation.</p> 6717fb4b0d1cfbad1f026fec704c86640f070b4c2fChet Haase */ 68a18a86b43e40e3c15dcca0ae0148d641be9b25feChet Haase public void end() { 6917fb4b0d1cfbad1f026fec704c86640f070b4c2fChet Haase } 7017fb4b0d1cfbad1f026fec704c86640f070b4c2fChet Haase 7117fb4b0d1cfbad1f026fec704c86640f070b4c2fChet Haase /** 72e8cee38c6a8dd54cc222cbbd8655ae32a66a8e73Chet Haase * The amount of time, in milliseconds, to delay processing the animation 73e8cee38c6a8dd54cc222cbbd8655ae32a66a8e73Chet Haase * after {@link #start()} is called. 74e8cee38c6a8dd54cc222cbbd8655ae32a66a8e73Chet Haase * 75e8cee38c6a8dd54cc222cbbd8655ae32a66a8e73Chet Haase * @return the number of milliseconds to delay running the animation 76e8cee38c6a8dd54cc222cbbd8655ae32a66a8e73Chet Haase */ 77e8cee38c6a8dd54cc222cbbd8655ae32a66a8e73Chet Haase public abstract long getStartDelay(); 78e8cee38c6a8dd54cc222cbbd8655ae32a66a8e73Chet Haase 79e8cee38c6a8dd54cc222cbbd8655ae32a66a8e73Chet Haase /** 80e8cee38c6a8dd54cc222cbbd8655ae32a66a8e73Chet Haase * The amount of time, in milliseconds, to delay processing the animation 81e8cee38c6a8dd54cc222cbbd8655ae32a66a8e73Chet Haase * after {@link #start()} is called. 82e8cee38c6a8dd54cc222cbbd8655ae32a66a8e73Chet Haase 83e8cee38c6a8dd54cc222cbbd8655ae32a66a8e73Chet Haase * @param startDelay The amount of the delay, in milliseconds 84e8cee38c6a8dd54cc222cbbd8655ae32a66a8e73Chet Haase */ 85e8cee38c6a8dd54cc222cbbd8655ae32a66a8e73Chet Haase public abstract void setStartDelay(long startDelay); 86e8cee38c6a8dd54cc222cbbd8655ae32a66a8e73Chet Haase 87e8cee38c6a8dd54cc222cbbd8655ae32a66a8e73Chet Haase /** 88e8cee38c6a8dd54cc222cbbd8655ae32a66a8e73Chet Haase * Sets the duration of the animation. 89e8cee38c6a8dd54cc222cbbd8655ae32a66a8e73Chet Haase * 90e8cee38c6a8dd54cc222cbbd8655ae32a66a8e73Chet Haase * @param duration The length of the animation, in milliseconds. 91e8cee38c6a8dd54cc222cbbd8655ae32a66a8e73Chet Haase */ 92e8cee38c6a8dd54cc222cbbd8655ae32a66a8e73Chet Haase public abstract Animator setDuration(long duration); 93e8cee38c6a8dd54cc222cbbd8655ae32a66a8e73Chet Haase 94e8cee38c6a8dd54cc222cbbd8655ae32a66a8e73Chet Haase /** 95e8cee38c6a8dd54cc222cbbd8655ae32a66a8e73Chet Haase * Gets the duration of the animation. 96e8cee38c6a8dd54cc222cbbd8655ae32a66a8e73Chet Haase * 97e8cee38c6a8dd54cc222cbbd8655ae32a66a8e73Chet Haase * @return The length of the animation, in milliseconds. 98e8cee38c6a8dd54cc222cbbd8655ae32a66a8e73Chet Haase */ 99e8cee38c6a8dd54cc222cbbd8655ae32a66a8e73Chet Haase public abstract long getDuration(); 100e8cee38c6a8dd54cc222cbbd8655ae32a66a8e73Chet Haase 101e8cee38c6a8dd54cc222cbbd8655ae32a66a8e73Chet Haase /** 102e8cee38c6a8dd54cc222cbbd8655ae32a66a8e73Chet Haase * The time interpolator used in calculating the elapsed fraction of the 103e8cee38c6a8dd54cc222cbbd8655ae32a66a8e73Chet Haase * animation. The interpolator determines whether the animation runs with 104e8cee38c6a8dd54cc222cbbd8655ae32a66a8e73Chet Haase * linear or non-linear motion, such as acceleration and deceleration. The 105e8cee38c6a8dd54cc222cbbd8655ae32a66a8e73Chet Haase * default value is {@link android.view.animation.AccelerateDecelerateInterpolator}. 106e8cee38c6a8dd54cc222cbbd8655ae32a66a8e73Chet Haase * 107e8cee38c6a8dd54cc222cbbd8655ae32a66a8e73Chet Haase * @param value the interpolator to be used by this animation 108e8cee38c6a8dd54cc222cbbd8655ae32a66a8e73Chet Haase */ 109e8cee38c6a8dd54cc222cbbd8655ae32a66a8e73Chet Haase public abstract void setInterpolator(TimeInterpolator value); 110e8cee38c6a8dd54cc222cbbd8655ae32a66a8e73Chet Haase 111e8cee38c6a8dd54cc222cbbd8655ae32a66a8e73Chet Haase /** 112e8cee38c6a8dd54cc222cbbd8655ae32a66a8e73Chet Haase * Returns the timing interpolator that this animation uses. 113e8cee38c6a8dd54cc222cbbd8655ae32a66a8e73Chet Haase * 114e8cee38c6a8dd54cc222cbbd8655ae32a66a8e73Chet Haase * @return The timing interpolator for this animation. 115e8cee38c6a8dd54cc222cbbd8655ae32a66a8e73Chet Haase */ 116e8cee38c6a8dd54cc222cbbd8655ae32a66a8e73Chet Haase public TimeInterpolator getInterpolator() { 117e8cee38c6a8dd54cc222cbbd8655ae32a66a8e73Chet Haase return null; 118e8cee38c6a8dd54cc222cbbd8655ae32a66a8e73Chet Haase } 119e8cee38c6a8dd54cc222cbbd8655ae32a66a8e73Chet Haase 120e8cee38c6a8dd54cc222cbbd8655ae32a66a8e73Chet Haase /** 1218b699792b677bd4dd8442b32641ac09d48fdd79cChet Haase * Returns whether this Animator is currently running (having been started and gone past any 1228b699792b677bd4dd8442b32641ac09d48fdd79cChet Haase * initial startDelay period and not yet ended). 1238b699792b677bd4dd8442b32641ac09d48fdd79cChet Haase * 124a18a86b43e40e3c15dcca0ae0148d641be9b25feChet Haase * @return Whether the Animator is running. 12517fb4b0d1cfbad1f026fec704c86640f070b4c2fChet Haase */ 126a18a86b43e40e3c15dcca0ae0148d641be9b25feChet Haase public abstract boolean isRunning(); 12717fb4b0d1cfbad1f026fec704c86640f070b4c2fChet Haase 12817fb4b0d1cfbad1f026fec704c86640f070b4c2fChet Haase /** 1298b699792b677bd4dd8442b32641ac09d48fdd79cChet Haase * Returns whether this Animator has been started and not yet ended. This state is a superset 1308b699792b677bd4dd8442b32641ac09d48fdd79cChet Haase * of the state of {@link #isRunning()}, because an Animator with a nonzero 1318b699792b677bd4dd8442b32641ac09d48fdd79cChet Haase * {@link #getStartDelay() startDelay} will return true for {@link #isStarted()} during the 1328b699792b677bd4dd8442b32641ac09d48fdd79cChet Haase * delay phase, whereas {@link #isRunning()} will return true only after the delay phase 1338b699792b677bd4dd8442b32641ac09d48fdd79cChet Haase * is complete. 1348b699792b677bd4dd8442b32641ac09d48fdd79cChet Haase * 1358b699792b677bd4dd8442b32641ac09d48fdd79cChet Haase * @return Whether the Animator has been started and not yet ended. 1368b699792b677bd4dd8442b32641ac09d48fdd79cChet Haase */ 1378b699792b677bd4dd8442b32641ac09d48fdd79cChet Haase public boolean isStarted() { 1388b699792b677bd4dd8442b32641ac09d48fdd79cChet Haase // Default method returns value for isRunning(). Subclasses should override to return a 1398b699792b677bd4dd8442b32641ac09d48fdd79cChet Haase // real value. 1408b699792b677bd4dd8442b32641ac09d48fdd79cChet Haase return isRunning(); 1418b699792b677bd4dd8442b32641ac09d48fdd79cChet Haase } 1428b699792b677bd4dd8442b32641ac09d48fdd79cChet Haase 1438b699792b677bd4dd8442b32641ac09d48fdd79cChet Haase /** 144a18a86b43e40e3c15dcca0ae0148d641be9b25feChet Haase * Adds a listener to the set of listeners that are sent events through the life of an 145a18a86b43e40e3c15dcca0ae0148d641be9b25feChet Haase * animation, such as start, repeat, and end. 14617fb4b0d1cfbad1f026fec704c86640f070b4c2fChet Haase * 14717fb4b0d1cfbad1f026fec704c86640f070b4c2fChet Haase * @param listener the listener to be added to the current set of listeners for this animation. 14817fb4b0d1cfbad1f026fec704c86640f070b4c2fChet Haase */ 149a18a86b43e40e3c15dcca0ae0148d641be9b25feChet Haase public void addListener(AnimatorListener listener) { 150a18a86b43e40e3c15dcca0ae0148d641be9b25feChet Haase if (mListeners == null) { 151a18a86b43e40e3c15dcca0ae0148d641be9b25feChet Haase mListeners = new ArrayList<AnimatorListener>(); 15217fb4b0d1cfbad1f026fec704c86640f070b4c2fChet Haase } 153a18a86b43e40e3c15dcca0ae0148d641be9b25feChet Haase mListeners.add(listener); 15417fb4b0d1cfbad1f026fec704c86640f070b4c2fChet Haase } 15517fb4b0d1cfbad1f026fec704c86640f070b4c2fChet Haase 15617fb4b0d1cfbad1f026fec704c86640f070b4c2fChet Haase /** 157a18a86b43e40e3c15dcca0ae0148d641be9b25feChet Haase * Removes a listener from the set listening to this animation. 15817fb4b0d1cfbad1f026fec704c86640f070b4c2fChet Haase * 159a18a86b43e40e3c15dcca0ae0148d641be9b25feChet Haase * @param listener the listener to be removed from the current set of listeners for this 160a18a86b43e40e3c15dcca0ae0148d641be9b25feChet Haase * animation. 16117fb4b0d1cfbad1f026fec704c86640f070b4c2fChet Haase */ 162a18a86b43e40e3c15dcca0ae0148d641be9b25feChet Haase public void removeListener(AnimatorListener listener) { 163a18a86b43e40e3c15dcca0ae0148d641be9b25feChet Haase if (mListeners == null) { 16417fb4b0d1cfbad1f026fec704c86640f070b4c2fChet Haase return; 16517fb4b0d1cfbad1f026fec704c86640f070b4c2fChet Haase } 166a18a86b43e40e3c15dcca0ae0148d641be9b25feChet Haase mListeners.remove(listener); 167a18a86b43e40e3c15dcca0ae0148d641be9b25feChet Haase if (mListeners.size() == 0) { 168a18a86b43e40e3c15dcca0ae0148d641be9b25feChet Haase mListeners = null; 16917fb4b0d1cfbad1f026fec704c86640f070b4c2fChet Haase } 17017fb4b0d1cfbad1f026fec704c86640f070b4c2fChet Haase } 17117fb4b0d1cfbad1f026fec704c86640f070b4c2fChet Haase 17217fb4b0d1cfbad1f026fec704c86640f070b4c2fChet Haase /** 173a18a86b43e40e3c15dcca0ae0148d641be9b25feChet Haase * Gets the set of {@link android.animation.Animator.AnimatorListener} objects that are currently 174a18a86b43e40e3c15dcca0ae0148d641be9b25feChet Haase * listening for events on this <code>Animator</code> object. 17517fb4b0d1cfbad1f026fec704c86640f070b4c2fChet Haase * 176a18a86b43e40e3c15dcca0ae0148d641be9b25feChet Haase * @return ArrayList<AnimatorListener> The set of listeners. 17717fb4b0d1cfbad1f026fec704c86640f070b4c2fChet Haase */ 178a18a86b43e40e3c15dcca0ae0148d641be9b25feChet Haase public ArrayList<AnimatorListener> getListeners() { 179a18a86b43e40e3c15dcca0ae0148d641be9b25feChet Haase return mListeners; 18017fb4b0d1cfbad1f026fec704c86640f070b4c2fChet Haase } 18117fb4b0d1cfbad1f026fec704c86640f070b4c2fChet Haase 18217fb4b0d1cfbad1f026fec704c86640f070b4c2fChet Haase /** 183a18a86b43e40e3c15dcca0ae0148d641be9b25feChet Haase * Removes all listeners from this object. This is equivalent to calling 184a18a86b43e40e3c15dcca0ae0148d641be9b25feChet Haase * <code>getListeners()</code> followed by calling <code>clear()</code> on the 185a18a86b43e40e3c15dcca0ae0148d641be9b25feChet Haase * returned list of listeners. 186602e4d3824bf8b9cb9f817375d195b969712176aChet Haase */ 187a18a86b43e40e3c15dcca0ae0148d641be9b25feChet Haase public void removeAllListeners() { 18817fb4b0d1cfbad1f026fec704c86640f070b4c2fChet Haase if (mListeners != null) { 189a18a86b43e40e3c15dcca0ae0148d641be9b25feChet Haase mListeners.clear(); 190a18a86b43e40e3c15dcca0ae0148d641be9b25feChet Haase mListeners = null; 19117fb4b0d1cfbad1f026fec704c86640f070b4c2fChet Haase } 19217fb4b0d1cfbad1f026fec704c86640f070b4c2fChet Haase } 19317fb4b0d1cfbad1f026fec704c86640f070b4c2fChet Haase 1945c7649857246333572eb332b505ad617365ef5faChet Haase @Override 195a18a86b43e40e3c15dcca0ae0148d641be9b25feChet Haase public Animator clone() { 196a18a86b43e40e3c15dcca0ae0148d641be9b25feChet Haase try { 197a18a86b43e40e3c15dcca0ae0148d641be9b25feChet Haase final Animator anim = (Animator) super.clone(); 198a18a86b43e40e3c15dcca0ae0148d641be9b25feChet Haase if (mListeners != null) { 199a18a86b43e40e3c15dcca0ae0148d641be9b25feChet Haase ArrayList<AnimatorListener> oldListeners = mListeners; 200a18a86b43e40e3c15dcca0ae0148d641be9b25feChet Haase anim.mListeners = new ArrayList<AnimatorListener>(); 201a18a86b43e40e3c15dcca0ae0148d641be9b25feChet Haase int numListeners = oldListeners.size(); 202a18a86b43e40e3c15dcca0ae0148d641be9b25feChet Haase for (int i = 0; i < numListeners; ++i) { 203a18a86b43e40e3c15dcca0ae0148d641be9b25feChet Haase anim.mListeners.add(oldListeners.get(i)); 204a18a86b43e40e3c15dcca0ae0148d641be9b25feChet Haase } 205673e42fafd4088970ec95e1f13c61dc83132c74eChet Haase } 206a18a86b43e40e3c15dcca0ae0148d641be9b25feChet Haase return anim; 207a18a86b43e40e3c15dcca0ae0148d641be9b25feChet Haase } catch (CloneNotSupportedException e) { 208a18a86b43e40e3c15dcca0ae0148d641be9b25feChet Haase throw new AssertionError(); 209673e42fafd4088970ec95e1f13c61dc83132c74eChet Haase } 2105c7649857246333572eb332b505ad617365ef5faChet Haase } 2115c7649857246333572eb332b505ad617365ef5faChet Haase 2125c7649857246333572eb332b505ad617365ef5faChet Haase /** 213a18a86b43e40e3c15dcca0ae0148d641be9b25feChet Haase * This method tells the object to use appropriate information to extract 214a18a86b43e40e3c15dcca0ae0148d641be9b25feChet Haase * starting values for the animation. For example, a AnimatorSet object will pass 215a18a86b43e40e3c15dcca0ae0148d641be9b25feChet Haase * this call to its child objects to tell them to set up the values. A 216a18a86b43e40e3c15dcca0ae0148d641be9b25feChet Haase * ObjectAnimator object will use the information it has about its target object 217a18a86b43e40e3c15dcca0ae0148d641be9b25feChet Haase * and PropertyValuesHolder objects to get the start values for its properties. 218f76a50ce8fdc6aea22cabc77b2977a1a15a79630Ken Wakasa * A ValueAnimator object will ignore the request since it does not have enough 219a18a86b43e40e3c15dcca0ae0148d641be9b25feChet Haase * information (such as a target object) to gather these values. 2205c7649857246333572eb332b505ad617365ef5faChet Haase */ 221a18a86b43e40e3c15dcca0ae0148d641be9b25feChet Haase public void setupStartValues() { 2225c7649857246333572eb332b505ad617365ef5faChet Haase } 2235c7649857246333572eb332b505ad617365ef5faChet Haase 2245c7649857246333572eb332b505ad617365ef5faChet Haase /** 225a18a86b43e40e3c15dcca0ae0148d641be9b25feChet Haase * This method tells the object to use appropriate information to extract 226a18a86b43e40e3c15dcca0ae0148d641be9b25feChet Haase * ending values for the animation. For example, a AnimatorSet object will pass 227a18a86b43e40e3c15dcca0ae0148d641be9b25feChet Haase * this call to its child objects to tell them to set up the values. A 228a18a86b43e40e3c15dcca0ae0148d641be9b25feChet Haase * ObjectAnimator object will use the information it has about its target object 229a18a86b43e40e3c15dcca0ae0148d641be9b25feChet Haase * and PropertyValuesHolder objects to get the start values for its properties. 230f76a50ce8fdc6aea22cabc77b2977a1a15a79630Ken Wakasa * A ValueAnimator object will ignore the request since it does not have enough 231a18a86b43e40e3c15dcca0ae0148d641be9b25feChet Haase * information (such as a target object) to gather these values. 23217fb4b0d1cfbad1f026fec704c86640f070b4c2fChet Haase */ 233a18a86b43e40e3c15dcca0ae0148d641be9b25feChet Haase public void setupEndValues() { 23417fb4b0d1cfbad1f026fec704c86640f070b4c2fChet Haase } 23517fb4b0d1cfbad1f026fec704c86640f070b4c2fChet Haase 23617fb4b0d1cfbad1f026fec704c86640f070b4c2fChet Haase /** 237a18a86b43e40e3c15dcca0ae0148d641be9b25feChet Haase * Sets the target object whose property will be animated by this animation. Not all subclasses 238a18a86b43e40e3c15dcca0ae0148d641be9b25feChet Haase * operate on target objects (for example, {@link ValueAnimator}, but this method 239a18a86b43e40e3c15dcca0ae0148d641be9b25feChet Haase * is on the superclass for the convenience of dealing generically with those subclasses 240a18a86b43e40e3c15dcca0ae0148d641be9b25feChet Haase * that do handle targets. 24117fb4b0d1cfbad1f026fec704c86640f070b4c2fChet Haase * 242a18a86b43e40e3c15dcca0ae0148d641be9b25feChet Haase * @param target The object being animated 24317fb4b0d1cfbad1f026fec704c86640f070b4c2fChet Haase */ 244a18a86b43e40e3c15dcca0ae0148d641be9b25feChet Haase public void setTarget(Object target) { 24517fb4b0d1cfbad1f026fec704c86640f070b4c2fChet Haase } 24617fb4b0d1cfbad1f026fec704c86640f070b4c2fChet Haase 24717fb4b0d1cfbad1f026fec704c86640f070b4c2fChet Haase /** 248a18a86b43e40e3c15dcca0ae0148d641be9b25feChet Haase * <p>An animation listener receives notifications from an animation. 249a18a86b43e40e3c15dcca0ae0148d641be9b25feChet Haase * Notifications indicate animation related events, such as the end or the 250a18a86b43e40e3c15dcca0ae0148d641be9b25feChet Haase * repetition of the animation.</p> 25117fb4b0d1cfbad1f026fec704c86640f070b4c2fChet Haase */ 252a18a86b43e40e3c15dcca0ae0148d641be9b25feChet Haase public static interface AnimatorListener { 253a18a86b43e40e3c15dcca0ae0148d641be9b25feChet Haase /** 254a18a86b43e40e3c15dcca0ae0148d641be9b25feChet Haase * <p>Notifies the start of the animation.</p> 255a18a86b43e40e3c15dcca0ae0148d641be9b25feChet Haase * 256a18a86b43e40e3c15dcca0ae0148d641be9b25feChet Haase * @param animation The started animation. 257a18a86b43e40e3c15dcca0ae0148d641be9b25feChet Haase */ 258a18a86b43e40e3c15dcca0ae0148d641be9b25feChet Haase void onAnimationStart(Animator animation); 25917fb4b0d1cfbad1f026fec704c86640f070b4c2fChet Haase 260a18a86b43e40e3c15dcca0ae0148d641be9b25feChet Haase /** 261a18a86b43e40e3c15dcca0ae0148d641be9b25feChet Haase * <p>Notifies the end of the animation. This callback is not invoked 262a18a86b43e40e3c15dcca0ae0148d641be9b25feChet Haase * for animations with repeat count set to INFINITE.</p> 263a18a86b43e40e3c15dcca0ae0148d641be9b25feChet Haase * 264a18a86b43e40e3c15dcca0ae0148d641be9b25feChet Haase * @param animation The animation which reached its end. 265a18a86b43e40e3c15dcca0ae0148d641be9b25feChet Haase */ 266a18a86b43e40e3c15dcca0ae0148d641be9b25feChet Haase void onAnimationEnd(Animator animation); 26717fb4b0d1cfbad1f026fec704c86640f070b4c2fChet Haase 268a18a86b43e40e3c15dcca0ae0148d641be9b25feChet Haase /** 269a18a86b43e40e3c15dcca0ae0148d641be9b25feChet Haase * <p>Notifies the cancellation of the animation. This callback is not invoked 270a18a86b43e40e3c15dcca0ae0148d641be9b25feChet Haase * for animations with repeat count set to INFINITE.</p> 271a18a86b43e40e3c15dcca0ae0148d641be9b25feChet Haase * 272a18a86b43e40e3c15dcca0ae0148d641be9b25feChet Haase * @param animation The animation which was canceled. 273a18a86b43e40e3c15dcca0ae0148d641be9b25feChet Haase */ 274a18a86b43e40e3c15dcca0ae0148d641be9b25feChet Haase void onAnimationCancel(Animator animation); 27549afa5bc100e5d4c069fea980dd6b09501f56397Chet Haase 27617fb4b0d1cfbad1f026fec704c86640f070b4c2fChet Haase /** 277a18a86b43e40e3c15dcca0ae0148d641be9b25feChet Haase * <p>Notifies the repetition of the animation.</p> 27817fb4b0d1cfbad1f026fec704c86640f070b4c2fChet Haase * 27917fb4b0d1cfbad1f026fec704c86640f070b4c2fChet Haase * @param animation The animation which was repeated. 28017fb4b0d1cfbad1f026fec704c86640f070b4c2fChet Haase */ 281a18a86b43e40e3c15dcca0ae0148d641be9b25feChet Haase void onAnimationRepeat(Animator animation); 28217fb4b0d1cfbad1f026fec704c86640f070b4c2fChet Haase } 283a18a86b43e40e3c15dcca0ae0148d641be9b25feChet Haase} 284