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

Commit 467cc6f0 authored by Adam Powell's avatar Adam Powell
Browse files

Less lazy child FragmentManager creation

Framework edition

Fix a bug where child FragmentManagers moving too lazily into the
CREATED state and beyond caused child fragments to not be
attached/created when expected.

Bug 25019275

Change-Id: I04ff0d3bcb693178a6ee3057da591392defdbcf8
parent 8b3cb1b2
Loading
Loading
Loading
Loading
+4 −0
Original line number Diff line number Diff line
@@ -1486,6 +1486,10 @@ public class Fragment implements ComponentCallbacks2, OnCreateContextMenuListene
        final int version = context != null ? context.getApplicationInfo().targetSdkVersion : 0;
        if (version >= Build.VERSION_CODES.N) {
            restoreChildFragmentState(savedInstanceState, true);
            if (mChildFragmentManager != null
                    && !mChildFragmentManager.isStateAtLeast(Fragment.CREATED)) {
                mChildFragmentManager.dispatchCreate();
            }
        }
    }

+4 −0
Original line number Diff line number Diff line
@@ -870,6 +870,10 @@ final class FragmentManagerImpl extends FragmentManager implements LayoutInflate
        }
    }

    boolean isStateAtLeast(int state) {
        return mCurState >= state;
    }

    void moveToState(Fragment f, int newState, int transit, int transitionStyle,
            boolean keepActive) {
        if (DEBUG && false) Log.v(TAG, "moveToState: " + f