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