OSDN Git Service

Ensure feature flags are set prior to checking Activity Transition.
authorGeorge Mount <mount@google.com>
Wed, 9 Sep 2015 19:45:55 +0000 (12:45 -0700)
committerGeorge Mount <mount@google.com>
Wed, 9 Sep 2015 19:45:55 +0000 (12:45 -0700)
Bug 23764120

Window features are set in PhoneWindow.installDecor. The Activity
Transition feature is checked after onCreate. If the developer
hasn't accessed the decor View in onCreate, the Activity Transition
feature will not have been set prior to checking it. To correct
this, the decor View will be forced to be created prior to
checking the Activity Transition feature state.

Change-Id: I2c756b6736ae7f3a346f4f9bcef6936371ff03c5

core/java/android/app/ActivityTransitionState.java

index 5c6fe46..38562da 100644 (file)
@@ -150,7 +150,13 @@ class ActivityTransitionState {
     }
 
     public void setEnterActivityOptions(Activity activity, ActivityOptions options) {
-        if (activity.getWindow().hasFeature(Window.FEATURE_ACTIVITY_TRANSITIONS)
+        final Window window = activity.getWindow();
+        if (window == null) {
+            return;
+        }
+        // ensure Decor View has been created so that the window features are activated
+        window.getDecorView();
+        if (window.hasFeature(Window.FEATURE_ACTIVITY_TRANSITIONS)
                 && options != null && mEnterActivityOptions == null
                 && mEnterTransitionCoordinator == null
                 && options.getAnimationType() == ActivityOptions.ANIM_SCENE_TRANSITION) {