TransitionHelperKitkat.java revision 9240e796bc63422c28f2707840bd99c48573279b
155c9ee4b612ffc7b4632b1e4b7b7ab4900cd47c7Craig Stout/* 255c9ee4b612ffc7b4632b1e4b7b7ab4900cd47c7Craig Stout * Copyright (C) 2014 The Android Open Source Project 355c9ee4b612ffc7b4632b1e4b7b7ab4900cd47c7Craig Stout * 455c9ee4b612ffc7b4632b1e4b7b7ab4900cd47c7Craig Stout * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except 555c9ee4b612ffc7b4632b1e4b7b7ab4900cd47c7Craig Stout * in compliance with the License. You may obtain a copy of the License at 655c9ee4b612ffc7b4632b1e4b7b7ab4900cd47c7Craig Stout * 755c9ee4b612ffc7b4632b1e4b7b7ab4900cd47c7Craig Stout * http://www.apache.org/licenses/LICENSE-2.0 855c9ee4b612ffc7b4632b1e4b7b7ab4900cd47c7Craig Stout * 955c9ee4b612ffc7b4632b1e4b7b7ab4900cd47c7Craig Stout * Unless required by applicable law or agreed to in writing, software distributed under the License 1055c9ee4b612ffc7b4632b1e4b7b7ab4900cd47c7Craig Stout * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 1155c9ee4b612ffc7b4632b1e4b7b7ab4900cd47c7Craig Stout * or implied. See the License for the specific language governing permissions and limitations under 1255c9ee4b612ffc7b4632b1e4b7b7ab4900cd47c7Craig Stout * the License. 1355c9ee4b612ffc7b4632b1e4b7b7ab4900cd47c7Craig Stout */ 1455c9ee4b612ffc7b4632b1e4b7b7ab4900cd47c7Craig Stoutpackage android.support.v17.leanback.app; 1555c9ee4b612ffc7b4632b1e4b7b7ab4900cd47c7Craig Stout 1655c9ee4b612ffc7b4632b1e4b7b7ab4900cd47c7Craig Stoutimport android.content.Context; 179240e796bc63422c28f2707840bd99c48573279bDake Guimport android.transition.AutoTransition; 1855c9ee4b612ffc7b4632b1e4b7b7ab4900cd47c7Craig Stoutimport android.transition.Scene; 1955c9ee4b612ffc7b4632b1e4b7b7ab4900cd47c7Craig Stoutimport android.transition.Transition; 2055c9ee4b612ffc7b4632b1e4b7b7ab4900cd47c7Craig Stoutimport android.transition.TransitionManager; 219240e796bc63422c28f2707840bd99c48573279bDake Guimport android.view.View; 2255c9ee4b612ffc7b4632b1e4b7b7ab4900cd47c7Craig Stoutimport android.view.ViewGroup; 2355c9ee4b612ffc7b4632b1e4b7b7ab4900cd47c7Craig Stout 2455c9ee4b612ffc7b4632b1e4b7b7ab4900cd47c7Craig Stoutclass TransitionHelperKitkat { 2555c9ee4b612ffc7b4632b1e4b7b7ab4900cd47c7Craig Stout private final Context mContext; 2655c9ee4b612ffc7b4632b1e4b7b7ab4900cd47c7Craig Stout 2755c9ee4b612ffc7b4632b1e4b7b7ab4900cd47c7Craig Stout TransitionHelperKitkat(Context context) { 2855c9ee4b612ffc7b4632b1e4b7b7ab4900cd47c7Craig Stout mContext = context; 2955c9ee4b612ffc7b4632b1e4b7b7ab4900cd47c7Craig Stout } 3055c9ee4b612ffc7b4632b1e4b7b7ab4900cd47c7Craig Stout 319240e796bc63422c28f2707840bd99c48573279bDake Gu Object createScene(ViewGroup sceneRoot, Runnable enterAction) { 3255c9ee4b612ffc7b4632b1e4b7b7ab4900cd47c7Craig Stout Scene scene = new Scene(sceneRoot); 339240e796bc63422c28f2707840bd99c48573279bDake Gu scene.setEnterAction(enterAction); 349240e796bc63422c28f2707840bd99c48573279bDake Gu return scene; 3555c9ee4b612ffc7b4632b1e4b7b7ab4900cd47c7Craig Stout } 3655c9ee4b612ffc7b4632b1e4b7b7ab4900cd47c7Craig Stout 379240e796bc63422c28f2707840bd99c48573279bDake Gu Object createAutoTransition() { 389240e796bc63422c28f2707840bd99c48573279bDake Gu return new AutoTransition(); 399240e796bc63422c28f2707840bd99c48573279bDake Gu } 409240e796bc63422c28f2707840bd99c48573279bDake Gu 419240e796bc63422c28f2707840bd99c48573279bDake Gu void excludeChildren(Object transition, int targetId, boolean exclude) { 429240e796bc63422c28f2707840bd99c48573279bDake Gu ((Transition) transition).excludeChildren(targetId, exclude); 439240e796bc63422c28f2707840bd99c48573279bDake Gu } 449240e796bc63422c28f2707840bd99c48573279bDake Gu 459240e796bc63422c28f2707840bd99c48573279bDake Gu void excludeChildren(Object transition, View targetView, boolean exclude) { 469240e796bc63422c28f2707840bd99c48573279bDake Gu ((Transition) transition).excludeChildren(targetView, exclude); 479240e796bc63422c28f2707840bd99c48573279bDake Gu } 489240e796bc63422c28f2707840bd99c48573279bDake Gu 499240e796bc63422c28f2707840bd99c48573279bDake Gu public void setTransitionCompleteListener(Object transition, Runnable listener) { 509240e796bc63422c28f2707840bd99c48573279bDake Gu Transition t = (Transition) transition; 519240e796bc63422c28f2707840bd99c48573279bDake Gu final Runnable completeListener = listener; 529240e796bc63422c28f2707840bd99c48573279bDake Gu t.addListener(new Transition.TransitionListener() { 539240e796bc63422c28f2707840bd99c48573279bDake Gu 549240e796bc63422c28f2707840bd99c48573279bDake Gu @Override 559240e796bc63422c28f2707840bd99c48573279bDake Gu public void onTransitionStart(Transition transition) { 569240e796bc63422c28f2707840bd99c48573279bDake Gu } 579240e796bc63422c28f2707840bd99c48573279bDake Gu 589240e796bc63422c28f2707840bd99c48573279bDake Gu @Override 599240e796bc63422c28f2707840bd99c48573279bDake Gu public void onTransitionResume(Transition transition) { 609240e796bc63422c28f2707840bd99c48573279bDake Gu } 619240e796bc63422c28f2707840bd99c48573279bDake Gu 629240e796bc63422c28f2707840bd99c48573279bDake Gu @Override 639240e796bc63422c28f2707840bd99c48573279bDake Gu public void onTransitionPause(Transition transition) { 649240e796bc63422c28f2707840bd99c48573279bDake Gu } 659240e796bc63422c28f2707840bd99c48573279bDake Gu 669240e796bc63422c28f2707840bd99c48573279bDake Gu @Override 679240e796bc63422c28f2707840bd99c48573279bDake Gu public void onTransitionEnd(Transition transition) { 689240e796bc63422c28f2707840bd99c48573279bDake Gu completeListener.run(); 699240e796bc63422c28f2707840bd99c48573279bDake Gu } 709240e796bc63422c28f2707840bd99c48573279bDake Gu 719240e796bc63422c28f2707840bd99c48573279bDake Gu @Override 729240e796bc63422c28f2707840bd99c48573279bDake Gu public void onTransitionCancel(Transition transition) { 739240e796bc63422c28f2707840bd99c48573279bDake Gu } 749240e796bc63422c28f2707840bd99c48573279bDake Gu }); 759240e796bc63422c28f2707840bd99c48573279bDake Gu } 769240e796bc63422c28f2707840bd99c48573279bDake Gu 779240e796bc63422c28f2707840bd99c48573279bDake Gu void runTransition(Object scene, Object transition) { 789240e796bc63422c28f2707840bd99c48573279bDake Gu TransitionManager.go((Scene) scene, (Transition) transition); 7955c9ee4b612ffc7b4632b1e4b7b7ab4900cd47c7Craig Stout } 8055c9ee4b612ffc7b4632b1e4b7b7ab4900cd47c7Craig Stout} 81