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

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

Merge "Fix Fragment.onCreate() not being called in some cases."

parents 25cefd10 15c21ffa
Loading
Loading
Loading
Loading
+7 −1
Original line number Diff line number Diff line
@@ -42,7 +42,6 @@ import android.util.AndroidRuntimeException;
import android.util.ArrayMap;
import android.util.AttributeSet;
import android.util.DebugUtils;
import android.util.Log;
import android.util.SparseArray;
import android.util.SuperNotCalledException;
import android.view.ContextMenu;
@@ -406,6 +405,11 @@ public class Fragment implements ComponentCallbacks2, OnCreateContextMenuListene
    // getLayoutInflater()
    LayoutInflater mLayoutInflater;

    // Keep track of whether or not this Fragment has run performCreate(). Retained instance
    // fragments can have mRetaining set to true without going through creation, so we must
    // track it separately.
    boolean mIsCreated;

    /**
     * State information that has been retrieved from a fragment instance
     * through {@link FragmentManager#saveFragmentInstanceState(Fragment)
@@ -2483,6 +2487,7 @@ public class Fragment implements ComponentCallbacks2, OnCreateContextMenuListene
        mState = CREATED;
        mCalled = false;
        onCreate(savedInstanceState);
        mIsCreated = true;
        if (!mCalled) {
            throw new SuperNotCalledException("Fragment " + this
                    + " did not call through to super.onCreate()");
@@ -2759,6 +2764,7 @@ public class Fragment implements ComponentCallbacks2, OnCreateContextMenuListene
        }
        mState = INITIALIZING;
        mCalled = false;
        mIsCreated = false;
        onDestroy();
        if (!mCalled) {
            throw new SuperNotCalledException("Fragment " + this
+1 −1
Original line number Diff line number Diff line
@@ -1232,7 +1232,7 @@ final class FragmentManagerImpl extends FragmentManager implements LayoutInflate
                        }
                        dispatchOnFragmentAttached(f, mHost.getContext(), false);

                        if (!f.mRetaining) {
                        if (!f.mIsCreated) {
                            dispatchOnFragmentPreCreated(f, f.mSavedFragmentState, false);
                            f.performCreate(f.mSavedFragmentState);
                            dispatchOnFragmentCreated(f, f.mSavedFragmentState, false);