14c904b38c763179727b9b5ea7a80454630545663Yuichi Araki/*
24c904b38c763179727b9b5ea7a80454630545663Yuichi Araki * Copyright (C) 2017 The Android Open Source Project
34c904b38c763179727b9b5ea7a80454630545663Yuichi Araki *
44c904b38c763179727b9b5ea7a80454630545663Yuichi Araki * Licensed under the Apache License, Version 2.0 (the "License");
54c904b38c763179727b9b5ea7a80454630545663Yuichi Araki * you may not use this file except in compliance with the License.
64c904b38c763179727b9b5ea7a80454630545663Yuichi Araki * You may obtain a copy of the License at
74c904b38c763179727b9b5ea7a80454630545663Yuichi Araki *
84c904b38c763179727b9b5ea7a80454630545663Yuichi Araki *      http://www.apache.org/licenses/LICENSE-2.0
94c904b38c763179727b9b5ea7a80454630545663Yuichi Araki *
104c904b38c763179727b9b5ea7a80454630545663Yuichi Araki * Unless required by applicable law or agreed to in writing, software
114c904b38c763179727b9b5ea7a80454630545663Yuichi Araki * distributed under the License is distributed on an "AS IS" BASIS,
124c904b38c763179727b9b5ea7a80454630545663Yuichi Araki * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
134c904b38c763179727b9b5ea7a80454630545663Yuichi Araki * See the License for the specific language governing permissions and
144c904b38c763179727b9b5ea7a80454630545663Yuichi Araki * limitations under the License.
154c904b38c763179727b9b5ea7a80454630545663Yuichi Araki */
164c904b38c763179727b9b5ea7a80454630545663Yuichi Araki
174c904b38c763179727b9b5ea7a80454630545663Yuichi Arakipackage android.support.transition;
184c904b38c763179727b9b5ea7a80454630545663Yuichi Araki
194c904b38c763179727b9b5ea7a80454630545663Yuichi Arakiimport android.view.ViewGroup;
204c904b38c763179727b9b5ea7a80454630545663Yuichi Araki
214c904b38c763179727b9b5ea7a80454630545663Yuichi Araki/**
224c904b38c763179727b9b5ea7a80454630545663Yuichi Araki * Extend <code>TransitionPropagation</code> to customize start delays for Animators created
234c904b38c763179727b9b5ea7a80454630545663Yuichi Araki * in {@link Transition#createAnimator(ViewGroup, TransitionValues, TransitionValues)}.
244c904b38c763179727b9b5ea7a80454630545663Yuichi Araki * A Transition such as {@link Explode} defaults to using {@link CircularPropagation} and Views
254c904b38c763179727b9b5ea7a80454630545663Yuichi Araki * closer to the epicenter will move out of the scene later and into the scene sooner than Views
264c904b38c763179727b9b5ea7a80454630545663Yuichi Araki * farther from the epicenter, giving the appearance of inertia. With no TransitionPropagation, all
274c904b38c763179727b9b5ea7a80454630545663Yuichi Araki * Views will react simultaneously to the start of the transition.
284c904b38c763179727b9b5ea7a80454630545663Yuichi Araki *
294c904b38c763179727b9b5ea7a80454630545663Yuichi Araki * @see Transition#setPropagation(TransitionPropagation)
304c904b38c763179727b9b5ea7a80454630545663Yuichi Araki * @see Transition#getEpicenter()
314c904b38c763179727b9b5ea7a80454630545663Yuichi Araki */
324c904b38c763179727b9b5ea7a80454630545663Yuichi Arakipublic abstract class TransitionPropagation {
334c904b38c763179727b9b5ea7a80454630545663Yuichi Araki
344c904b38c763179727b9b5ea7a80454630545663Yuichi Araki    /**
354c904b38c763179727b9b5ea7a80454630545663Yuichi Araki     * Called by Transition to alter the Animator start delay. All start delays will be adjusted
364c904b38c763179727b9b5ea7a80454630545663Yuichi Araki     * such that the minimum becomes zero.
374c904b38c763179727b9b5ea7a80454630545663Yuichi Araki     *
384c904b38c763179727b9b5ea7a80454630545663Yuichi Araki     * @param sceneRoot   The root of the View hierarchy running the transition.
394c904b38c763179727b9b5ea7a80454630545663Yuichi Araki     * @param transition  The transition that created the Animator
404c904b38c763179727b9b5ea7a80454630545663Yuichi Araki     * @param startValues The values for a specific target in the start scene.
414c904b38c763179727b9b5ea7a80454630545663Yuichi Araki     * @param endValues   The values for the target in the end scene.
424c904b38c763179727b9b5ea7a80454630545663Yuichi Araki     * @return A start delay to use with the Animator created by <code>transition</code>. The
434c904b38c763179727b9b5ea7a80454630545663Yuichi Araki     * delay will be offset by the minimum delay of all <code>TransitionPropagation</code>s
444c904b38c763179727b9b5ea7a80454630545663Yuichi Araki     * used in the Transition so that the smallest delay will be 0. Returned values may be
454c904b38c763179727b9b5ea7a80454630545663Yuichi Araki     * negative.
464c904b38c763179727b9b5ea7a80454630545663Yuichi Araki     */
474c904b38c763179727b9b5ea7a80454630545663Yuichi Araki    public abstract long getStartDelay(ViewGroup sceneRoot, Transition transition,
484c904b38c763179727b9b5ea7a80454630545663Yuichi Araki            TransitionValues startValues, TransitionValues endValues);
494c904b38c763179727b9b5ea7a80454630545663Yuichi Araki
504c904b38c763179727b9b5ea7a80454630545663Yuichi Araki    /**
514c904b38c763179727b9b5ea7a80454630545663Yuichi Araki     * Captures the values in the start or end scene for the properties that this
524c904b38c763179727b9b5ea7a80454630545663Yuichi Araki     * transition propagation monitors. These values are then passed as the startValues
534c904b38c763179727b9b5ea7a80454630545663Yuichi Araki     * or endValues structure in a later call to
544c904b38c763179727b9b5ea7a80454630545663Yuichi Araki     * {@link #getStartDelay(ViewGroup, Transition, TransitionValues, TransitionValues)}.
554c904b38c763179727b9b5ea7a80454630545663Yuichi Araki     * The main concern for an implementation is what the
564c904b38c763179727b9b5ea7a80454630545663Yuichi Araki     * properties are that the transition cares about and what the values are
574c904b38c763179727b9b5ea7a80454630545663Yuichi Araki     * for all of those properties. The start and end values will be compared
584c904b38c763179727b9b5ea7a80454630545663Yuichi Araki     * later during the
594c904b38c763179727b9b5ea7a80454630545663Yuichi Araki     * {@link #getStartDelay(ViewGroup, Transition, TransitionValues, TransitionValues)}.
604c904b38c763179727b9b5ea7a80454630545663Yuichi Araki     * method to determine the start delay.
614c904b38c763179727b9b5ea7a80454630545663Yuichi Araki     *
624c904b38c763179727b9b5ea7a80454630545663Yuichi Araki     * <p>Subclasses must implement this method. The method should only be called by the
634c904b38c763179727b9b5ea7a80454630545663Yuichi Araki     * transition system; it is not intended to be called from external classes.</p>
644c904b38c763179727b9b5ea7a80454630545663Yuichi Araki     *
654c904b38c763179727b9b5ea7a80454630545663Yuichi Araki     * @param transitionValues The holder for any values that the Transition
664c904b38c763179727b9b5ea7a80454630545663Yuichi Araki     *                         wishes to store. Values are stored in the <code>values</code> field
674c904b38c763179727b9b5ea7a80454630545663Yuichi Araki     *                         of this TransitionValues object and are keyed from
684c904b38c763179727b9b5ea7a80454630545663Yuichi Araki     *                         a String value. For example, to store a view's rotation value,
694c904b38c763179727b9b5ea7a80454630545663Yuichi Araki     *                         a transition might call
704c904b38c763179727b9b5ea7a80454630545663Yuichi Araki     *                         <code>transitionValues.values.put("appname:transitionname:rotation",
714c904b38c763179727b9b5ea7a80454630545663Yuichi Araki     *                         view.getRotation())</code>. The target view will already be stored
724c904b38c763179727b9b5ea7a80454630545663Yuichi Araki     *                         in
734c904b38c763179727b9b5ea7a80454630545663Yuichi Araki     *                         the transitionValues structure when this method is called.
744c904b38c763179727b9b5ea7a80454630545663Yuichi Araki     */
754c904b38c763179727b9b5ea7a80454630545663Yuichi Araki    public abstract void captureValues(TransitionValues transitionValues);
764c904b38c763179727b9b5ea7a80454630545663Yuichi Araki
774c904b38c763179727b9b5ea7a80454630545663Yuichi Araki    /**
784c904b38c763179727b9b5ea7a80454630545663Yuichi Araki     * Returns the set of property names stored in the {@link TransitionValues}
794c904b38c763179727b9b5ea7a80454630545663Yuichi Araki     * object passed into {@link #captureValues(TransitionValues)} that
804c904b38c763179727b9b5ea7a80454630545663Yuichi Araki     * this transition propagation cares about for the purposes of preventing
814c904b38c763179727b9b5ea7a80454630545663Yuichi Araki     * duplicate capturing of property values.
824c904b38c763179727b9b5ea7a80454630545663Yuichi Araki     *
834c904b38c763179727b9b5ea7a80454630545663Yuichi Araki     * <p>A <code>TransitionPropagation</code> must override this method to prevent
844c904b38c763179727b9b5ea7a80454630545663Yuichi Araki     * duplicate capturing of values and must contain at least one </p>
854c904b38c763179727b9b5ea7a80454630545663Yuichi Araki     *
864c904b38c763179727b9b5ea7a80454630545663Yuichi Araki     * @return An array of property names as described in the class documentation for
874c904b38c763179727b9b5ea7a80454630545663Yuichi Araki     * {@link TransitionValues}.
884c904b38c763179727b9b5ea7a80454630545663Yuichi Araki     */
894c904b38c763179727b9b5ea7a80454630545663Yuichi Araki    public abstract String[] getPropagationProperties();
904c904b38c763179727b9b5ea7a80454630545663Yuichi Araki
914c904b38c763179727b9b5ea7a80454630545663Yuichi Araki}
92