Animator.java revision 291161ac3815fb853fd6af21055d60f57a869608
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 /** 338aa1ffb0ed292891030992c65df4e5dc8bd37524Chet Haase * The set of listeners to be sent pause/resume events through the life 348aa1ffb0ed292891030992c65df4e5dc8bd37524Chet Haase * of an animation. 358aa1ffb0ed292891030992c65df4e5dc8bd37524Chet Haase */ 368aa1ffb0ed292891030992c65df4e5dc8bd37524Chet Haase ArrayList<AnimatorPauseListener> mPauseListeners = null; 378aa1ffb0ed292891030992c65df4e5dc8bd37524Chet Haase 388aa1ffb0ed292891030992c65df4e5dc8bd37524Chet Haase /** 398aa1ffb0ed292891030992c65df4e5dc8bd37524Chet Haase * Whether this animator is currently in a paused state. 408aa1ffb0ed292891030992c65df4e5dc8bd37524Chet Haase */ 418aa1ffb0ed292891030992c65df4e5dc8bd37524Chet Haase boolean mPaused = false; 428aa1ffb0ed292891030992c65df4e5dc8bd37524Chet Haase 438aa1ffb0ed292891030992c65df4e5dc8bd37524Chet Haase /** 44a18a86b43e40e3c15dcca0ae0148d641be9b25feChet Haase * Starts this animation. If the animation has a nonzero startDelay, the animation will start 45b8f574a165bf6ec5b316734b367ac274ded4809bChet Haase * running after that delay elapses. A non-delayed animation will have its initial 46b8f574a165bf6ec5b316734b367ac274ded4809bChet Haase * value(s) set immediately, followed by calls to 47b8f574a165bf6ec5b316734b367ac274ded4809bChet Haase * {@link AnimatorListener#onAnimationStart(Animator)} for any listeners of this animator. 48e2ab7ccd385cdb6517955c719e1d2b49771bedb6Chet Haase * 49e2ab7ccd385cdb6517955c719e1d2b49771bedb6Chet Haase * <p>The animation started by calling this method will be run on the thread that called 50e2ab7ccd385cdb6517955c719e1d2b49771bedb6Chet Haase * this method. This thread should have a Looper on it (a runtime exception will be thrown if 51e2ab7ccd385cdb6517955c719e1d2b49771bedb6Chet Haase * this is not the case). Also, if the animation will animate 52e2ab7ccd385cdb6517955c719e1d2b49771bedb6Chet Haase * properties of objects in the view hierarchy, then the calling thread should be the UI 53e2ab7ccd385cdb6517955c719e1d2b49771bedb6Chet Haase * thread for that view hierarchy.</p> 54e2ab7ccd385cdb6517955c719e1d2b49771bedb6Chet Haase * 55d51d368f2d512ab657b8ae45780c82c0dbea94c3Chet Haase */ 56a18a86b43e40e3c15dcca0ae0148d641be9b25feChet Haase public void start() { 575d7b50b800b9898f5ca0b2b4d8b73ed6a4ee1749Chet Haase } 585d7b50b800b9898f5ca0b2b4d8b73ed6a4ee1749Chet Haase 595d7b50b800b9898f5ca0b2b4d8b73ed6a4ee1749Chet Haase /** 60a18a86b43e40e3c15dcca0ae0148d641be9b25feChet Haase * Cancels the animation. Unlike {@link #end()}, <code>cancel()</code> causes the animation to 61e2ab7ccd385cdb6517955c719e1d2b49771bedb6Chet Haase * stop in its tracks, sending an 62e2ab7ccd385cdb6517955c719e1d2b49771bedb6Chet Haase * {@link android.animation.Animator.AnimatorListener#onAnimationCancel(Animator)} to 63e2ab7ccd385cdb6517955c719e1d2b49771bedb6Chet Haase * its listeners, followed by an 64e2ab7ccd385cdb6517955c719e1d2b49771bedb6Chet Haase * {@link android.animation.Animator.AnimatorListener#onAnimationEnd(Animator)} message. 65e2ab7ccd385cdb6517955c719e1d2b49771bedb6Chet Haase * 66e2ab7ccd385cdb6517955c719e1d2b49771bedb6Chet Haase * <p>This method must be called on the thread that is running the animation.</p> 675d7b50b800b9898f5ca0b2b4d8b73ed6a4ee1749Chet Haase */ 68a18a86b43e40e3c15dcca0ae0148d641be9b25feChet Haase public void cancel() { 69fe591563f8529305bd52e1f0640e83b9a93d562fChet Haase } 70fe591563f8529305bd52e1f0640e83b9a93d562fChet Haase 71fe591563f8529305bd52e1f0640e83b9a93d562fChet Haase /** 72a18a86b43e40e3c15dcca0ae0148d641be9b25feChet Haase * Ends the animation. This causes the animation to assign the end value of the property being 73e2ab7ccd385cdb6517955c719e1d2b49771bedb6Chet Haase * animated, then calling the 74e2ab7ccd385cdb6517955c719e1d2b49771bedb6Chet Haase * {@link android.animation.Animator.AnimatorListener#onAnimationEnd(Animator)} method on 75a18a86b43e40e3c15dcca0ae0148d641be9b25feChet Haase * its listeners. 76e2ab7ccd385cdb6517955c719e1d2b49771bedb6Chet Haase * 77e2ab7ccd385cdb6517955c719e1d2b49771bedb6Chet Haase * <p>This method must be called on the thread that is running the animation.</p> 7817fb4b0d1cfbad1f026fec704c86640f070b4c2fChet Haase */ 79a18a86b43e40e3c15dcca0ae0148d641be9b25feChet Haase public void end() { 8017fb4b0d1cfbad1f026fec704c86640f070b4c2fChet Haase } 8117fb4b0d1cfbad1f026fec704c86640f070b4c2fChet Haase 8217fb4b0d1cfbad1f026fec704c86640f070b4c2fChet Haase /** 838aa1ffb0ed292891030992c65df4e5dc8bd37524Chet Haase * Pauses a running animation. This method should only be called on the same thread on 848aa1ffb0ed292891030992c65df4e5dc8bd37524Chet Haase * which the animation was started. If the animation has not yet been {@link 858aa1ffb0ed292891030992c65df4e5dc8bd37524Chet Haase * #isStarted() started} or has since ended, then the call is ignored. Paused 868aa1ffb0ed292891030992c65df4e5dc8bd37524Chet Haase * animations can be resumed by calling {@link #resume()}. 878aa1ffb0ed292891030992c65df4e5dc8bd37524Chet Haase * 888aa1ffb0ed292891030992c65df4e5dc8bd37524Chet Haase * @see #resume() 898aa1ffb0ed292891030992c65df4e5dc8bd37524Chet Haase * @see #isPaused() 908aa1ffb0ed292891030992c65df4e5dc8bd37524Chet Haase * @see AnimatorPauseListener 918aa1ffb0ed292891030992c65df4e5dc8bd37524Chet Haase */ 928aa1ffb0ed292891030992c65df4e5dc8bd37524Chet Haase public void pause() { 938aa1ffb0ed292891030992c65df4e5dc8bd37524Chet Haase if (isStarted() && !mPaused) { 948aa1ffb0ed292891030992c65df4e5dc8bd37524Chet Haase mPaused = true; 958aa1ffb0ed292891030992c65df4e5dc8bd37524Chet Haase if (mPauseListeners != null) { 968aa1ffb0ed292891030992c65df4e5dc8bd37524Chet Haase ArrayList<AnimatorPauseListener> tmpListeners = 978aa1ffb0ed292891030992c65df4e5dc8bd37524Chet Haase (ArrayList<AnimatorPauseListener>) mPauseListeners.clone(); 988aa1ffb0ed292891030992c65df4e5dc8bd37524Chet Haase int numListeners = tmpListeners.size(); 998aa1ffb0ed292891030992c65df4e5dc8bd37524Chet Haase for (int i = 0; i < numListeners; ++i) { 1008aa1ffb0ed292891030992c65df4e5dc8bd37524Chet Haase tmpListeners.get(i).onAnimationPause(this); 1018aa1ffb0ed292891030992c65df4e5dc8bd37524Chet Haase } 1028aa1ffb0ed292891030992c65df4e5dc8bd37524Chet Haase } 1038aa1ffb0ed292891030992c65df4e5dc8bd37524Chet Haase } 1048aa1ffb0ed292891030992c65df4e5dc8bd37524Chet Haase } 1058aa1ffb0ed292891030992c65df4e5dc8bd37524Chet Haase 1068aa1ffb0ed292891030992c65df4e5dc8bd37524Chet Haase /** 1078aa1ffb0ed292891030992c65df4e5dc8bd37524Chet Haase * Resumes a paused animation, causing the animator to pick up where it left off 1088aa1ffb0ed292891030992c65df4e5dc8bd37524Chet Haase * when it was paused. This method should only be called on the same thread on 1098aa1ffb0ed292891030992c65df4e5dc8bd37524Chet Haase * which the animation was started. Calls to resume() on an animator that is 1108aa1ffb0ed292891030992c65df4e5dc8bd37524Chet Haase * not currently paused will be ignored. 1118aa1ffb0ed292891030992c65df4e5dc8bd37524Chet Haase * 1128aa1ffb0ed292891030992c65df4e5dc8bd37524Chet Haase * @see #pause() 1138aa1ffb0ed292891030992c65df4e5dc8bd37524Chet Haase * @see #isPaused() 1148aa1ffb0ed292891030992c65df4e5dc8bd37524Chet Haase * @see AnimatorPauseListener 1158aa1ffb0ed292891030992c65df4e5dc8bd37524Chet Haase */ 1168aa1ffb0ed292891030992c65df4e5dc8bd37524Chet Haase public void resume() { 1178aa1ffb0ed292891030992c65df4e5dc8bd37524Chet Haase if (mPaused) { 1188aa1ffb0ed292891030992c65df4e5dc8bd37524Chet Haase mPaused = false; 1198aa1ffb0ed292891030992c65df4e5dc8bd37524Chet Haase if (mPauseListeners != null) { 1208aa1ffb0ed292891030992c65df4e5dc8bd37524Chet Haase ArrayList<AnimatorPauseListener> tmpListeners = 1218aa1ffb0ed292891030992c65df4e5dc8bd37524Chet Haase (ArrayList<AnimatorPauseListener>) mPauseListeners.clone(); 1228aa1ffb0ed292891030992c65df4e5dc8bd37524Chet Haase int numListeners = tmpListeners.size(); 1238aa1ffb0ed292891030992c65df4e5dc8bd37524Chet Haase for (int i = 0; i < numListeners; ++i) { 1248aa1ffb0ed292891030992c65df4e5dc8bd37524Chet Haase tmpListeners.get(i).onAnimationResume(this); 1258aa1ffb0ed292891030992c65df4e5dc8bd37524Chet Haase } 1268aa1ffb0ed292891030992c65df4e5dc8bd37524Chet Haase } 1278aa1ffb0ed292891030992c65df4e5dc8bd37524Chet Haase } 1288aa1ffb0ed292891030992c65df4e5dc8bd37524Chet Haase } 1298aa1ffb0ed292891030992c65df4e5dc8bd37524Chet Haase 1308aa1ffb0ed292891030992c65df4e5dc8bd37524Chet Haase /** 1318aa1ffb0ed292891030992c65df4e5dc8bd37524Chet Haase * Returns whether this animator is currently in a paused state. 1328aa1ffb0ed292891030992c65df4e5dc8bd37524Chet Haase * 1338aa1ffb0ed292891030992c65df4e5dc8bd37524Chet Haase * @return True if the animator is currently paused, false otherwise. 1348aa1ffb0ed292891030992c65df4e5dc8bd37524Chet Haase * 1358aa1ffb0ed292891030992c65df4e5dc8bd37524Chet Haase * @see #pause() 1368aa1ffb0ed292891030992c65df4e5dc8bd37524Chet Haase * @see #resume() 1378aa1ffb0ed292891030992c65df4e5dc8bd37524Chet Haase */ 1388aa1ffb0ed292891030992c65df4e5dc8bd37524Chet Haase public boolean isPaused() { 1398aa1ffb0ed292891030992c65df4e5dc8bd37524Chet Haase return mPaused; 1408aa1ffb0ed292891030992c65df4e5dc8bd37524Chet Haase } 1418aa1ffb0ed292891030992c65df4e5dc8bd37524Chet Haase 1428aa1ffb0ed292891030992c65df4e5dc8bd37524Chet Haase /** 143e8cee38c6a8dd54cc222cbbd8655ae32a66a8e73Chet Haase * The amount of time, in milliseconds, to delay processing the animation 144e8cee38c6a8dd54cc222cbbd8655ae32a66a8e73Chet Haase * after {@link #start()} is called. 145e8cee38c6a8dd54cc222cbbd8655ae32a66a8e73Chet Haase * 146e8cee38c6a8dd54cc222cbbd8655ae32a66a8e73Chet Haase * @return the number of milliseconds to delay running the animation 147e8cee38c6a8dd54cc222cbbd8655ae32a66a8e73Chet Haase */ 148e8cee38c6a8dd54cc222cbbd8655ae32a66a8e73Chet Haase public abstract long getStartDelay(); 149e8cee38c6a8dd54cc222cbbd8655ae32a66a8e73Chet Haase 150e8cee38c6a8dd54cc222cbbd8655ae32a66a8e73Chet Haase /** 151e8cee38c6a8dd54cc222cbbd8655ae32a66a8e73Chet Haase * The amount of time, in milliseconds, to delay processing the animation 152e8cee38c6a8dd54cc222cbbd8655ae32a66a8e73Chet Haase * after {@link #start()} is called. 153e8cee38c6a8dd54cc222cbbd8655ae32a66a8e73Chet Haase 154e8cee38c6a8dd54cc222cbbd8655ae32a66a8e73Chet Haase * @param startDelay The amount of the delay, in milliseconds 155e8cee38c6a8dd54cc222cbbd8655ae32a66a8e73Chet Haase */ 156e8cee38c6a8dd54cc222cbbd8655ae32a66a8e73Chet Haase public abstract void setStartDelay(long startDelay); 157e8cee38c6a8dd54cc222cbbd8655ae32a66a8e73Chet Haase 158e8cee38c6a8dd54cc222cbbd8655ae32a66a8e73Chet Haase /** 159e8cee38c6a8dd54cc222cbbd8655ae32a66a8e73Chet Haase * Sets the duration of the animation. 160e8cee38c6a8dd54cc222cbbd8655ae32a66a8e73Chet Haase * 161e8cee38c6a8dd54cc222cbbd8655ae32a66a8e73Chet Haase * @param duration The length of the animation, in milliseconds. 162e8cee38c6a8dd54cc222cbbd8655ae32a66a8e73Chet Haase */ 163e8cee38c6a8dd54cc222cbbd8655ae32a66a8e73Chet Haase public abstract Animator setDuration(long duration); 164e8cee38c6a8dd54cc222cbbd8655ae32a66a8e73Chet Haase 165e8cee38c6a8dd54cc222cbbd8655ae32a66a8e73Chet Haase /** 166e8cee38c6a8dd54cc222cbbd8655ae32a66a8e73Chet Haase * Gets the duration of the animation. 167e8cee38c6a8dd54cc222cbbd8655ae32a66a8e73Chet Haase * 168e8cee38c6a8dd54cc222cbbd8655ae32a66a8e73Chet Haase * @return The length of the animation, in milliseconds. 169e8cee38c6a8dd54cc222cbbd8655ae32a66a8e73Chet Haase */ 170e8cee38c6a8dd54cc222cbbd8655ae32a66a8e73Chet Haase public abstract long getDuration(); 171e8cee38c6a8dd54cc222cbbd8655ae32a66a8e73Chet Haase 172e8cee38c6a8dd54cc222cbbd8655ae32a66a8e73Chet Haase /** 173e8cee38c6a8dd54cc222cbbd8655ae32a66a8e73Chet Haase * The time interpolator used in calculating the elapsed fraction of the 174e8cee38c6a8dd54cc222cbbd8655ae32a66a8e73Chet Haase * animation. The interpolator determines whether the animation runs with 175e8cee38c6a8dd54cc222cbbd8655ae32a66a8e73Chet Haase * linear or non-linear motion, such as acceleration and deceleration. The 176e8cee38c6a8dd54cc222cbbd8655ae32a66a8e73Chet Haase * default value is {@link android.view.animation.AccelerateDecelerateInterpolator}. 177e8cee38c6a8dd54cc222cbbd8655ae32a66a8e73Chet Haase * 178e8cee38c6a8dd54cc222cbbd8655ae32a66a8e73Chet Haase * @param value the interpolator to be used by this animation 179e8cee38c6a8dd54cc222cbbd8655ae32a66a8e73Chet Haase */ 180e8cee38c6a8dd54cc222cbbd8655ae32a66a8e73Chet Haase public abstract void setInterpolator(TimeInterpolator value); 181e8cee38c6a8dd54cc222cbbd8655ae32a66a8e73Chet Haase 182e8cee38c6a8dd54cc222cbbd8655ae32a66a8e73Chet Haase /** 183e8cee38c6a8dd54cc222cbbd8655ae32a66a8e73Chet Haase * Returns the timing interpolator that this animation uses. 184e8cee38c6a8dd54cc222cbbd8655ae32a66a8e73Chet Haase * 185e8cee38c6a8dd54cc222cbbd8655ae32a66a8e73Chet Haase * @return The timing interpolator for this animation. 186e8cee38c6a8dd54cc222cbbd8655ae32a66a8e73Chet Haase */ 187e8cee38c6a8dd54cc222cbbd8655ae32a66a8e73Chet Haase public TimeInterpolator getInterpolator() { 188e8cee38c6a8dd54cc222cbbd8655ae32a66a8e73Chet Haase return null; 189e8cee38c6a8dd54cc222cbbd8655ae32a66a8e73Chet Haase } 190e8cee38c6a8dd54cc222cbbd8655ae32a66a8e73Chet Haase 191e8cee38c6a8dd54cc222cbbd8655ae32a66a8e73Chet Haase /** 1928b699792b677bd4dd8442b32641ac09d48fdd79cChet Haase * Returns whether this Animator is currently running (having been started and gone past any 1938b699792b677bd4dd8442b32641ac09d48fdd79cChet Haase * initial startDelay period and not yet ended). 1948b699792b677bd4dd8442b32641ac09d48fdd79cChet Haase * 195a18a86b43e40e3c15dcca0ae0148d641be9b25feChet Haase * @return Whether the Animator is running. 19617fb4b0d1cfbad1f026fec704c86640f070b4c2fChet Haase */ 197a18a86b43e40e3c15dcca0ae0148d641be9b25feChet Haase public abstract boolean isRunning(); 19817fb4b0d1cfbad1f026fec704c86640f070b4c2fChet Haase 19917fb4b0d1cfbad1f026fec704c86640f070b4c2fChet Haase /** 2008b699792b677bd4dd8442b32641ac09d48fdd79cChet Haase * Returns whether this Animator has been started and not yet ended. This state is a superset 2018b699792b677bd4dd8442b32641ac09d48fdd79cChet Haase * of the state of {@link #isRunning()}, because an Animator with a nonzero 2028b699792b677bd4dd8442b32641ac09d48fdd79cChet Haase * {@link #getStartDelay() startDelay} will return true for {@link #isStarted()} during the 2038b699792b677bd4dd8442b32641ac09d48fdd79cChet Haase * delay phase, whereas {@link #isRunning()} will return true only after the delay phase 2048b699792b677bd4dd8442b32641ac09d48fdd79cChet Haase * is complete. 2058b699792b677bd4dd8442b32641ac09d48fdd79cChet Haase * 2068b699792b677bd4dd8442b32641ac09d48fdd79cChet Haase * @return Whether the Animator has been started and not yet ended. 2078b699792b677bd4dd8442b32641ac09d48fdd79cChet Haase */ 2088b699792b677bd4dd8442b32641ac09d48fdd79cChet Haase public boolean isStarted() { 2098b699792b677bd4dd8442b32641ac09d48fdd79cChet Haase // Default method returns value for isRunning(). Subclasses should override to return a 2108b699792b677bd4dd8442b32641ac09d48fdd79cChet Haase // real value. 2118b699792b677bd4dd8442b32641ac09d48fdd79cChet Haase return isRunning(); 2128b699792b677bd4dd8442b32641ac09d48fdd79cChet Haase } 2138b699792b677bd4dd8442b32641ac09d48fdd79cChet Haase 2148b699792b677bd4dd8442b32641ac09d48fdd79cChet Haase /** 215a18a86b43e40e3c15dcca0ae0148d641be9b25feChet Haase * Adds a listener to the set of listeners that are sent events through the life of an 216a18a86b43e40e3c15dcca0ae0148d641be9b25feChet Haase * animation, such as start, repeat, and end. 21717fb4b0d1cfbad1f026fec704c86640f070b4c2fChet Haase * 21817fb4b0d1cfbad1f026fec704c86640f070b4c2fChet Haase * @param listener the listener to be added to the current set of listeners for this animation. 21917fb4b0d1cfbad1f026fec704c86640f070b4c2fChet Haase */ 220a18a86b43e40e3c15dcca0ae0148d641be9b25feChet Haase public void addListener(AnimatorListener listener) { 221a18a86b43e40e3c15dcca0ae0148d641be9b25feChet Haase if (mListeners == null) { 222a18a86b43e40e3c15dcca0ae0148d641be9b25feChet Haase mListeners = new ArrayList<AnimatorListener>(); 22317fb4b0d1cfbad1f026fec704c86640f070b4c2fChet Haase } 224a18a86b43e40e3c15dcca0ae0148d641be9b25feChet Haase mListeners.add(listener); 22517fb4b0d1cfbad1f026fec704c86640f070b4c2fChet Haase } 22617fb4b0d1cfbad1f026fec704c86640f070b4c2fChet Haase 22717fb4b0d1cfbad1f026fec704c86640f070b4c2fChet Haase /** 228a18a86b43e40e3c15dcca0ae0148d641be9b25feChet Haase * Removes a listener from the set listening to this animation. 22917fb4b0d1cfbad1f026fec704c86640f070b4c2fChet Haase * 230a18a86b43e40e3c15dcca0ae0148d641be9b25feChet Haase * @param listener the listener to be removed from the current set of listeners for this 231a18a86b43e40e3c15dcca0ae0148d641be9b25feChet Haase * animation. 23217fb4b0d1cfbad1f026fec704c86640f070b4c2fChet Haase */ 233a18a86b43e40e3c15dcca0ae0148d641be9b25feChet Haase public void removeListener(AnimatorListener listener) { 234a18a86b43e40e3c15dcca0ae0148d641be9b25feChet Haase if (mListeners == null) { 23517fb4b0d1cfbad1f026fec704c86640f070b4c2fChet Haase return; 23617fb4b0d1cfbad1f026fec704c86640f070b4c2fChet Haase } 237a18a86b43e40e3c15dcca0ae0148d641be9b25feChet Haase mListeners.remove(listener); 238a18a86b43e40e3c15dcca0ae0148d641be9b25feChet Haase if (mListeners.size() == 0) { 239a18a86b43e40e3c15dcca0ae0148d641be9b25feChet Haase mListeners = null; 24017fb4b0d1cfbad1f026fec704c86640f070b4c2fChet Haase } 24117fb4b0d1cfbad1f026fec704c86640f070b4c2fChet Haase } 24217fb4b0d1cfbad1f026fec704c86640f070b4c2fChet Haase 24317fb4b0d1cfbad1f026fec704c86640f070b4c2fChet Haase /** 244a18a86b43e40e3c15dcca0ae0148d641be9b25feChet Haase * Gets the set of {@link android.animation.Animator.AnimatorListener} objects that are currently 245a18a86b43e40e3c15dcca0ae0148d641be9b25feChet Haase * listening for events on this <code>Animator</code> object. 24617fb4b0d1cfbad1f026fec704c86640f070b4c2fChet Haase * 247a18a86b43e40e3c15dcca0ae0148d641be9b25feChet Haase * @return ArrayList<AnimatorListener> The set of listeners. 24817fb4b0d1cfbad1f026fec704c86640f070b4c2fChet Haase */ 249a18a86b43e40e3c15dcca0ae0148d641be9b25feChet Haase public ArrayList<AnimatorListener> getListeners() { 250a18a86b43e40e3c15dcca0ae0148d641be9b25feChet Haase return mListeners; 25117fb4b0d1cfbad1f026fec704c86640f070b4c2fChet Haase } 25217fb4b0d1cfbad1f026fec704c86640f070b4c2fChet Haase 25317fb4b0d1cfbad1f026fec704c86640f070b4c2fChet Haase /** 2548aa1ffb0ed292891030992c65df4e5dc8bd37524Chet Haase * Adds a pause listener to this animator. 2558aa1ffb0ed292891030992c65df4e5dc8bd37524Chet Haase * 2568aa1ffb0ed292891030992c65df4e5dc8bd37524Chet Haase * @param listener the listener to be added to the current set of pause listeners 2578aa1ffb0ed292891030992c65df4e5dc8bd37524Chet Haase * for this animation. 2588aa1ffb0ed292891030992c65df4e5dc8bd37524Chet Haase */ 2598aa1ffb0ed292891030992c65df4e5dc8bd37524Chet Haase public void addPauseListener(AnimatorPauseListener listener) { 2608aa1ffb0ed292891030992c65df4e5dc8bd37524Chet Haase if (mPauseListeners == null) { 2618aa1ffb0ed292891030992c65df4e5dc8bd37524Chet Haase mPauseListeners = new ArrayList<AnimatorPauseListener>(); 2628aa1ffb0ed292891030992c65df4e5dc8bd37524Chet Haase } 2638aa1ffb0ed292891030992c65df4e5dc8bd37524Chet Haase mPauseListeners.add(listener); 2648aa1ffb0ed292891030992c65df4e5dc8bd37524Chet Haase } 2658aa1ffb0ed292891030992c65df4e5dc8bd37524Chet Haase 2668aa1ffb0ed292891030992c65df4e5dc8bd37524Chet Haase /** 2678aa1ffb0ed292891030992c65df4e5dc8bd37524Chet Haase * Removes a pause listener from the set listening to this animation. 2688aa1ffb0ed292891030992c65df4e5dc8bd37524Chet Haase * 2698aa1ffb0ed292891030992c65df4e5dc8bd37524Chet Haase * @param listener the listener to be removed from the current set of pause 2708aa1ffb0ed292891030992c65df4e5dc8bd37524Chet Haase * listeners for this animation. 2718aa1ffb0ed292891030992c65df4e5dc8bd37524Chet Haase */ 2728aa1ffb0ed292891030992c65df4e5dc8bd37524Chet Haase public void removePauseListener(AnimatorPauseListener listener) { 2738aa1ffb0ed292891030992c65df4e5dc8bd37524Chet Haase if (mPauseListeners == null) { 2748aa1ffb0ed292891030992c65df4e5dc8bd37524Chet Haase return; 2758aa1ffb0ed292891030992c65df4e5dc8bd37524Chet Haase } 2768aa1ffb0ed292891030992c65df4e5dc8bd37524Chet Haase mPauseListeners.remove(listener); 2778aa1ffb0ed292891030992c65df4e5dc8bd37524Chet Haase if (mPauseListeners.size() == 0) { 2788aa1ffb0ed292891030992c65df4e5dc8bd37524Chet Haase mPauseListeners = null; 2798aa1ffb0ed292891030992c65df4e5dc8bd37524Chet Haase } 2808aa1ffb0ed292891030992c65df4e5dc8bd37524Chet Haase } 2818aa1ffb0ed292891030992c65df4e5dc8bd37524Chet Haase 2828aa1ffb0ed292891030992c65df4e5dc8bd37524Chet Haase /** 283d82c8ac4db7091d2e976af4c89a1734465d20cd2Chet Haase * Removes all {@link #addListener(android.animation.Animator.AnimatorListener) listeners} 284d82c8ac4db7091d2e976af4c89a1734465d20cd2Chet Haase * and {@link #addPauseListener(android.animation.Animator.AnimatorPauseListener) 285d82c8ac4db7091d2e976af4c89a1734465d20cd2Chet Haase * pauseListeners} from this object. 286602e4d3824bf8b9cb9f817375d195b969712176aChet Haase */ 287a18a86b43e40e3c15dcca0ae0148d641be9b25feChet Haase public void removeAllListeners() { 28817fb4b0d1cfbad1f026fec704c86640f070b4c2fChet Haase if (mListeners != null) { 289a18a86b43e40e3c15dcca0ae0148d641be9b25feChet Haase mListeners.clear(); 290a18a86b43e40e3c15dcca0ae0148d641be9b25feChet Haase mListeners = null; 29117fb4b0d1cfbad1f026fec704c86640f070b4c2fChet Haase } 2928aa1ffb0ed292891030992c65df4e5dc8bd37524Chet Haase if (mPauseListeners != null) { 2938aa1ffb0ed292891030992c65df4e5dc8bd37524Chet Haase mPauseListeners.clear(); 2948aa1ffb0ed292891030992c65df4e5dc8bd37524Chet Haase mPauseListeners = null; 2958aa1ffb0ed292891030992c65df4e5dc8bd37524Chet Haase } 29617fb4b0d1cfbad1f026fec704c86640f070b4c2fChet Haase } 29717fb4b0d1cfbad1f026fec704c86640f070b4c2fChet Haase 2985c7649857246333572eb332b505ad617365ef5faChet Haase @Override 299a18a86b43e40e3c15dcca0ae0148d641be9b25feChet Haase public Animator clone() { 300a18a86b43e40e3c15dcca0ae0148d641be9b25feChet Haase try { 301a18a86b43e40e3c15dcca0ae0148d641be9b25feChet Haase final Animator anim = (Animator) super.clone(); 302a18a86b43e40e3c15dcca0ae0148d641be9b25feChet Haase if (mListeners != null) { 303a18a86b43e40e3c15dcca0ae0148d641be9b25feChet Haase ArrayList<AnimatorListener> oldListeners = mListeners; 304a18a86b43e40e3c15dcca0ae0148d641be9b25feChet Haase anim.mListeners = new ArrayList<AnimatorListener>(); 305a18a86b43e40e3c15dcca0ae0148d641be9b25feChet Haase int numListeners = oldListeners.size(); 306a18a86b43e40e3c15dcca0ae0148d641be9b25feChet Haase for (int i = 0; i < numListeners; ++i) { 307a18a86b43e40e3c15dcca0ae0148d641be9b25feChet Haase anim.mListeners.add(oldListeners.get(i)); 308a18a86b43e40e3c15dcca0ae0148d641be9b25feChet Haase } 309673e42fafd4088970ec95e1f13c61dc83132c74eChet Haase } 3108aa1ffb0ed292891030992c65df4e5dc8bd37524Chet Haase if (mPauseListeners != null) { 3118aa1ffb0ed292891030992c65df4e5dc8bd37524Chet Haase ArrayList<AnimatorPauseListener> oldListeners = mPauseListeners; 3128aa1ffb0ed292891030992c65df4e5dc8bd37524Chet Haase anim.mPauseListeners = new ArrayList<AnimatorPauseListener>(); 3138aa1ffb0ed292891030992c65df4e5dc8bd37524Chet Haase int numListeners = oldListeners.size(); 3148aa1ffb0ed292891030992c65df4e5dc8bd37524Chet Haase for (int i = 0; i < numListeners; ++i) { 3158aa1ffb0ed292891030992c65df4e5dc8bd37524Chet Haase anim.mPauseListeners.add(oldListeners.get(i)); 3168aa1ffb0ed292891030992c65df4e5dc8bd37524Chet Haase } 3178aa1ffb0ed292891030992c65df4e5dc8bd37524Chet Haase } 318a18a86b43e40e3c15dcca0ae0148d641be9b25feChet Haase return anim; 319a18a86b43e40e3c15dcca0ae0148d641be9b25feChet Haase } catch (CloneNotSupportedException e) { 320a18a86b43e40e3c15dcca0ae0148d641be9b25feChet Haase throw new AssertionError(); 321673e42fafd4088970ec95e1f13c61dc83132c74eChet Haase } 3225c7649857246333572eb332b505ad617365ef5faChet Haase } 3235c7649857246333572eb332b505ad617365ef5faChet Haase 3245c7649857246333572eb332b505ad617365ef5faChet Haase /** 325a18a86b43e40e3c15dcca0ae0148d641be9b25feChet Haase * This method tells the object to use appropriate information to extract 326a18a86b43e40e3c15dcca0ae0148d641be9b25feChet Haase * starting values for the animation. For example, a AnimatorSet object will pass 327a18a86b43e40e3c15dcca0ae0148d641be9b25feChet Haase * this call to its child objects to tell them to set up the values. A 328a18a86b43e40e3c15dcca0ae0148d641be9b25feChet Haase * ObjectAnimator object will use the information it has about its target object 329a18a86b43e40e3c15dcca0ae0148d641be9b25feChet Haase * and PropertyValuesHolder objects to get the start values for its properties. 330f76a50ce8fdc6aea22cabc77b2977a1a15a79630Ken Wakasa * A ValueAnimator object will ignore the request since it does not have enough 331a18a86b43e40e3c15dcca0ae0148d641be9b25feChet Haase * information (such as a target object) to gather these values. 3325c7649857246333572eb332b505ad617365ef5faChet Haase */ 333a18a86b43e40e3c15dcca0ae0148d641be9b25feChet Haase public void setupStartValues() { 3345c7649857246333572eb332b505ad617365ef5faChet Haase } 3355c7649857246333572eb332b505ad617365ef5faChet Haase 3365c7649857246333572eb332b505ad617365ef5faChet Haase /** 337a18a86b43e40e3c15dcca0ae0148d641be9b25feChet Haase * This method tells the object to use appropriate information to extract 338a18a86b43e40e3c15dcca0ae0148d641be9b25feChet Haase * ending values for the animation. For example, a AnimatorSet object will pass 339a18a86b43e40e3c15dcca0ae0148d641be9b25feChet Haase * this call to its child objects to tell them to set up the values. A 340a18a86b43e40e3c15dcca0ae0148d641be9b25feChet Haase * ObjectAnimator object will use the information it has about its target object 341a18a86b43e40e3c15dcca0ae0148d641be9b25feChet Haase * and PropertyValuesHolder objects to get the start values for its properties. 342f76a50ce8fdc6aea22cabc77b2977a1a15a79630Ken Wakasa * A ValueAnimator object will ignore the request since it does not have enough 343a18a86b43e40e3c15dcca0ae0148d641be9b25feChet Haase * information (such as a target object) to gather these values. 34417fb4b0d1cfbad1f026fec704c86640f070b4c2fChet Haase */ 345a18a86b43e40e3c15dcca0ae0148d641be9b25feChet Haase public void setupEndValues() { 34617fb4b0d1cfbad1f026fec704c86640f070b4c2fChet Haase } 34717fb4b0d1cfbad1f026fec704c86640f070b4c2fChet Haase 34817fb4b0d1cfbad1f026fec704c86640f070b4c2fChet Haase /** 349a18a86b43e40e3c15dcca0ae0148d641be9b25feChet Haase * Sets the target object whose property will be animated by this animation. Not all subclasses 350a18a86b43e40e3c15dcca0ae0148d641be9b25feChet Haase * operate on target objects (for example, {@link ValueAnimator}, but this method 351a18a86b43e40e3c15dcca0ae0148d641be9b25feChet Haase * is on the superclass for the convenience of dealing generically with those subclasses 352a18a86b43e40e3c15dcca0ae0148d641be9b25feChet Haase * that do handle targets. 35317fb4b0d1cfbad1f026fec704c86640f070b4c2fChet Haase * 354a18a86b43e40e3c15dcca0ae0148d641be9b25feChet Haase * @param target The object being animated 35517fb4b0d1cfbad1f026fec704c86640f070b4c2fChet Haase */ 356a18a86b43e40e3c15dcca0ae0148d641be9b25feChet Haase public void setTarget(Object target) { 3577bc6a3f023ca3e1dde91fc97b6036dee3ba538a2ztenghui } 3587bc6a3f023ca3e1dde91fc97b6036dee3ba538a2ztenghui 3597bc6a3f023ca3e1dde91fc97b6036dee3ba538a2ztenghui // Hide reverse() and canReverse() for now since reverse() only work for simple 3607bc6a3f023ca3e1dde91fc97b6036dee3ba538a2ztenghui // cases, like we don't support sequential, neither startDelay. 3617bc6a3f023ca3e1dde91fc97b6036dee3ba538a2ztenghui // TODO: make reverse() works for all the Animators. 3627bc6a3f023ca3e1dde91fc97b6036dee3ba538a2ztenghui /** 3637bc6a3f023ca3e1dde91fc97b6036dee3ba538a2ztenghui * @hide 3647bc6a3f023ca3e1dde91fc97b6036dee3ba538a2ztenghui */ 3657bc6a3f023ca3e1dde91fc97b6036dee3ba538a2ztenghui public boolean canReverse() { 3667bc6a3f023ca3e1dde91fc97b6036dee3ba538a2ztenghui return false; 3677bc6a3f023ca3e1dde91fc97b6036dee3ba538a2ztenghui } 3687bc6a3f023ca3e1dde91fc97b6036dee3ba538a2ztenghui 3697bc6a3f023ca3e1dde91fc97b6036dee3ba538a2ztenghui /** 3707bc6a3f023ca3e1dde91fc97b6036dee3ba538a2ztenghui * @hide 3717bc6a3f023ca3e1dde91fc97b6036dee3ba538a2ztenghui */ 3727bc6a3f023ca3e1dde91fc97b6036dee3ba538a2ztenghui public void reverse() { 373291161ac3815fb853fd6af21055d60f57a869608John Reck throw new IllegalStateException("Reverse is not supported"); 37417fb4b0d1cfbad1f026fec704c86640f070b4c2fChet Haase } 37517fb4b0d1cfbad1f026fec704c86640f070b4c2fChet Haase 37617fb4b0d1cfbad1f026fec704c86640f070b4c2fChet Haase /** 377a18a86b43e40e3c15dcca0ae0148d641be9b25feChet Haase * <p>An animation listener receives notifications from an animation. 378a18a86b43e40e3c15dcca0ae0148d641be9b25feChet Haase * Notifications indicate animation related events, such as the end or the 379a18a86b43e40e3c15dcca0ae0148d641be9b25feChet Haase * repetition of the animation.</p> 38017fb4b0d1cfbad1f026fec704c86640f070b4c2fChet Haase */ 381a18a86b43e40e3c15dcca0ae0148d641be9b25feChet Haase public static interface AnimatorListener { 382a18a86b43e40e3c15dcca0ae0148d641be9b25feChet Haase /** 383a18a86b43e40e3c15dcca0ae0148d641be9b25feChet Haase * <p>Notifies the start of the animation.</p> 384a18a86b43e40e3c15dcca0ae0148d641be9b25feChet Haase * 385a18a86b43e40e3c15dcca0ae0148d641be9b25feChet Haase * @param animation The started animation. 386a18a86b43e40e3c15dcca0ae0148d641be9b25feChet Haase */ 387a18a86b43e40e3c15dcca0ae0148d641be9b25feChet Haase void onAnimationStart(Animator animation); 38817fb4b0d1cfbad1f026fec704c86640f070b4c2fChet Haase 389a18a86b43e40e3c15dcca0ae0148d641be9b25feChet Haase /** 390a18a86b43e40e3c15dcca0ae0148d641be9b25feChet Haase * <p>Notifies the end of the animation. This callback is not invoked 391a18a86b43e40e3c15dcca0ae0148d641be9b25feChet Haase * for animations with repeat count set to INFINITE.</p> 392a18a86b43e40e3c15dcca0ae0148d641be9b25feChet Haase * 393a18a86b43e40e3c15dcca0ae0148d641be9b25feChet Haase * @param animation The animation which reached its end. 394a18a86b43e40e3c15dcca0ae0148d641be9b25feChet Haase */ 395a18a86b43e40e3c15dcca0ae0148d641be9b25feChet Haase void onAnimationEnd(Animator animation); 39617fb4b0d1cfbad1f026fec704c86640f070b4c2fChet Haase 397a18a86b43e40e3c15dcca0ae0148d641be9b25feChet Haase /** 398a18a86b43e40e3c15dcca0ae0148d641be9b25feChet Haase * <p>Notifies the cancellation of the animation. This callback is not invoked 399a18a86b43e40e3c15dcca0ae0148d641be9b25feChet Haase * for animations with repeat count set to INFINITE.</p> 400a18a86b43e40e3c15dcca0ae0148d641be9b25feChet Haase * 401a18a86b43e40e3c15dcca0ae0148d641be9b25feChet Haase * @param animation The animation which was canceled. 402a18a86b43e40e3c15dcca0ae0148d641be9b25feChet Haase */ 403a18a86b43e40e3c15dcca0ae0148d641be9b25feChet Haase void onAnimationCancel(Animator animation); 40449afa5bc100e5d4c069fea980dd6b09501f56397Chet Haase 40517fb4b0d1cfbad1f026fec704c86640f070b4c2fChet Haase /** 406a18a86b43e40e3c15dcca0ae0148d641be9b25feChet Haase * <p>Notifies the repetition of the animation.</p> 40717fb4b0d1cfbad1f026fec704c86640f070b4c2fChet Haase * 40817fb4b0d1cfbad1f026fec704c86640f070b4c2fChet Haase * @param animation The animation which was repeated. 40917fb4b0d1cfbad1f026fec704c86640f070b4c2fChet Haase */ 410a18a86b43e40e3c15dcca0ae0148d641be9b25feChet Haase void onAnimationRepeat(Animator animation); 41117fb4b0d1cfbad1f026fec704c86640f070b4c2fChet Haase } 4128aa1ffb0ed292891030992c65df4e5dc8bd37524Chet Haase 4138aa1ffb0ed292891030992c65df4e5dc8bd37524Chet Haase /** 4148aa1ffb0ed292891030992c65df4e5dc8bd37524Chet Haase * A pause listener receives notifications from an animation when the 4158aa1ffb0ed292891030992c65df4e5dc8bd37524Chet Haase * animation is {@link #pause() paused} or {@link #resume() resumed}. 4168aa1ffb0ed292891030992c65df4e5dc8bd37524Chet Haase * 4178aa1ffb0ed292891030992c65df4e5dc8bd37524Chet Haase * @see #addPauseListener(AnimatorPauseListener) 4188aa1ffb0ed292891030992c65df4e5dc8bd37524Chet Haase */ 4198aa1ffb0ed292891030992c65df4e5dc8bd37524Chet Haase public static interface AnimatorPauseListener { 4208aa1ffb0ed292891030992c65df4e5dc8bd37524Chet Haase /** 4218aa1ffb0ed292891030992c65df4e5dc8bd37524Chet Haase * <p>Notifies that the animation was paused.</p> 4228aa1ffb0ed292891030992c65df4e5dc8bd37524Chet Haase * 4238aa1ffb0ed292891030992c65df4e5dc8bd37524Chet Haase * @param animation The animaton being paused. 4248aa1ffb0ed292891030992c65df4e5dc8bd37524Chet Haase * @see #pause() 4258aa1ffb0ed292891030992c65df4e5dc8bd37524Chet Haase */ 4268aa1ffb0ed292891030992c65df4e5dc8bd37524Chet Haase void onAnimationPause(Animator animation); 4278aa1ffb0ed292891030992c65df4e5dc8bd37524Chet Haase 4288aa1ffb0ed292891030992c65df4e5dc8bd37524Chet Haase /** 4298aa1ffb0ed292891030992c65df4e5dc8bd37524Chet Haase * <p>Notifies that the animation was resumed, after being 4308aa1ffb0ed292891030992c65df4e5dc8bd37524Chet Haase * previously paused.</p> 4318aa1ffb0ed292891030992c65df4e5dc8bd37524Chet Haase * 4328aa1ffb0ed292891030992c65df4e5dc8bd37524Chet Haase * @param animation The animation being resumed. 4338aa1ffb0ed292891030992c65df4e5dc8bd37524Chet Haase * @see #resume() 4348aa1ffb0ed292891030992c65df4e5dc8bd37524Chet Haase */ 4358aa1ffb0ed292891030992c65df4e5dc8bd37524Chet Haase void onAnimationResume(Animator animation); 4368aa1ffb0ed292891030992c65df4e5dc8bd37524Chet Haase } 437c01bd1167a1b08d59557f214ddc48cf24d3b8d0aJohn Reck 438c01bd1167a1b08d59557f214ddc48cf24d3b8d0aJohn Reck /** 439c01bd1167a1b08d59557f214ddc48cf24d3b8d0aJohn Reck * <p>Whether or not the Animator is allowed to run asynchronously off of 440c01bd1167a1b08d59557f214ddc48cf24d3b8d0aJohn Reck * the UI thread. This is a hint that informs the Animator that it is 441c01bd1167a1b08d59557f214ddc48cf24d3b8d0aJohn Reck * OK to run the animation off-thread, however the Animator may decide 442c01bd1167a1b08d59557f214ddc48cf24d3b8d0aJohn Reck * that it must run the animation on the UI thread anyway. 443c01bd1167a1b08d59557f214ddc48cf24d3b8d0aJohn Reck * 444c01bd1167a1b08d59557f214ddc48cf24d3b8d0aJohn Reck * <p>Regardless of whether or not the animation runs asynchronously, all 445c01bd1167a1b08d59557f214ddc48cf24d3b8d0aJohn Reck * listener callbacks will be called on the UI thread.</p> 446c01bd1167a1b08d59557f214ddc48cf24d3b8d0aJohn Reck * 447c01bd1167a1b08d59557f214ddc48cf24d3b8d0aJohn Reck * <p>To be able to use this hint the following must be true:</p> 448c01bd1167a1b08d59557f214ddc48cf24d3b8d0aJohn Reck * <ol> 449c01bd1167a1b08d59557f214ddc48cf24d3b8d0aJohn Reck * <li>The animator is immutable while {@link #isStarted()} is true. Requests 450c01bd1167a1b08d59557f214ddc48cf24d3b8d0aJohn Reck * to change duration, delay, etc... may be ignored.</li> 451c01bd1167a1b08d59557f214ddc48cf24d3b8d0aJohn Reck * <li>Lifecycle callback events may be asynchronous. Events such as 452c01bd1167a1b08d59557f214ddc48cf24d3b8d0aJohn Reck * {@link Animator.AnimatorListener#onAnimationEnd(Animator)} or 453c01bd1167a1b08d59557f214ddc48cf24d3b8d0aJohn Reck * {@link Animator.AnimatorListener#onAnimationRepeat(Animator)} may end up delayed 454c01bd1167a1b08d59557f214ddc48cf24d3b8d0aJohn Reck * as they must be posted back to the UI thread, and any actions performed 455c01bd1167a1b08d59557f214ddc48cf24d3b8d0aJohn Reck * by those callbacks (such as starting new animations) will not happen 456c01bd1167a1b08d59557f214ddc48cf24d3b8d0aJohn Reck * in the same frame.</li> 457c01bd1167a1b08d59557f214ddc48cf24d3b8d0aJohn Reck * <li>State change requests ({@link #cancel()}, {@link #end()}, {@link #reverse()}, etc...) 458c01bd1167a1b08d59557f214ddc48cf24d3b8d0aJohn Reck * may be asynchronous. It is guaranteed that all state changes that are 459c01bd1167a1b08d59557f214ddc48cf24d3b8d0aJohn Reck * performed on the UI thread in the same frame will be applied as a single 460c01bd1167a1b08d59557f214ddc48cf24d3b8d0aJohn Reck * atomic update, however that frame may be the current frame, 461c01bd1167a1b08d59557f214ddc48cf24d3b8d0aJohn Reck * the next frame, or some future frame. This will also impact the observed 462c01bd1167a1b08d59557f214ddc48cf24d3b8d0aJohn Reck * state of the Animator. For example, {@link #isStarted()} may still return true 463c01bd1167a1b08d59557f214ddc48cf24d3b8d0aJohn Reck * after a call to {@link #end()}. Using the lifecycle callbacks is preferred over 464c01bd1167a1b08d59557f214ddc48cf24d3b8d0aJohn Reck * queries to {@link #isStarted()}, {@link #isRunning()}, and {@link #isPaused()} 465c01bd1167a1b08d59557f214ddc48cf24d3b8d0aJohn Reck * for this reason.</li> 466c01bd1167a1b08d59557f214ddc48cf24d3b8d0aJohn Reck * </ol> 467c01bd1167a1b08d59557f214ddc48cf24d3b8d0aJohn Reck * @hide 468c01bd1167a1b08d59557f214ddc48cf24d3b8d0aJohn Reck */ 469c01bd1167a1b08d59557f214ddc48cf24d3b8d0aJohn Reck public void setAllowRunningAsynchronously(boolean mayRunAsync) { 470c01bd1167a1b08d59557f214ddc48cf24d3b8d0aJohn Reck // It is up to subclasses to support this, if they can. 471c01bd1167a1b08d59557f214ddc48cf24d3b8d0aJohn Reck } 472a18a86b43e40e3c15dcca0ae0148d641be9b25feChet Haase} 473