1/* 2 * Copyright (C) 2017 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 androidx.transition; 18 19import android.view.ViewGroup; 20 21/** 22 * Extend <code>TransitionPropagation</code> to customize start delays for Animators created 23 * in {@link Transition#createAnimator(ViewGroup, TransitionValues, TransitionValues)}. 24 * A Transition such as {@link Explode} defaults to using {@link CircularPropagation} and Views 25 * closer to the epicenter will move out of the scene later and into the scene sooner than Views 26 * farther from the epicenter, giving the appearance of inertia. With no TransitionPropagation, all 27 * Views will react simultaneously to the start of the transition. 28 * 29 * @see Transition#setPropagation(TransitionPropagation) 30 * @see Transition#getEpicenter() 31 */ 32public abstract class TransitionPropagation { 33 34 /** 35 * Called by Transition to alter the Animator start delay. All start delays will be adjusted 36 * such that the minimum becomes zero. 37 * 38 * @param sceneRoot The root of the View hierarchy running the transition. 39 * @param transition The transition that created the Animator 40 * @param startValues The values for a specific target in the start scene. 41 * @param endValues The values for the target in the end scene. 42 * @return A start delay to use with the Animator created by <code>transition</code>. The 43 * delay will be offset by the minimum delay of all <code>TransitionPropagation</code>s 44 * used in the Transition so that the smallest delay will be 0. Returned values may be 45 * negative. 46 */ 47 public abstract long getStartDelay(ViewGroup sceneRoot, Transition transition, 48 TransitionValues startValues, TransitionValues endValues); 49 50 /** 51 * Captures the values in the start or end scene for the properties that this 52 * transition propagation monitors. These values are then passed as the startValues 53 * or endValues structure in a later call to 54 * {@link #getStartDelay(ViewGroup, Transition, TransitionValues, TransitionValues)}. 55 * The main concern for an implementation is what the 56 * properties are that the transition cares about and what the values are 57 * for all of those properties. The start and end values will be compared 58 * later during the 59 * {@link #getStartDelay(ViewGroup, Transition, TransitionValues, TransitionValues)}. 60 * method to determine the start delay. 61 * 62 * <p>Subclasses must implement this method. The method should only be called by the 63 * transition system; it is not intended to be called from external classes.</p> 64 * 65 * @param transitionValues The holder for any values that the Transition 66 * wishes to store. Values are stored in the <code>values</code> field 67 * of this TransitionValues object and are keyed from 68 * a String value. For example, to store a view's rotation value, 69 * a transition might call 70 * <code>transitionValues.values.put("appname:transitionname:rotation", 71 * view.getRotation())</code>. The target view will already be stored 72 * in 73 * the transitionValues structure when this method is called. 74 */ 75 public abstract void captureValues(TransitionValues transitionValues); 76 77 /** 78 * Returns the set of property names stored in the {@link TransitionValues} 79 * object passed into {@link #captureValues(TransitionValues)} that 80 * this transition propagation cares about for the purposes of preventing 81 * duplicate capturing of property values. 82 * 83 * <p>A <code>TransitionPropagation</code> must override this method to prevent 84 * duplicate capturing of values and must contain at least one </p> 85 * 86 * @return An array of property names as described in the class documentation for 87 * {@link TransitionValues}. 88 */ 89 public abstract String[] getPropagationProperties(); 90 91} 92