Give transitioning fragment a context prior to retrieving transition
Bug 23688972 An incoming fragment that is going to execute a transition may need to have a context in order to load the transition. This CL moves the state of incoming fragments to CREATED prior to getting their Transitions. Change-Id: I08b8cda479f7542fb326aa4f0f62a07ccc5662b0
This commit is contained in:
@@ -957,6 +957,7 @@ final class BackStackRecord extends FragmentTransaction implements
|
||||
*/
|
||||
private TransitionState beginTransition(SparseArray<Fragment> firstOutFragments,
|
||||
SparseArray<Fragment> lastInFragments, boolean isBack) {
|
||||
ensureFragmentsAreInitialized(lastInFragments);
|
||||
TransitionState state = new TransitionState();
|
||||
|
||||
// Adding a non-existent target view makes sure that the transitions don't target
|
||||
@@ -982,6 +983,20 @@ final class BackStackRecord extends FragmentTransaction implements
|
||||
return state;
|
||||
}
|
||||
|
||||
/**
|
||||
* Ensure that fragments that are entering are at least at the CREATED state
|
||||
* so that they may load Transitions using TransitionInflater.
|
||||
*/
|
||||
private void ensureFragmentsAreInitialized(SparseArray<Fragment> lastInFragments) {
|
||||
final int count = lastInFragments.size();
|
||||
for (int i = 0; i < count; i++) {
|
||||
final Fragment fragment = lastInFragments.valueAt(i);
|
||||
if (fragment.mState < Fragment.CREATED) {
|
||||
mManager.moveToState(fragment, Fragment.CREATED, 0, 0, false);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static Transition cloneTransition(Transition transition) {
|
||||
if (transition != null) {
|
||||
transition = transition.clone();
|
||||
|
||||
Reference in New Issue
Block a user