Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit ce8a4b89 authored by Sergey Vasilinets's avatar Sergey Vasilinets Committed by Android (Google) Code Review
Browse files

Merge "Correctly save retained fragments in the backstack" into oc-dev

parents 6441e106 be6f5042
Loading
Loading
Loading
Loading
+15 −13
Original line number Diff line number Diff line
@@ -2603,23 +2603,25 @@ final class FragmentManagerImpl extends FragmentManager implements LayoutInflate
                        f.mTargetIndex = f.mTarget != null ? f.mTarget.mIndex : -1;
                        if (DEBUG) Log.v(TAG, "retainNonConfig: keeping retained " + f);
                    }
                    boolean addedChild = false;
                    FragmentManagerNonConfig child;
                    if (f.mChildFragmentManager != null) {
                        f.mChildFragmentManager.saveNonConfig();
                        FragmentManagerNonConfig child = f.mChildFragmentManager.mSavedNonConfig;
                        if (child != null) {
                            if (childFragments == null) {
                                childFragments = new ArrayList<>();
                        child = f.mChildFragmentManager.mSavedNonConfig;
                    } else {
                        // f.mChildNonConfig may be not null, when the parent fragment is
                        // in the backstack.
                        child = f.mChildNonConfig;
                    }

                    if (childFragments == null && child != null) {
                        childFragments = new ArrayList<>(mActive.size());
                        for (int j = 0; j < i; j++) {
                            childFragments.add(null);
                        }
                    }

                    if (childFragments != null) {
                        childFragments.add(child);
                            addedChild = true;
                        }
                    }
                    if (childFragments != null && !addedChild) {
                        childFragments.add(null);
                    }
                }
            }