summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author George Mount <mount@google.com> 2016-11-29 11:36:17 -0800
committer George Mount <mount@google.com> 2016-11-29 12:43:05 -0800
commit0c3ab75c6a9da73043cd345d05a3d1e47c455e69 (patch)
treeb88f44af2b2a62c81ac065e64996a15d6c169b66
parent1dddc057ec9e7450466d1e871a703fc285aff8e9 (diff)
Don't change visibility of fragment Views that aren't visible
Bug 32864127 When a fragment creates a view that is either invisible or gone, it should remain that way. This means that the fragment won't have any animations. When transactions are optimized, transitions will avoid invisible and gone fragment views, but unoptimized transactions will lead to failed transitions because none of the views will be visible. Test: Ie71902d1b5f5f647c758a1bd60cdfd6814cda29d Change-Id: If952f81859227a28569d234d8232ff6bb100e74c
-rw-r--r--core/java/android/app/FragmentManager.java6
1 files changed, 4 insertions, 2 deletions
diff --git a/core/java/android/app/FragmentManager.java b/core/java/android/app/FragmentManager.java
index 9ea3f83992cb..92ba4408b5ce 100644
--- a/core/java/android/app/FragmentManager.java
+++ b/core/java/android/app/FragmentManager.java
@@ -1175,15 +1175,17 @@ final class FragmentManagerImpl extends FragmentManager implements LayoutInflate
f.mView.setSaveFromParentEnabled(false);
if (container != null) {
container.addView(f.mView);
- f.mIsNewlyAdded = true;
}
if (f.mHidden) {
f.mView.setVisibility(View.GONE);
- f.mIsNewlyAdded = false; // No animation required
}
f.onViewCreated(f.mView, f.mSavedFragmentState);
dispatchOnFragmentViewCreated(f, f.mView, f.mSavedFragmentState,
false);
+ // Only animate the view if it is visible. This is done after
+ // dispatchOnFragmentViewCreated in case visibility is changed
+ f.mIsNewlyAdded = (f.mView.getVisibility() == View.VISIBLE)
+ && f.mContainer != null;
}
}