OSDN Git Service

fix NPE when fragment container is null
authorGeorge Mount <mount@google.com>
Thu, 20 Apr 2017 20:16:52 +0000 (13:16 -0700)
committerGeorge Mount <mount@google.com>
Thu, 20 Apr 2017 20:17:30 +0000 (13:17 -0700)
Bug 37529822

Test: ran against breaking application

Change-Id: Ib829b817eddf2e91898989a2f9e7885a6f5847e5

core/java/android/app/FragmentManager.java

index c1161a2..b6a578b 100644 (file)
@@ -1464,13 +1464,17 @@ final class FragmentManagerImpl extends FragmentManager implements LayoutInflate
                     } else {
                         final ViewGroup container = fragment.mContainer;
                         final View animatingView = fragment.mView;
-                        container.startViewTransition(animatingView);
+                        if (container != null) {
+                            container.startViewTransition(animatingView);
+                        }
                         // Delay the actual hide operation until the animation finishes, otherwise
                         // the fragment will just immediately disappear
                         anim.addListener(new AnimatorListenerAdapter() {
                             @Override
                             public void onAnimationEnd(Animator animation) {
-                                container.endViewTransition(animatingView);
+                                if (container != null) {
+                                    container.endViewTransition(animatingView);
+                                }
                                 animation.removeListener(this);
                                 animatingView.setVisibility(View.GONE);
                             }