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

Commit 5feafb1f authored by TreeHugger Robot's avatar TreeHugger Robot Committed by Android (Google) Code Review
Browse files

Merge "Properly track fragments from pop operations."

parents ce29c76a 99c532d0
Loading
Loading
Loading
Loading
+24 −1
Original line number Diff line number Diff line
@@ -807,7 +807,7 @@ final class BackStackRecord extends FragmentTransaction implements
                default:
                    throw new IllegalArgumentException("Unknown cmd: " + op.cmd);
            }
            if (!mAllowOptimization && op.cmd != OP_ADD) {
            if (!mAllowOptimization && op.cmd != OP_REMOVE) {
                mManager.moveFragmentToExpectedState(f);
            }
        }
@@ -873,6 +873,29 @@ final class BackStackRecord extends FragmentTransaction implements
        }
    }

    /**
     * Removes fragments that are added or removed during a pop operation.
     *
     * @param added Initialized to the fragments that are in the mManager.mAdded, this
     *              will be modified to contain the fragments that will be in mAdded
     *              after the execution ({@link #executeOps()}.
     */
    void trackAddedFragmentsInPop(ArrayList<Fragment> added) {
        for (int opNum = 0; opNum < mOps.size(); opNum++) {
            final Op op = mOps.get(opNum);
            switch (op.cmd) {
                case OP_ADD:
                case OP_ATTACH:
                    added.remove(op.fragment);
                    break;
                case OP_REMOVE:
                case OP_DETACH:
                    added.add(op.fragment);
                    break;
            }
        }
    }

    boolean isPostponed() {
        for (int opNum = 0; opNum < mOps.size(); opNum++) {
            final Op op = mOps.get(opNum);
+2 −0
Original line number Diff line number Diff line
@@ -2026,6 +2026,8 @@ final class FragmentManagerImpl extends FragmentManager implements LayoutInflate
            final boolean isPop = isRecordPop.get(recordNum);
            if (!isPop) {
                record.expandReplaceOps(mTmpAddedFragments);
            } else {
                record.trackAddedFragmentsInPop(mTmpAddedFragments);
            }
            final int bumpAmount = isPop ? -1 : 1;
            record.bumpBackStackNesting(bumpAmount);