blob: 589ad574dd9b22ee20bc509e59554fc14c8da603 [file] [log] [blame]
Chet Haased82c8ac2013-08-26 14:20:16 -07001/*
2 * Copyright (C) 2013 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.transition;
18
19import android.animation.TimeInterpolator;
George Mountecd857b2014-06-19 07:51:08 -070020import android.content.Context;
21import android.content.res.TypedArray;
Chet Haased82c8ac2013-08-26 14:20:16 -070022import android.util.AndroidRuntimeException;
George Mountecd857b2014-06-19 07:51:08 -070023import android.util.AttributeSet;
Chet Haased82c8ac2013-08-26 14:20:16 -070024import android.view.View;
25import android.view.ViewGroup;
26
George Mount413739e2016-06-08 07:13:37 -070027import com.android.internal.R;
28
Chet Haased82c8ac2013-08-26 14:20:16 -070029import java.util.ArrayList;
30
31/**
32 * A TransitionSet is a parent of child transitions (including other
33 * TransitionSets). Using TransitionSets enables more complex
34 * choreography of transitions, where some sets play {@link #ORDERING_TOGETHER} and
35 * others play {@link #ORDERING_SEQUENTIAL}. For example, {@link AutoTransition}
36 * uses a TransitionSet to sequentially play a Fade(Fade.OUT), followed by
37 * a {@link ChangeBounds}, followed by a Fade(Fade.OUT) transition.
Chet Haaseaafc91c2013-10-06 12:10:12 -070038 *
39 * <p>A TransitionSet can be described in a resource file by using the
40 * tag <code>transitionSet</code>, along with the standard
41 * attributes of {@link android.R.styleable#TransitionSet} and
42 * {@link android.R.styleable#Transition}. Child transitions of the
43 * TransitionSet object can be loaded by adding those child tags inside the
44 * enclosing <code>transitionSet</code> tag. For example, the following xml
45 * describes a TransitionSet that plays a Fade and then a ChangeBounds
46 * transition on the affected view targets:</p>
47 * <pre>
48 * &lt;transitionSet xmlns:android="http://schemas.android.com/apk/res/android"
George Mount93aaab02016-02-10 15:39:17 -080049 * android:transitionOrdering="sequential"&gt;
Chet Haaseaafc91c2013-10-06 12:10:12 -070050 * &lt;fade/&gt;
51 * &lt;changeBounds/&gt;
52 * &lt;/transitionSet&gt;
53 * </pre>
Chet Haased82c8ac2013-08-26 14:20:16 -070054 */
55public class TransitionSet extends Transition {
George Mounta69609e2018-03-15 16:37:37 -070056 /**
57 * Flag indicating the the interpolator changed.
58 */
59 private static final int FLAG_CHANGE_INTERPOLATOR = 0x01;
60 /**
61 * Flag indicating the the propagation changed.
62 */
63 private static final int FLAG_CHANGE_PROPAGATION = 0x02;
64 /**
65 * Flag indicating the the path motion changed.
66 */
67 private static final int FLAG_CHANGE_PATH_MOTION = 0x04;
68 /**
69 * Flag indicating the the epicentera callback changed.
70 */
71 static final int FLAG_CHANGE_EPICENTER = 0x08;
Chet Haased82c8ac2013-08-26 14:20:16 -070072
73 ArrayList<Transition> mTransitions = new ArrayList<Transition>();
74 private boolean mPlayTogether = true;
75 int mCurrentListeners;
76 boolean mStarted = false;
George Mounta69609e2018-03-15 16:37:37 -070077 // Flags to know whether or not the interpolator, path motion, epicenter, propagation
78 // have changed
79 private int mChangeFlags = 0;
Chet Haased82c8ac2013-08-26 14:20:16 -070080
81 /**
82 * A flag used to indicate that the child transitions of this set
83 * should all start at the same time.
84 */
85 public static final int ORDERING_TOGETHER = 0;
86 /**
87 * A flag used to indicate that the child transitions of this set should
88 * play in sequence; when one child transition ends, the next child
89 * transition begins. Note that a transition does not end until all
90 * instances of it (which are playing on all applicable targets of the
91 * transition) end.
92 */
93 public static final int ORDERING_SEQUENTIAL = 1;
94
95 /**
96 * Constructs an empty transition set. Add child transitions to the
97 * set by calling {@link #addTransition(Transition)} )}. By default,
98 * child transitions will play {@link #ORDERING_TOGETHER together}.
99 */
100 public TransitionSet() {
101 }
102
George Mountecd857b2014-06-19 07:51:08 -0700103 public TransitionSet(Context context, AttributeSet attrs) {
104 super(context, attrs);
105 TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.TransitionSet);
106 int ordering = a.getInt(R.styleable.TransitionSet_transitionOrdering,
107 TransitionSet.ORDERING_TOGETHER);
108 setOrdering(ordering);
109 a.recycle();
110 }
111
Chet Haased82c8ac2013-08-26 14:20:16 -0700112 /**
113 * Sets the play order of this set's child transitions.
114 *
115 * @param ordering {@link #ORDERING_TOGETHER} to play this set's child
116 * transitions together, {@link #ORDERING_SEQUENTIAL} to play the child
117 * transitions in sequence.
118 * @return This transitionSet object.
119 */
120 public TransitionSet setOrdering(int ordering) {
121 switch (ordering) {
122 case ORDERING_SEQUENTIAL:
123 mPlayTogether = false;
124 break;
125 case ORDERING_TOGETHER:
126 mPlayTogether = true;
127 break;
128 default:
129 throw new AndroidRuntimeException("Invalid parameter for TransitionSet " +
130 "ordering: " + ordering);
131 }
132 return this;
133 }
134
135 /**
136 * Returns the ordering of this TransitionSet. By default, the value is
137 * {@link #ORDERING_TOGETHER}.
138 *
139 * @return {@link #ORDERING_TOGETHER} if child transitions will play at the same
140 * time, {@link #ORDERING_SEQUENTIAL} if they will play in sequence.
141 *
142 * @see #setOrdering(int)
143 */
144 public int getOrdering() {
145 return mPlayTogether ? ORDERING_TOGETHER : ORDERING_SEQUENTIAL;
146 }
147
148 /**
149 * Adds child transition to this set. The order in which this child transition
150 * is added relative to other child transitions that are added, in addition to
151 * the {@link #getOrdering() ordering} property, determines the
152 * order in which the transitions are started.
153 *
George Mounta69609e2018-03-15 16:37:37 -0700154 * <p>If this transitionSet has a {@link #getDuration() duration},
155 * {@link #getInterpolator() interpolator}, {@link #getPropagation() propagation delay},
156 * {@link #getPathMotion() path motion}, or
157 * {@link #setEpicenterCallback(EpicenterCallback) epicenter callback}
158 * set on it, the child transition will inherit the values that are set.
159 * Transitions are assumed to have a maximum of one transitionSet parent.</p>
Chet Haased82c8ac2013-08-26 14:20:16 -0700160 *
161 * @param transition A non-null child transition to be added to this set.
162 * @return This transitionSet object.
163 */
164 public TransitionSet addTransition(Transition transition) {
165 if (transition != null) {
166 mTransitions.add(transition);
167 transition.mParent = this;
168 if (mDuration >= 0) {
169 transition.setDuration(mDuration);
170 }
George Mounta69609e2018-03-15 16:37:37 -0700171 if ((mChangeFlags & FLAG_CHANGE_INTERPOLATOR) != 0) {
172 transition.setInterpolator(getInterpolator());
173 }
174 if ((mChangeFlags & FLAG_CHANGE_PROPAGATION) != 0) {
175 transition.setPropagation(getPropagation());
176 }
177 if ((mChangeFlags & FLAG_CHANGE_PATH_MOTION) != 0) {
178 transition.setPathMotion(getPathMotion());
179 }
180 if ((mChangeFlags & FLAG_CHANGE_EPICENTER) != 0) {
181 transition.setEpicenterCallback(getEpicenterCallback());
182 }
Chet Haased82c8ac2013-08-26 14:20:16 -0700183 }
184 return this;
185 }
186
187 /**
George Mount7f151642014-08-18 16:24:21 -0700188 * Returns the number of child transitions in the TransitionSet.
189 *
190 * @return The number of child transitions in the TransitionSet.
191 * @see #addTransition(Transition)
192 * @see #getTransitionAt(int)
193 */
194 public int getTransitionCount() {
195 return mTransitions.size();
196 }
197
198 /**
199 * Returns the child Transition at the specified position in the TransitionSet.
200 *
201 * @param index The position of the Transition to retrieve.
202 * @see #addTransition(Transition)
203 * @see #getTransitionCount()
204 */
205 public Transition getTransitionAt(int index) {
206 if (index < 0 || index >= mTransitions.size()) {
207 return null;
208 }
209 return mTransitions.get(index);
210 }
211
212 /**
Chet Haased82c8ac2013-08-26 14:20:16 -0700213 * Setting a non-negative duration on a TransitionSet causes all of the child
214 * transitions (current and future) to inherit this duration.
215 *
216 * @param duration The length of the animation, in milliseconds.
217 * @return This transitionSet object.
218 */
219 @Override
220 public TransitionSet setDuration(long duration) {
221 super.setDuration(duration);
George Mounte3b50ae2014-07-15 10:41:50 -0700222 if (mDuration >= 0 && mTransitions != null) {
Chet Haased82c8ac2013-08-26 14:20:16 -0700223 int numTransitions = mTransitions.size();
224 for (int i = 0; i < numTransitions; ++i) {
225 mTransitions.get(i).setDuration(duration);
226 }
227 }
228 return this;
229 }
230
231 @Override
232 public TransitionSet setStartDelay(long startDelay) {
233 return (TransitionSet) super.setStartDelay(startDelay);
234 }
235
236 @Override
237 public TransitionSet setInterpolator(TimeInterpolator interpolator) {
George Mounta69609e2018-03-15 16:37:37 -0700238 mChangeFlags |= FLAG_CHANGE_INTERPOLATOR;
239 if (mTransitions != null) {
240 int numTransitions = mTransitions.size();
241 for (int i = 0; i < numTransitions; ++i) {
242 mTransitions.get(i).setInterpolator(interpolator);
243 }
244 }
Chet Haased82c8ac2013-08-26 14:20:16 -0700245 return (TransitionSet) super.setInterpolator(interpolator);
246 }
247
248 @Override
249 public TransitionSet addTarget(View target) {
George Mountd4c3c912014-06-09 12:31:34 -0700250 for (int i = 0; i < mTransitions.size(); i++) {
251 mTransitions.get(i).addTarget(target);
252 }
Chet Haased82c8ac2013-08-26 14:20:16 -0700253 return (TransitionSet) super.addTarget(target);
254 }
255
256 @Override
Chet Haaseff58f922013-09-11 13:08:18 -0700257 public TransitionSet addTarget(int targetId) {
George Mountd4c3c912014-06-09 12:31:34 -0700258 for (int i = 0; i < mTransitions.size(); i++) {
259 mTransitions.get(i).addTarget(targetId);
260 }
Chet Haaseff58f922013-09-11 13:08:18 -0700261 return (TransitionSet) super.addTarget(targetId);
Chet Haased82c8ac2013-08-26 14:20:16 -0700262 }
263
264 @Override
George Mountd4c3c912014-06-09 12:31:34 -0700265 public TransitionSet addTarget(String targetName) {
266 for (int i = 0; i < mTransitions.size(); i++) {
267 mTransitions.get(i).addTarget(targetName);
268 }
269 return (TransitionSet) super.addTarget(targetName);
270 }
271
272 @Override
273 public TransitionSet addTarget(Class targetType) {
274 for (int i = 0; i < mTransitions.size(); i++) {
275 mTransitions.get(i).addTarget(targetType);
276 }
277 return (TransitionSet) super.addTarget(targetType);
278 }
279
280 @Override
Chet Haased82c8ac2013-08-26 14:20:16 -0700281 public TransitionSet addListener(TransitionListener listener) {
282 return (TransitionSet) super.addListener(listener);
283 }
284
285 @Override
Chet Haaseff58f922013-09-11 13:08:18 -0700286 public TransitionSet removeTarget(int targetId) {
George Mountd4c3c912014-06-09 12:31:34 -0700287 for (int i = 0; i < mTransitions.size(); i++) {
288 mTransitions.get(i).removeTarget(targetId);
289 }
Chet Haaseff58f922013-09-11 13:08:18 -0700290 return (TransitionSet) super.removeTarget(targetId);
Chet Haased82c8ac2013-08-26 14:20:16 -0700291 }
292
293 @Override
294 public TransitionSet removeTarget(View target) {
George Mountd4c3c912014-06-09 12:31:34 -0700295 for (int i = 0; i < mTransitions.size(); i++) {
296 mTransitions.get(i).removeTarget(target);
297 }
Chet Haased82c8ac2013-08-26 14:20:16 -0700298 return (TransitionSet) super.removeTarget(target);
299 }
300
301 @Override
George Mountd4c3c912014-06-09 12:31:34 -0700302 public TransitionSet removeTarget(Class target) {
303 for (int i = 0; i < mTransitions.size(); i++) {
304 mTransitions.get(i).removeTarget(target);
305 }
306 return (TransitionSet) super.removeTarget(target);
307 }
308
309 @Override
310 public TransitionSet removeTarget(String target) {
311 for (int i = 0; i < mTransitions.size(); i++) {
312 mTransitions.get(i).removeTarget(target);
313 }
314 return (TransitionSet) super.removeTarget(target);
315 }
316
317 @Override
318 public Transition excludeTarget(View target, boolean exclude) {
319 for (int i = 0; i < mTransitions.size(); i++) {
320 mTransitions.get(i).excludeTarget(target, exclude);
321 }
322 return super.excludeTarget(target, exclude);
323 }
324
325 @Override
George Mount0a2ae002014-06-23 14:57:27 +0000326 public Transition excludeTarget(String targetName, boolean exclude) {
George Mountd4c3c912014-06-09 12:31:34 -0700327 for (int i = 0; i < mTransitions.size(); i++) {
George Mount0a2ae002014-06-23 14:57:27 +0000328 mTransitions.get(i).excludeTarget(targetName, exclude);
George Mountd4c3c912014-06-09 12:31:34 -0700329 }
George Mount0a2ae002014-06-23 14:57:27 +0000330 return super.excludeTarget(targetName, exclude);
George Mountd4c3c912014-06-09 12:31:34 -0700331 }
332
333 @Override
334 public Transition excludeTarget(int targetId, boolean exclude) {
335 for (int i = 0; i < mTransitions.size(); i++) {
336 mTransitions.get(i).excludeTarget(targetId, exclude);
337 }
338 return super.excludeTarget(targetId, exclude);
339 }
340
341 @Override
342 public Transition excludeTarget(Class type, boolean exclude) {
343 for (int i = 0; i < mTransitions.size(); i++) {
344 mTransitions.get(i).excludeTarget(type, exclude);
345 }
346 return super.excludeTarget(type, exclude);
347 }
348
349 @Override
Chet Haased82c8ac2013-08-26 14:20:16 -0700350 public TransitionSet removeListener(TransitionListener listener) {
351 return (TransitionSet) super.removeListener(listener);
352 }
353
George Mountecd857b2014-06-19 07:51:08 -0700354 @Override
355 public void setPathMotion(PathMotion pathMotion) {
356 super.setPathMotion(pathMotion);
George Mounta69609e2018-03-15 16:37:37 -0700357 mChangeFlags |= FLAG_CHANGE_PATH_MOTION;
George Mountecd857b2014-06-19 07:51:08 -0700358 for (int i = 0; i < mTransitions.size(); i++) {
359 mTransitions.get(i).setPathMotion(pathMotion);
360 }
361 }
362
Chet Haased82c8ac2013-08-26 14:20:16 -0700363 /**
364 * Removes the specified child transition from this set.
365 *
366 * @param transition The transition to be removed.
367 * @return This transitionSet object.
368 */
369 public TransitionSet removeTransition(Transition transition) {
370 mTransitions.remove(transition);
371 transition.mParent = null;
372 return this;
373 }
374
375 /**
376 * Sets up listeners for each of the child transitions. This is used to
377 * determine when this transition set is finished (all child transitions
378 * must finish first).
379 */
380 private void setupStartEndListeners() {
381 TransitionSetListener listener = new TransitionSetListener(this);
382 for (Transition childTransition : mTransitions) {
383 childTransition.addListener(listener);
384 }
385 mCurrentListeners = mTransitions.size();
386 }
387
388 /**
389 * This listener is used to detect when all child transitions are done, at
390 * which point this transition set is also done.
391 */
392 static class TransitionSetListener extends TransitionListenerAdapter {
393 TransitionSet mTransitionSet;
394 TransitionSetListener(TransitionSet transitionSet) {
395 mTransitionSet = transitionSet;
396 }
397 @Override
398 public void onTransitionStart(Transition transition) {
399 if (!mTransitionSet.mStarted) {
400 mTransitionSet.start();
401 mTransitionSet.mStarted = true;
402 }
403 }
404
405 @Override
406 public void onTransitionEnd(Transition transition) {
407 --mTransitionSet.mCurrentListeners;
408 if (mTransitionSet.mCurrentListeners == 0) {
409 // All child trans
410 mTransitionSet.mStarted = false;
411 mTransitionSet.end();
412 }
413 transition.removeListener(this);
414 }
415 }
416
417 /**
418 * @hide
419 */
420 @Override
421 protected void createAnimators(ViewGroup sceneRoot, TransitionValuesMaps startValues,
George Mount4d1ecf52014-07-29 11:15:54 -0700422 TransitionValuesMaps endValues, ArrayList<TransitionValues> startValuesList,
423 ArrayList<TransitionValues> endValuesList) {
George Mount04600022014-09-10 10:58:08 -0700424 long startDelay = getStartDelay();
425 int numTransitions = mTransitions.size();
426 for (int i = 0; i < numTransitions; i++) {
427 Transition childTransition = mTransitions.get(i);
428 // We only set the start delay on the first transition if we are playing
429 // the transitions sequentially.
430 if (startDelay > 0 && (mPlayTogether || i == 0)) {
431 long childStartDelay = childTransition.getStartDelay();
432 if (childStartDelay > 0) {
433 childTransition.setStartDelay(startDelay + childStartDelay);
434 } else {
435 childTransition.setStartDelay(startDelay);
436 }
437 }
George Mount4d1ecf52014-07-29 11:15:54 -0700438 childTransition.createAnimators(sceneRoot, startValues, endValues, startValuesList,
439 endValuesList);
Chet Haased82c8ac2013-08-26 14:20:16 -0700440 }
441 }
442
443 /**
444 * @hide
445 */
446 @Override
447 protected void runAnimators() {
George Mount38a66492014-09-10 10:58:08 -0700448 if (mTransitions.isEmpty()) {
449 start();
450 end();
451 return;
452 }
Chet Haased82c8ac2013-08-26 14:20:16 -0700453 setupStartEndListeners();
George Mount38a66492014-09-10 10:58:08 -0700454 int numTransitions = mTransitions.size();
Chet Haased82c8ac2013-08-26 14:20:16 -0700455 if (!mPlayTogether) {
456 // Setup sequence with listeners
457 // TODO: Need to add listeners in such a way that we can remove them later if canceled
George Mount38a66492014-09-10 10:58:08 -0700458 for (int i = 1; i < numTransitions; ++i) {
Chet Haased82c8ac2013-08-26 14:20:16 -0700459 Transition previousTransition = mTransitions.get(i - 1);
460 final Transition nextTransition = mTransitions.get(i);
461 previousTransition.addListener(new TransitionListenerAdapter() {
462 @Override
463 public void onTransitionEnd(Transition transition) {
464 nextTransition.runAnimators();
465 transition.removeListener(this);
466 }
467 });
468 }
469 Transition firstTransition = mTransitions.get(0);
470 if (firstTransition != null) {
471 firstTransition.runAnimators();
472 }
473 } else {
George Mount38a66492014-09-10 10:58:08 -0700474 for (int i = 0; i < numTransitions; ++i) {
475 mTransitions.get(i).runAnimators();
Chet Haased82c8ac2013-08-26 14:20:16 -0700476 }
477 }
478 }
479
480 @Override
481 public void captureStartValues(TransitionValues transitionValues) {
George Mount30da61d2014-05-09 13:17:52 -0700482 if (isValidTarget(transitionValues.view)) {
Chet Haaseff58f922013-09-11 13:08:18 -0700483 for (Transition childTransition : mTransitions) {
George Mount30da61d2014-05-09 13:17:52 -0700484 if (childTransition.isValidTarget(transitionValues.view)) {
Chet Haaseff58f922013-09-11 13:08:18 -0700485 childTransition.captureStartValues(transitionValues);
George Mount5030c7f2014-09-10 10:58:08 -0700486 transitionValues.targetedTransitions.add(childTransition);
Chet Haaseff58f922013-09-11 13:08:18 -0700487 }
Chet Haased82c8ac2013-08-26 14:20:16 -0700488 }
489 }
490 }
491
492 @Override
493 public void captureEndValues(TransitionValues transitionValues) {
George Mount30da61d2014-05-09 13:17:52 -0700494 if (isValidTarget(transitionValues.view)) {
Chet Haaseff58f922013-09-11 13:08:18 -0700495 for (Transition childTransition : mTransitions) {
George Mount30da61d2014-05-09 13:17:52 -0700496 if (childTransition.isValidTarget(transitionValues.view)) {
Chet Haaseff58f922013-09-11 13:08:18 -0700497 childTransition.captureEndValues(transitionValues);
George Mount5030c7f2014-09-10 10:58:08 -0700498 transitionValues.targetedTransitions.add(childTransition);
Chet Haaseff58f922013-09-11 13:08:18 -0700499 }
Chet Haased82c8ac2013-08-26 14:20:16 -0700500 }
501 }
502 }
503
George Mountd6107a32014-03-10 16:51:16 -0700504 @Override
505 void capturePropagationValues(TransitionValues transitionValues) {
506 super.capturePropagationValues(transitionValues);
507 int numTransitions = mTransitions.size();
508 for (int i = 0; i < numTransitions; ++i) {
509 mTransitions.get(i).capturePropagationValues(transitionValues);
510 }
511 }
512
Chet Haased82c8ac2013-08-26 14:20:16 -0700513 /** @hide */
514 @Override
George Mountcf68aad2014-03-06 14:17:46 -0800515 public void pause(View sceneRoot) {
516 super.pause(sceneRoot);
Chet Haased82c8ac2013-08-26 14:20:16 -0700517 int numTransitions = mTransitions.size();
518 for (int i = 0; i < numTransitions; ++i) {
George Mountcf68aad2014-03-06 14:17:46 -0800519 mTransitions.get(i).pause(sceneRoot);
Chet Haased82c8ac2013-08-26 14:20:16 -0700520 }
521 }
522
523 /** @hide */
524 @Override
George Mountcf68aad2014-03-06 14:17:46 -0800525 public void resume(View sceneRoot) {
526 super.resume(sceneRoot);
Chet Haased82c8ac2013-08-26 14:20:16 -0700527 int numTransitions = mTransitions.size();
528 for (int i = 0; i < numTransitions; ++i) {
George Mountcf68aad2014-03-06 14:17:46 -0800529 mTransitions.get(i).resume(sceneRoot);
Chet Haased82c8ac2013-08-26 14:20:16 -0700530 }
531 }
532
533 /** @hide */
534 @Override
535 protected void cancel() {
536 super.cancel();
537 int numTransitions = mTransitions.size();
538 for (int i = 0; i < numTransitions; ++i) {
539 mTransitions.get(i).cancel();
540 }
541 }
542
George Mount413739e2016-06-08 07:13:37 -0700543 /** @hide */
544 @Override
545 void forceToEnd(ViewGroup sceneRoot) {
546 super.forceToEnd(sceneRoot);
547 int numTransitions = mTransitions.size();
548 for (int i = 0; i < numTransitions; ++i) {
549 mTransitions.get(i).forceToEnd(sceneRoot);
550 }
551 }
552
Chet Haased82c8ac2013-08-26 14:20:16 -0700553 @Override
554 TransitionSet setSceneRoot(ViewGroup sceneRoot) {
555 super.setSceneRoot(sceneRoot);
556 int numTransitions = mTransitions.size();
557 for (int i = 0; i < numTransitions; ++i) {
558 mTransitions.get(i).setSceneRoot(sceneRoot);
559 }
560 return (TransitionSet) this;
561 }
562
563 @Override
Chet Haaseb7a7fc92013-09-20 16:33:08 -0700564 void setCanRemoveViews(boolean canRemoveViews) {
565 super.setCanRemoveViews(canRemoveViews);
566 int numTransitions = mTransitions.size();
567 for (int i = 0; i < numTransitions; ++i) {
568 mTransitions.get(i).setCanRemoveViews(canRemoveViews);
569 }
570 }
571
572 @Override
George Mountd6107a32014-03-10 16:51:16 -0700573 public void setPropagation(TransitionPropagation propagation) {
574 super.setPropagation(propagation);
George Mounta69609e2018-03-15 16:37:37 -0700575 mChangeFlags |= FLAG_CHANGE_PROPAGATION;
George Mountd6107a32014-03-10 16:51:16 -0700576 int numTransitions = mTransitions.size();
577 for (int i = 0; i < numTransitions; ++i) {
578 mTransitions.get(i).setPropagation(propagation);
579 }
580 }
581
582 @Override
583 public void setEpicenterCallback(EpicenterCallback epicenterCallback) {
584 super.setEpicenterCallback(epicenterCallback);
George Mounta69609e2018-03-15 16:37:37 -0700585 mChangeFlags |= FLAG_CHANGE_EPICENTER;
George Mountd6107a32014-03-10 16:51:16 -0700586 int numTransitions = mTransitions.size();
587 for (int i = 0; i < numTransitions; ++i) {
588 mTransitions.get(i).setEpicenterCallback(epicenterCallback);
589 }
590 }
591
592 @Override
Chet Haased82c8ac2013-08-26 14:20:16 -0700593 String toString(String indent) {
594 String result = super.toString(indent);
595 for (int i = 0; i < mTransitions.size(); ++i) {
596 result += "\n" + mTransitions.get(i).toString(indent + " ");
597 }
598 return result;
599 }
600
601 @Override
602 public TransitionSet clone() {
603 TransitionSet clone = (TransitionSet) super.clone();
604 clone.mTransitions = new ArrayList<Transition>();
605 int numTransitions = mTransitions.size();
606 for (int i = 0; i < numTransitions; ++i) {
Chet Haasec46181a2013-09-16 13:56:21 -0700607 clone.addTransition((Transition) mTransitions.get(i).clone());
Chet Haased82c8ac2013-08-26 14:20:16 -0700608 }
609 return clone;
610 }
Chet Haased82c8ac2013-08-26 14:20:16 -0700611}