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