1d6107a3170df61d9e776fcd5666acfc9135c6f16George Mount/* 2d6107a3170df61d9e776fcd5666acfc9135c6f16George Mount * Copyright (C) 2014 The Android Open Source Project 3d6107a3170df61d9e776fcd5666acfc9135c6f16George Mount * 4d6107a3170df61d9e776fcd5666acfc9135c6f16George Mount * Licensed under the Apache License, Version 2.0 (the "License"); 5d6107a3170df61d9e776fcd5666acfc9135c6f16George Mount * you may not use this file except in compliance with the License. 6d6107a3170df61d9e776fcd5666acfc9135c6f16George Mount * You may obtain a copy of the License at 7d6107a3170df61d9e776fcd5666acfc9135c6f16George Mount * 8d6107a3170df61d9e776fcd5666acfc9135c6f16George Mount * http://www.apache.org/licenses/LICENSE-2.0 9d6107a3170df61d9e776fcd5666acfc9135c6f16George Mount * 10d6107a3170df61d9e776fcd5666acfc9135c6f16George Mount * Unless required by applicable law or agreed to in writing, software 11d6107a3170df61d9e776fcd5666acfc9135c6f16George Mount * distributed under the License is distributed on an "AS IS" BASIS, 12d6107a3170df61d9e776fcd5666acfc9135c6f16George Mount * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13d6107a3170df61d9e776fcd5666acfc9135c6f16George Mount * See the License for the specific language governing permissions and 14d6107a3170df61d9e776fcd5666acfc9135c6f16George Mount * limitations under the License. 15d6107a3170df61d9e776fcd5666acfc9135c6f16George Mount */ 16d6107a3170df61d9e776fcd5666acfc9135c6f16George Mountpackage android.transition; 17d6107a3170df61d9e776fcd5666acfc9135c6f16George Mount 18d6107a3170df61d9e776fcd5666acfc9135c6f16George Mountimport android.view.ViewGroup; 19d6107a3170df61d9e776fcd5666acfc9135c6f16George Mount 20d6107a3170df61d9e776fcd5666acfc9135c6f16George Mount/** 21d6107a3170df61d9e776fcd5666acfc9135c6f16George Mount * Extend <code>TransitionPropagation</code> to customize start delays for Animators created 22d6107a3170df61d9e776fcd5666acfc9135c6f16George Mount * in {@link android.transition.Transition#createAnimator(ViewGroup, 23d6107a3170df61d9e776fcd5666acfc9135c6f16George Mount * TransitionValues, TransitionValues)}. A Transition such as {@link android.transition.Explode} 24d6107a3170df61d9e776fcd5666acfc9135c6f16George Mount * defaults to using {@link android.transition.CircularPropagation} and Views closer to the 25d6107a3170df61d9e776fcd5666acfc9135c6f16George Mount * epicenter will move out of the scene later and into the scene sooner than Views farther 26d6107a3170df61d9e776fcd5666acfc9135c6f16George Mount * from the epicenter, giving the appearance of inertia. With no TransitionPropagation, all 27d6107a3170df61d9e776fcd5666acfc9135c6f16George Mount * Views will react simultaneously to the start of the transition. 28d6107a3170df61d9e776fcd5666acfc9135c6f16George Mount * 29d6107a3170df61d9e776fcd5666acfc9135c6f16George Mount * @see Transition#setPropagation(TransitionPropagation) 30d6107a3170df61d9e776fcd5666acfc9135c6f16George Mount * @see Transition#getEpicenter() 31d6107a3170df61d9e776fcd5666acfc9135c6f16George Mount */ 32d6107a3170df61d9e776fcd5666acfc9135c6f16George Mountpublic abstract class TransitionPropagation { 33d6107a3170df61d9e776fcd5666acfc9135c6f16George Mount /** 34d6107a3170df61d9e776fcd5666acfc9135c6f16George Mount * Called by Transition to alter the Animator start delay. All start delays will be adjusted 35d6107a3170df61d9e776fcd5666acfc9135c6f16George Mount * such that the minimum becomes zero. 36d6107a3170df61d9e776fcd5666acfc9135c6f16George Mount * @param sceneRoot The root of the View hierarchy running the transition. 37d6107a3170df61d9e776fcd5666acfc9135c6f16George Mount * @param transition The transition that created the Animator 38d6107a3170df61d9e776fcd5666acfc9135c6f16George Mount * @param startValues The values for a specific target in the start scene. 39d6107a3170df61d9e776fcd5666acfc9135c6f16George Mount * @param endValues The values for the target in the end scene. 40d6107a3170df61d9e776fcd5666acfc9135c6f16George Mount * @return A start delay to use with the Animator created by <code>transition</code>. The 41d6107a3170df61d9e776fcd5666acfc9135c6f16George Mount * delay will be offset by the minimum delay of all <code>TransitionPropagation</code>s 42d6107a3170df61d9e776fcd5666acfc9135c6f16George Mount * used in the Transition so that the smallest delay will be 0. Returned values may be 43d6107a3170df61d9e776fcd5666acfc9135c6f16George Mount * negative. 44d6107a3170df61d9e776fcd5666acfc9135c6f16George Mount */ 45d6107a3170df61d9e776fcd5666acfc9135c6f16George Mount public abstract long getStartDelay(ViewGroup sceneRoot, Transition transition, 46d6107a3170df61d9e776fcd5666acfc9135c6f16George Mount TransitionValues startValues, TransitionValues endValues); 47d6107a3170df61d9e776fcd5666acfc9135c6f16George Mount 48d6107a3170df61d9e776fcd5666acfc9135c6f16George Mount /** 49d6107a3170df61d9e776fcd5666acfc9135c6f16George Mount * Captures the values in the start or end scene for the properties that this 50d6107a3170df61d9e776fcd5666acfc9135c6f16George Mount * transition propagation monitors. These values are then passed as the startValues 51d6107a3170df61d9e776fcd5666acfc9135c6f16George Mount * or endValues structure in a later call to 52d6107a3170df61d9e776fcd5666acfc9135c6f16George Mount * {@link #getStartDelay(ViewGroup, Transition, TransitionValues, TransitionValues)}. 53d6107a3170df61d9e776fcd5666acfc9135c6f16George Mount * The main concern for an implementation is what the 54d6107a3170df61d9e776fcd5666acfc9135c6f16George Mount * properties are that the transition cares about and what the values are 55d6107a3170df61d9e776fcd5666acfc9135c6f16George Mount * for all of those properties. The start and end values will be compared 56d6107a3170df61d9e776fcd5666acfc9135c6f16George Mount * later during the 57d6107a3170df61d9e776fcd5666acfc9135c6f16George Mount * {@link #getStartDelay(ViewGroup, Transition, TransitionValues, TransitionValues)}. 58d6107a3170df61d9e776fcd5666acfc9135c6f16George Mount * method to determine the start delay. 59d6107a3170df61d9e776fcd5666acfc9135c6f16George Mount * 60d6107a3170df61d9e776fcd5666acfc9135c6f16George Mount * <p>Subclasses must implement this method. The method should only be called by the 61d6107a3170df61d9e776fcd5666acfc9135c6f16George Mount * transition system; it is not intended to be called from external classes.</p> 62d6107a3170df61d9e776fcd5666acfc9135c6f16George Mount * 63d6107a3170df61d9e776fcd5666acfc9135c6f16George Mount * @param transitionValues The holder for any values that the Transition 64d6107a3170df61d9e776fcd5666acfc9135c6f16George Mount * wishes to store. Values are stored in the <code>values</code> field 65d6107a3170df61d9e776fcd5666acfc9135c6f16George Mount * of this TransitionValues object and are keyed from 66d6107a3170df61d9e776fcd5666acfc9135c6f16George Mount * a String value. For example, to store a view's rotation value, 67d6107a3170df61d9e776fcd5666acfc9135c6f16George Mount * a transition might call 68d6107a3170df61d9e776fcd5666acfc9135c6f16George Mount * <code>transitionValues.values.put("appname:transitionname:rotation", 69d6107a3170df61d9e776fcd5666acfc9135c6f16George Mount * view.getRotation())</code>. The target view will already be stored in 70d6107a3170df61d9e776fcd5666acfc9135c6f16George Mount * the transitionValues structure when this method is called. 71d6107a3170df61d9e776fcd5666acfc9135c6f16George Mount */ 72d6107a3170df61d9e776fcd5666acfc9135c6f16George Mount public abstract void captureValues(TransitionValues transitionValues); 73d6107a3170df61d9e776fcd5666acfc9135c6f16George Mount 74d6107a3170df61d9e776fcd5666acfc9135c6f16George Mount /** 75d6107a3170df61d9e776fcd5666acfc9135c6f16George Mount * Returns the set of property names stored in the {@link TransitionValues} 76d6107a3170df61d9e776fcd5666acfc9135c6f16George Mount * object passed into {@link #captureValues(TransitionValues)} that 77d6107a3170df61d9e776fcd5666acfc9135c6f16George Mount * this transition propagation cares about for the purposes of preventing 78d6107a3170df61d9e776fcd5666acfc9135c6f16George Mount * duplicate capturing of property values. 79d6107a3170df61d9e776fcd5666acfc9135c6f16George Mount 80d6107a3170df61d9e776fcd5666acfc9135c6f16George Mount * <p>A <code>TransitionPropagation</code> must override this method to prevent 81d6107a3170df61d9e776fcd5666acfc9135c6f16George Mount * duplicate capturing of values and must contain at least one </p> 82d6107a3170df61d9e776fcd5666acfc9135c6f16George Mount * 83d6107a3170df61d9e776fcd5666acfc9135c6f16George Mount * @return An array of property names as described in the class documentation for 84d6107a3170df61d9e776fcd5666acfc9135c6f16George Mount * {@link TransitionValues}. 85d6107a3170df61d9e776fcd5666acfc9135c6f16George Mount */ 86d6107a3170df61d9e776fcd5666acfc9135c6f16George Mount public abstract String[] getPropagationProperties() ; 87d6107a3170df61d9e776fcd5666acfc9135c6f16George Mount} 88