1 /* 2 * Copyright (C) 2022 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 17 package androidx.constraintlayout.core.dsl; 18 19 import java.util.ArrayList; 20 21 /** 22 * This defines to MotionScene container 23 * It contains ConstraintSet and Transitions 24 */ 25 public class MotionScene { 26 ArrayList<Transition> mTransitions = new ArrayList<>(); 27 ArrayList<ConstraintSet> mConstraintSets = new ArrayList<>(); 28 29 // todo add support for variables, generate and helpers addTransition(Transition transition)30 public void addTransition(Transition transition) { 31 mTransitions.add(transition); 32 } 33 addConstraintSet(ConstraintSet constraintSet)34 public void addConstraintSet(ConstraintSet constraintSet) { 35 mConstraintSets.add(constraintSet); 36 } 37 38 @Override toString()39 public String toString() { 40 StringBuilder ret = new StringBuilder("{\n"); 41 if (!mTransitions.isEmpty()) { 42 ret.append("Transitions:{\n"); 43 for (Transition transition : mTransitions) { 44 ret.append(transition.toString()); 45 } 46 ret.append("},\n"); 47 } 48 if (!mConstraintSets.isEmpty()) { 49 ret.append("ConstraintSets:{\n"); 50 for (ConstraintSet constraintSet : mConstraintSets) { 51 ret.append(constraintSet.toString()); 52 } 53 ret.append("},\n"); 54 } 55 56 ret.append("}\n"); 57 return ret.toString(); 58 } 59 } 60