/* * Copyright (C) 2016 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package android.support.transition; import android.os.Build; import android.support.annotation.NonNull; import android.support.annotation.Nullable; import android.view.ViewGroup; /** * This class manages the set of transitions that fire when there is a * change of {@link Scene}. To use the manager, add scenes along with * transition objects with calls to {@link #setTransition(Scene, Transition)} * or {@link #setTransition(Scene, Scene, Transition)}. Setting specific * transitions for scene changes is not required; by default, a Scene change * will use {@link AutoTransition} to do something reasonable for most * situations. Specifying other transitions for particular scene changes is * only necessary if the application wants different transition behavior * in these situations. * *
Unlike the platform version, this does not support declaration by XML resources.
*/ public class TransitionManager { private static TransitionManagerStaticsImpl sImpl; static { if (Build.VERSION.SDK_INT < 19) { sImpl = new TransitionManagerStaticsIcs(); } else { sImpl = new TransitionManagerStaticsKitKat(); } } private TransitionManagerImpl mImpl; public TransitionManager() { if (Build.VERSION.SDK_INT < 19) { mImpl = new TransitionManagerIcs(); } else { mImpl = new TransitionManagerKitKat(); } } /** * Convenience method to simply change to the given scene using * the default transition for TransitionManager. * * @param scene The Scene to change to */ public static void go(@NonNull Scene scene) { sImpl.go(scene.mImpl); } /** * Convenience method to simply change to the given scene using * the given transition. * *Passing in null
for the transition parameter will
* result in the scene changing without any transition running, and is
* equivalent to calling {@link Scene#exit()} on the scene root's
* current scene, followed by {@link Scene#enter()} on the scene
* specified by the scene
parameter.
null
for the transition
parameter.
*
* @param sceneRoot The root of the View hierarchy to run the transition on.
*/
public static void beginDelayedTransition(@NonNull final ViewGroup sceneRoot) {
sImpl.beginDelayedTransition(sceneRoot);
}
/**
* Convenience method to animate to a new scene defined by all changes within
* the given scene root between calling this method and the next rendering frame.
* Calling this method causes TransitionManager to capture current values in the
* scene root and then post a request to run a transition on the next frame.
* At that time, the new values in the scene root will be captured and changes
* will be animated. There is no need to create a Scene; it is implied by
* changes which take place between calling this method and the next frame when
* the transition begins.
*
* Calling this method several times before the next frame (for example, if * unrelated code also wants to make dynamic changes and run a transition on * the same scene root), only the first call will trigger capturing values * and exiting the current scene. Subsequent calls to the method with the * same scene root during the same frame will be ignored.
* *Passing in null
for the transition parameter will
* cause the TransitionManager to use its default transition.