blob: 844063c04e83c121c899d1ce2e31baeeed1f3673 [file] [log] [blame]
Chet Haase17fb4b02010-06-28 17:55:07 -07001/*
2 * Copyright (C) 2010 The Android Open Source Project
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17package android.animation;
18
Yigit Boyard422dc32014-09-25 12:23:35 -070019import android.content.res.ConstantState;
20
Chet Haase17fb4b02010-06-28 17:55:07 -070021import java.util.ArrayList;
22
23/**
Chet Haasea18a86b2010-09-07 13:20:00 -070024 * This is the superclass for classes which provide basic support for animations which can be
25 * started, ended, and have <code>AnimatorListeners</code> added to them.
Chet Haase17fb4b02010-06-28 17:55:07 -070026 */
Chet Haasee8cee38c2013-04-16 17:54:14 -070027public abstract class Animator implements Cloneable {
Chet Haase17fb4b02010-06-28 17:55:07 -070028
29 /**
Doris Liu13099142015-07-10 17:32:41 -070030 * The value used to indicate infinite duration (e.g. when Animators repeat infinitely).
Doris Liu13099142015-07-10 17:32:41 -070031 */
32 public static final long DURATION_INFINITE = -1;
33 /**
Chet Haase17fb4b02010-06-28 17:55:07 -070034 * The set of listeners to be sent events through the life of an animation.
35 */
Chet Haasea18a86b2010-09-07 13:20:00 -070036 ArrayList<AnimatorListener> mListeners = null;
Chet Haase17fb4b02010-06-28 17:55:07 -070037
38 /**
Chet Haase8aa1ffb2013-08-08 14:00:00 -070039 * The set of listeners to be sent pause/resume events through the life
40 * of an animation.
41 */
42 ArrayList<AnimatorPauseListener> mPauseListeners = null;
43
44 /**
45 * Whether this animator is currently in a paused state.
46 */
47 boolean mPaused = false;
48
49 /**
Yigit Boyard422dc32014-09-25 12:23:35 -070050 * A set of flags which identify the type of configuration changes that can affect this
51 * Animator. Used by the Animator cache.
52 */
53 int mChangingConfigurations = 0;
54
55 /**
56 * If this animator is inflated from a constant state, keep a reference to it so that
57 * ConstantState will not be garbage collected until this animator is collected
58 */
59 private AnimatorConstantState mConstantState;
60
61 /**
Chet Haasea18a86b2010-09-07 13:20:00 -070062 * Starts this animation. If the animation has a nonzero startDelay, the animation will start
Chet Haaseb8f574a2011-08-03 14:10:06 -070063 * running after that delay elapses. A non-delayed animation will have its initial
64 * value(s) set immediately, followed by calls to
65 * {@link AnimatorListener#onAnimationStart(Animator)} for any listeners of this animator.
Chet Haasee2ab7cc2010-12-06 16:10:07 -080066 *
67 * <p>The animation started by calling this method will be run on the thread that called
68 * this method. This thread should have a Looper on it (a runtime exception will be thrown if
69 * this is not the case). Also, if the animation will animate
70 * properties of objects in the view hierarchy, then the calling thread should be the UI
71 * thread for that view hierarchy.</p>
72 *
Chet Haase17fb4b02010-06-28 17:55:07 -070073 */
Chet Haasea18a86b2010-09-07 13:20:00 -070074 public void start() {
Chet Haasef54a8d72010-07-22 14:44:59 -070075 }
76
Chet Haased953d082010-08-16 17:44:28 -070077 /**
Chet Haasea18a86b2010-09-07 13:20:00 -070078 * Cancels the animation. Unlike {@link #end()}, <code>cancel()</code> causes the animation to
Chet Haasee2ab7cc2010-12-06 16:10:07 -080079 * stop in its tracks, sending an
80 * {@link android.animation.Animator.AnimatorListener#onAnimationCancel(Animator)} to
81 * its listeners, followed by an
82 * {@link android.animation.Animator.AnimatorListener#onAnimationEnd(Animator)} message.
83 *
84 * <p>This method must be called on the thread that is running the animation.</p>
Chet Haased953d082010-08-16 17:44:28 -070085 */
Chet Haasea18a86b2010-09-07 13:20:00 -070086 public void cancel() {
Chet Haased953d082010-08-16 17:44:28 -070087 }
88
Chet Haase21cd1382010-09-01 17:42:29 -070089 /**
Chet Haasea18a86b2010-09-07 13:20:00 -070090 * Ends the animation. This causes the animation to assign the end value of the property being
Chet Haasee2ab7cc2010-12-06 16:10:07 -080091 * animated, then calling the
92 * {@link android.animation.Animator.AnimatorListener#onAnimationEnd(Animator)} method on
Chet Haasea18a86b2010-09-07 13:20:00 -070093 * its listeners.
Chet Haasee2ab7cc2010-12-06 16:10:07 -080094 *
95 * <p>This method must be called on the thread that is running the animation.</p>
Chet Haase21cd1382010-09-01 17:42:29 -070096 */
Chet Haasea18a86b2010-09-07 13:20:00 -070097 public void end() {
Chet Haase17fb4b02010-06-28 17:55:07 -070098 }
99
100 /**
Chet Haase8aa1ffb2013-08-08 14:00:00 -0700101 * Pauses a running animation. This method should only be called on the same thread on
102 * which the animation was started. If the animation has not yet been {@link
103 * #isStarted() started} or has since ended, then the call is ignored. Paused
104 * animations can be resumed by calling {@link #resume()}.
105 *
106 * @see #resume()
107 * @see #isPaused()
108 * @see AnimatorPauseListener
109 */
110 public void pause() {
111 if (isStarted() && !mPaused) {
112 mPaused = true;
113 if (mPauseListeners != null) {
114 ArrayList<AnimatorPauseListener> tmpListeners =
115 (ArrayList<AnimatorPauseListener>) mPauseListeners.clone();
116 int numListeners = tmpListeners.size();
117 for (int i = 0; i < numListeners; ++i) {
118 tmpListeners.get(i).onAnimationPause(this);
119 }
120 }
121 }
122 }
123
124 /**
125 * Resumes a paused animation, causing the animator to pick up where it left off
126 * when it was paused. This method should only be called on the same thread on
127 * which the animation was started. Calls to resume() on an animator that is
128 * not currently paused will be ignored.
129 *
130 * @see #pause()
131 * @see #isPaused()
132 * @see AnimatorPauseListener
133 */
134 public void resume() {
135 if (mPaused) {
136 mPaused = false;
137 if (mPauseListeners != null) {
138 ArrayList<AnimatorPauseListener> tmpListeners =
139 (ArrayList<AnimatorPauseListener>) mPauseListeners.clone();
140 int numListeners = tmpListeners.size();
141 for (int i = 0; i < numListeners; ++i) {
142 tmpListeners.get(i).onAnimationResume(this);
143 }
144 }
145 }
146 }
147
148 /**
149 * Returns whether this animator is currently in a paused state.
150 *
151 * @return True if the animator is currently paused, false otherwise.
152 *
153 * @see #pause()
154 * @see #resume()
155 */
156 public boolean isPaused() {
157 return mPaused;
158 }
159
160 /**
Chet Haasee8cee38c2013-04-16 17:54:14 -0700161 * The amount of time, in milliseconds, to delay processing the animation
162 * after {@link #start()} is called.
163 *
164 * @return the number of milliseconds to delay running the animation
165 */
166 public abstract long getStartDelay();
167
168 /**
169 * The amount of time, in milliseconds, to delay processing the animation
170 * after {@link #start()} is called.
171
172 * @param startDelay The amount of the delay, in milliseconds
173 */
174 public abstract void setStartDelay(long startDelay);
175
176 /**
177 * Sets the duration of the animation.
178 *
179 * @param duration The length of the animation, in milliseconds.
180 */
181 public abstract Animator setDuration(long duration);
182
183 /**
184 * Gets the duration of the animation.
185 *
186 * @return The length of the animation, in milliseconds.
187 */
188 public abstract long getDuration();
189
190 /**
Doris Liu13099142015-07-10 17:32:41 -0700191 * Gets the total duration of the animation, accounting for animation sequences, start delay,
192 * and repeating. Return {@link #DURATION_INFINITE} if the duration is infinite.
Doris Liu8b7c99c2015-10-01 17:27:20 -0700193 *
194 * @return Total time an animation takes to finish, starting from the time {@link #start()}
195 * is called. {@link #DURATION_INFINITE} will be returned if the animation or any
196 * child animation repeats infinite times.
Doris Liu13099142015-07-10 17:32:41 -0700197 */
198 public long getTotalDuration() {
Doris Liu8b7c99c2015-10-01 17:27:20 -0700199 long duration = getDuration();
200 if (duration == DURATION_INFINITE) {
201 return DURATION_INFINITE;
202 } else {
203 return getStartDelay() + duration;
204 }
Doris Liu13099142015-07-10 17:32:41 -0700205 }
206
207 /**
Chet Haasee8cee38c2013-04-16 17:54:14 -0700208 * The time interpolator used in calculating the elapsed fraction of the
209 * animation. The interpolator determines whether the animation runs with
210 * linear or non-linear motion, such as acceleration and deceleration. The
211 * default value is {@link android.view.animation.AccelerateDecelerateInterpolator}.
212 *
213 * @param value the interpolator to be used by this animation
214 */
215 public abstract void setInterpolator(TimeInterpolator value);
216
217 /**
218 * Returns the timing interpolator that this animation uses.
219 *
220 * @return The timing interpolator for this animation.
221 */
222 public TimeInterpolator getInterpolator() {
223 return null;
224 }
225
226 /**
Chet Haase8b699792011-08-05 15:20:19 -0700227 * Returns whether this Animator is currently running (having been started and gone past any
228 * initial startDelay period and not yet ended).
229 *
Chet Haasea18a86b2010-09-07 13:20:00 -0700230 * @return Whether the Animator is running.
231 */
232 public abstract boolean isRunning();
233
234 /**
Chet Haase4ddd9252015-06-10 09:25:16 +0100235 * Returns whether this Animator has been started and not yet ended. For reusable
236 * Animators (which most Animators are, apart from the one-shot animator produced by
237 * {@link android.view.ViewAnimationUtils#createCircularReveal(
238 * android.view.View, int, int, float, float) createCircularReveal()}),
239 * this state is a superset of {@link #isRunning()}, because an Animator with a
240 * nonzero {@link #getStartDelay() startDelay} will return true for {@link #isStarted()} during
241 * the delay phase, whereas {@link #isRunning()} will return true only after the delay phase
242 * is complete. Non-reusable animators will always return true after they have been
243 * started, because they cannot return to a non-started state.
Chet Haase8b699792011-08-05 15:20:19 -0700244 *
245 * @return Whether the Animator has been started and not yet ended.
246 */
247 public boolean isStarted() {
248 // Default method returns value for isRunning(). Subclasses should override to return a
249 // real value.
250 return isRunning();
251 }
252
253 /**
Chet Haasea18a86b2010-09-07 13:20:00 -0700254 * Adds a listener to the set of listeners that are sent events through the life of an
255 * animation, such as start, repeat, and end.
256 *
257 * @param listener the listener to be added to the current set of listeners for this animation.
258 */
259 public void addListener(AnimatorListener listener) {
260 if (mListeners == null) {
261 mListeners = new ArrayList<AnimatorListener>();
262 }
263 mListeners.add(listener);
264 }
265
266 /**
267 * Removes a listener from the set listening to this animation.
268 *
269 * @param listener the listener to be removed from the current set of listeners for this
270 * animation.
271 */
272 public void removeListener(AnimatorListener listener) {
273 if (mListeners == null) {
274 return;
275 }
276 mListeners.remove(listener);
277 if (mListeners.size() == 0) {
278 mListeners = null;
Chet Haase17fb4b02010-06-28 17:55:07 -0700279 }
280 }
281
282 /**
Chet Haasea18a86b2010-09-07 13:20:00 -0700283 * Gets the set of {@link android.animation.Animator.AnimatorListener} objects that are currently
284 * listening for events on this <code>Animator</code> object.
Chet Haase602e4d32010-08-16 08:57:23 -0700285 *
Chet Haasea18a86b2010-09-07 13:20:00 -0700286 * @return ArrayList<AnimatorListener> The set of listeners.
Chet Haase602e4d32010-08-16 08:57:23 -0700287 */
Chet Haasea18a86b2010-09-07 13:20:00 -0700288 public ArrayList<AnimatorListener> getListeners() {
289 return mListeners;
Chet Haase602e4d32010-08-16 08:57:23 -0700290 }
291
292 /**
Chet Haase8aa1ffb2013-08-08 14:00:00 -0700293 * Adds a pause listener to this animator.
294 *
295 * @param listener the listener to be added to the current set of pause listeners
296 * for this animation.
297 */
298 public void addPauseListener(AnimatorPauseListener listener) {
299 if (mPauseListeners == null) {
300 mPauseListeners = new ArrayList<AnimatorPauseListener>();
301 }
302 mPauseListeners.add(listener);
303 }
304
305 /**
306 * Removes a pause listener from the set listening to this animation.
307 *
308 * @param listener the listener to be removed from the current set of pause
309 * listeners for this animation.
310 */
311 public void removePauseListener(AnimatorPauseListener listener) {
312 if (mPauseListeners == null) {
313 return;
314 }
315 mPauseListeners.remove(listener);
316 if (mPauseListeners.size() == 0) {
317 mPauseListeners = null;
318 }
319 }
320
321 /**
Chet Haased82c8ac2013-08-26 14:20:16 -0700322 * Removes all {@link #addListener(android.animation.Animator.AnimatorListener) listeners}
323 * and {@link #addPauseListener(android.animation.Animator.AnimatorPauseListener)
324 * pauseListeners} from this object.
Chet Haase17fb4b02010-06-28 17:55:07 -0700325 */
Chet Haasea18a86b2010-09-07 13:20:00 -0700326 public void removeAllListeners() {
Chet Haase17fb4b02010-06-28 17:55:07 -0700327 if (mListeners != null) {
Chet Haasea18a86b2010-09-07 13:20:00 -0700328 mListeners.clear();
329 mListeners = null;
Chet Haase17fb4b02010-06-28 17:55:07 -0700330 }
Chet Haase8aa1ffb2013-08-08 14:00:00 -0700331 if (mPauseListeners != null) {
332 mPauseListeners.clear();
333 mPauseListeners = null;
334 }
Chet Haase17fb4b02010-06-28 17:55:07 -0700335 }
336
Yigit Boyard422dc32014-09-25 12:23:35 -0700337 /**
338 * Return a mask of the configuration parameters for which this animator may change, requiring
339 * that it should be re-created from Resources. The default implementation returns whatever
340 * value was provided through setChangingConfigurations(int) or 0 by default.
341 *
342 * @return Returns a mask of the changing configuration parameters, as defined by
343 * {@link android.content.pm.ActivityInfo}.
344 * @see android.content.pm.ActivityInfo
345 * @hide
346 */
347 public int getChangingConfigurations() {
348 return mChangingConfigurations;
349 }
350
351 /**
352 * Set a mask of the configuration parameters for which this animator may change, requiring
353 * that it be re-created from resource.
354 *
355 * @param configs A mask of the changing configuration parameters, as
356 * defined by {@link android.content.pm.ActivityInfo}.
357 *
358 * @see android.content.pm.ActivityInfo
359 * @hide
360 */
361 public void setChangingConfigurations(int configs) {
362 mChangingConfigurations = configs;
363 }
364
365 /**
366 * Sets the changing configurations value to the union of the current changing configurations
367 * and the provided configs.
368 * This method is called while loading the animator.
369 * @hide
370 */
371 public void appendChangingConfigurations(int configs) {
372 mChangingConfigurations |= configs;
373 }
374
375 /**
376 * Return a {@link android.content.res.ConstantState} instance that holds the shared state of
377 * this Animator.
378 * <p>
379 * This constant state is used to create new instances of this animator when needed, instead
380 * of re-loading it from resources. Default implementation creates a new
381 * {@link AnimatorConstantState}. You can override this method to provide your custom logic or
382 * return null if you don't want this animator to be cached.
383 *
384 * @return The ConfigurationBoundResourceCache.BaseConstantState associated to this Animator.
385 * @see android.content.res.ConstantState
386 * @see #clone()
387 * @hide
388 */
389 public ConstantState<Animator> createConstantState() {
390 return new AnimatorConstantState(this);
391 }
392
Chet Haase49afa5b2010-08-23 11:39:53 -0700393 @Override
Chet Haase21cd1382010-09-01 17:42:29 -0700394 public Animator clone() {
Chet Haasea18a86b2010-09-07 13:20:00 -0700395 try {
396 final Animator anim = (Animator) super.clone();
397 if (mListeners != null) {
Yigit Boyard422dc32014-09-25 12:23:35 -0700398 anim.mListeners = new ArrayList<AnimatorListener>(mListeners);
Chet Haase49afa5b2010-08-23 11:39:53 -0700399 }
Chet Haase8aa1ffb2013-08-08 14:00:00 -0700400 if (mPauseListeners != null) {
Yigit Boyard422dc32014-09-25 12:23:35 -0700401 anim.mPauseListeners = new ArrayList<AnimatorPauseListener>(mPauseListeners);
Chet Haase8aa1ffb2013-08-08 14:00:00 -0700402 }
Chet Haasea18a86b2010-09-07 13:20:00 -0700403 return anim;
404 } catch (CloneNotSupportedException e) {
405 throw new AssertionError();
Chet Haase49afa5b2010-08-23 11:39:53 -0700406 }
Chet Haase49afa5b2010-08-23 11:39:53 -0700407 }
408
Chet Haase17fb4b02010-06-28 17:55:07 -0700409 /**
Chet Haasea18a86b2010-09-07 13:20:00 -0700410 * This method tells the object to use appropriate information to extract
411 * starting values for the animation. For example, a AnimatorSet object will pass
412 * this call to its child objects to tell them to set up the values. A
413 * ObjectAnimator object will use the information it has about its target object
414 * and PropertyValuesHolder objects to get the start values for its properties.
Ken Wakasaf76a50c2012-03-09 19:56:35 +0900415 * A ValueAnimator object will ignore the request since it does not have enough
Chet Haasea18a86b2010-09-07 13:20:00 -0700416 * information (such as a target object) to gather these values.
Chet Haase17fb4b02010-06-28 17:55:07 -0700417 */
Chet Haasea18a86b2010-09-07 13:20:00 -0700418 public void setupStartValues() {
419 }
420
421 /**
422 * This method tells the object to use appropriate information to extract
423 * ending values for the animation. For example, a AnimatorSet object will pass
424 * this call to its child objects to tell them to set up the values. A
425 * ObjectAnimator object will use the information it has about its target object
426 * and PropertyValuesHolder objects to get the start values for its properties.
Ken Wakasaf76a50c2012-03-09 19:56:35 +0900427 * A ValueAnimator object will ignore the request since it does not have enough
Chet Haasea18a86b2010-09-07 13:20:00 -0700428 * information (such as a target object) to gather these values.
429 */
430 public void setupEndValues() {
431 }
432
433 /**
434 * Sets the target object whose property will be animated by this animation. Not all subclasses
435 * operate on target objects (for example, {@link ValueAnimator}, but this method
436 * is on the superclass for the convenience of dealing generically with those subclasses
437 * that do handle targets.
438 *
439 * @param target The object being animated
440 */
441 public void setTarget(Object target) {
442 }
443
ztenghui7bc6a3f2014-07-15 15:12:12 -0700444 // Hide reverse() and canReverse() for now since reverse() only work for simple
445 // cases, like we don't support sequential, neither startDelay.
446 // TODO: make reverse() works for all the Animators.
447 /**
448 * @hide
449 */
450 public boolean canReverse() {
451 return false;
452 }
453
454 /**
455 * @hide
456 */
457 public void reverse() {
John Reck291161a2014-07-22 07:31:09 -0700458 throw new IllegalStateException("Reverse is not supported");
ztenghui7bc6a3f2014-07-15 15:12:12 -0700459 }
460
Chet Haasea18a86b2010-09-07 13:20:00 -0700461 /**
462 * <p>An animation listener receives notifications from an animation.
463 * Notifications indicate animation related events, such as the end or the
464 * repetition of the animation.</p>
465 */
466 public static interface AnimatorListener {
Chet Haase17fb4b02010-06-28 17:55:07 -0700467 /**
Chet Haasea18a86b2010-09-07 13:20:00 -0700468 * <p>Notifies the start of the animation.</p>
469 *
470 * @param animation The started animation.
471 */
472 void onAnimationStart(Animator animation);
473
474 /**
475 * <p>Notifies the end of the animation. This callback is not invoked
476 * for animations with repeat count set to INFINITE.</p>
477 *
478 * @param animation The animation which reached its end.
479 */
480 void onAnimationEnd(Animator animation);
481
482 /**
483 * <p>Notifies the cancellation of the animation. This callback is not invoked
484 * for animations with repeat count set to INFINITE.</p>
485 *
486 * @param animation The animation which was canceled.
487 */
488 void onAnimationCancel(Animator animation);
489
490 /**
491 * <p>Notifies the repetition of the animation.</p>
Chet Haase17fb4b02010-06-28 17:55:07 -0700492 *
493 * @param animation The animation which was repeated.
494 */
Chet Haasea18a86b2010-09-07 13:20:00 -0700495 void onAnimationRepeat(Animator animation);
Chet Haase17fb4b02010-06-28 17:55:07 -0700496 }
Chet Haase8aa1ffb2013-08-08 14:00:00 -0700497
498 /**
499 * A pause listener receives notifications from an animation when the
500 * animation is {@link #pause() paused} or {@link #resume() resumed}.
501 *
502 * @see #addPauseListener(AnimatorPauseListener)
503 */
504 public static interface AnimatorPauseListener {
505 /**
506 * <p>Notifies that the animation was paused.</p>
507 *
508 * @param animation The animaton being paused.
509 * @see #pause()
510 */
511 void onAnimationPause(Animator animation);
512
513 /**
514 * <p>Notifies that the animation was resumed, after being
515 * previously paused.</p>
516 *
517 * @param animation The animation being resumed.
518 * @see #resume()
519 */
520 void onAnimationResume(Animator animation);
521 }
John Reckc01bd112014-07-18 16:22:09 -0700522
523 /**
524 * <p>Whether or not the Animator is allowed to run asynchronously off of
525 * the UI thread. This is a hint that informs the Animator that it is
526 * OK to run the animation off-thread, however the Animator may decide
527 * that it must run the animation on the UI thread anyway.
528 *
529 * <p>Regardless of whether or not the animation runs asynchronously, all
530 * listener callbacks will be called on the UI thread.</p>
531 *
532 * <p>To be able to use this hint the following must be true:</p>
533 * <ol>
534 * <li>The animator is immutable while {@link #isStarted()} is true. Requests
535 * to change duration, delay, etc... may be ignored.</li>
536 * <li>Lifecycle callback events may be asynchronous. Events such as
537 * {@link Animator.AnimatorListener#onAnimationEnd(Animator)} or
538 * {@link Animator.AnimatorListener#onAnimationRepeat(Animator)} may end up delayed
539 * as they must be posted back to the UI thread, and any actions performed
540 * by those callbacks (such as starting new animations) will not happen
541 * in the same frame.</li>
542 * <li>State change requests ({@link #cancel()}, {@link #end()}, {@link #reverse()}, etc...)
543 * may be asynchronous. It is guaranteed that all state changes that are
544 * performed on the UI thread in the same frame will be applied as a single
545 * atomic update, however that frame may be the current frame,
546 * the next frame, or some future frame. This will also impact the observed
547 * state of the Animator. For example, {@link #isStarted()} may still return true
548 * after a call to {@link #end()}. Using the lifecycle callbacks is preferred over
549 * queries to {@link #isStarted()}, {@link #isRunning()}, and {@link #isPaused()}
550 * for this reason.</li>
551 * </ol>
552 * @hide
553 */
554 public void setAllowRunningAsynchronously(boolean mayRunAsync) {
555 // It is up to subclasses to support this, if they can.
556 }
Yigit Boyard422dc32014-09-25 12:23:35 -0700557
558 /**
559 * Creates a {@link ConstantState} which holds changing configurations information associated
560 * with the given Animator.
561 * <p>
562 * When {@link #newInstance()} is called, default implementation clones the Animator.
563 */
564 private static class AnimatorConstantState extends ConstantState<Animator> {
565
566 final Animator mAnimator;
567 int mChangingConf;
568
569 public AnimatorConstantState(Animator animator) {
570 mAnimator = animator;
571 // ensure a reference back to here so that constante state is not gc'ed.
572 mAnimator.mConstantState = this;
573 mChangingConf = mAnimator.getChangingConfigurations();
574 }
575
576 @Override
577 public int getChangingConfigurations() {
578 return mChangingConf;
579 }
580
581 @Override
582 public Animator newInstance() {
583 final Animator clone = mAnimator.clone();
584 clone.mConstantState = this;
585 return clone;
586 }
587 }
Chet Haasea18a86b2010-09-07 13:20:00 -0700588}