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

Commit 67cbbfe0 authored by Sergey Vasilinets's avatar Sergey Vasilinets Committed by android-build-merger
Browse files

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

am: ce8a4b89

Change-Id: I755b0f38c907d1ae7bf12df67f4b10590a9016bf
parents 2105d8f1 ce8a4b89
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);
                    }
                }
            }