From f10587faadb9080a7bf9991cbe04bac5525da482 Mon Sep 17 00:00:00 2001 From: George Mount Date: Thu, 6 Feb 2014 14:12:53 -0800 Subject: Change Activity Scene Transitions to be more automatic. Shared element transitions are enabled by default when the Window has a TransitionManager. Shared element location and size are captured and transferred to the target Activity. ActionBar is treated as a shared element. Change-Id: I0f22ea4e5cbe80254e848444e3f235cb742684f4 --- .../android/transition/TransitionInflater.java | 43 ++++++---------------- 1 file changed, 12 insertions(+), 31 deletions(-) (limited to 'core/java/android/transition/TransitionInflater.java') diff --git a/core/java/android/transition/TransitionInflater.java b/core/java/android/transition/TransitionInflater.java index 9fa554c3b3a6..912f2ed88962 100644 --- a/core/java/android/transition/TransitionInflater.java +++ b/core/java/android/transition/TransitionInflater.java @@ -285,46 +285,27 @@ public class TransitionInflater { com.android.internal.R.styleable.TransitionManager); int transitionId = a.getResourceId( com.android.internal.R.styleable.TransitionManager_transition, -1); - Scene fromScene = null, toScene = null; int fromId = a.getResourceId( com.android.internal.R.styleable.TransitionManager_fromScene, -1); - if (fromId >= 0) fromScene = Scene.getSceneForLayout(sceneRoot, fromId, mContext); + Scene fromScene = (fromId < 0) ? null: Scene.getSceneForLayout(sceneRoot, fromId, mContext); int toId = a.getResourceId( com.android.internal.R.styleable.TransitionManager_toScene, -1); - if (toId >= 0) toScene = Scene.getSceneForLayout(sceneRoot, toId, mContext); - String fromName = a.getString( - com.android.internal.R.styleable.TransitionManager_fromSceneName); - String toName = a.getString( - com.android.internal.R.styleable.TransitionManager_toSceneName); + Scene toScene = (toId < 0) ? null : Scene.getSceneForLayout(sceneRoot, toId, mContext); + if (transitionId >= 0) { Transition transition = inflateTransition(transitionId); if (transition != null) { - if (fromScene != null) { - boolean hasDest = false; - if (toScene != null) { - transitionManager.setTransition(fromScene, toScene, transition); - hasDest = true; - } - - if (!TextUtils.isEmpty(toName)) { - transitionManager.setTransition(fromScene, toName, transition); - hasDest = true; - } - - if (!hasDest) { - throw new RuntimeException("No matching toScene or toSceneName for given " + - "fromScene for transition ID " + transitionId); - } - } else if (toId >= 0) { - transitionManager.setTransition(toScene, transition); - } - if (fromName != null) { - if (toScene != null) { - transitionManager.setTransition(fromName, toScene, transition); - } else { - throw new RuntimeException("No matching toScene for given fromSceneName " + + if (fromScene == null) { + if (toScene == null) { + throw new RuntimeException("No matching fromScene or toScene " + "for transition ID " + transitionId); + } else { + transitionManager.setTransition(toScene, transition); } + } else if (toScene == null) { + transitionManager.setExitTransition(fromScene, transition); + } else { + transitionManager.setTransition(fromScene, toScene, transition); } } } -- cgit v1.2.3