diff options
| author | George Mount <mount@google.com> | 2014-02-06 14:12:53 -0800 |
|---|---|---|
| committer | George Mount <mount@google.com> | 2014-02-25 11:12:16 -0800 |
| commit | f10587faadb9080a7bf9991cbe04bac5525da482 (patch) | |
| tree | 61d5195d6d05d119c81bc75cfc659de4a7df5514 /core/java/android/transition/TransitionInflater.java | |
| parent | 875e2101d71afe7e4acf10b061c942fbf7294775 (diff) | |
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
Diffstat (limited to 'core/java/android/transition/TransitionInflater.java')
| -rw-r--r-- | core/java/android/transition/TransitionInflater.java | 43 |
1 files changed, 12 insertions, 31 deletions
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); } } } |
