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
This commit is contained in:
George Mount
2016-11-29 11:36:17 -08:00
parent 1dddc057ec
commit 0c3ab75c6a

View File

@@ -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;
}
}