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

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

Merge "Fragment grab bag!"

parents 2a382d3e adfd62c4
Loading
Loading
Loading
Loading
+2 −0
Original line number Diff line number Diff line
@@ -4516,6 +4516,7 @@ package android.app {
    method public final boolean isInLayout();
    method public final boolean isRemoving();
    method public final boolean isResumed();
    method public final boolean isStateSaved();
    method public final boolean isVisible();
    method public void onActivityCreated(android.os.Bundle);
    method public void onActivityResult(int, int, android.content.Intent);
@@ -4754,6 +4755,7 @@ package android.app {
    method public abstract android.app.FragmentTransaction hide(android.app.Fragment);
    method public abstract boolean isAddToBackStackAllowed();
    method public abstract boolean isEmpty();
    method public abstract android.app.FragmentTransaction postOnCommit(java.lang.Runnable);
    method public abstract android.app.FragmentTransaction remove(android.app.Fragment);
    method public abstract android.app.FragmentTransaction replace(int, android.app.Fragment);
    method public abstract android.app.FragmentTransaction replace(int, android.app.Fragment, java.lang.String);
+2 −0
Original line number Diff line number Diff line
@@ -4676,6 +4676,7 @@ package android.app {
    method public final boolean isInLayout();
    method public final boolean isRemoving();
    method public final boolean isResumed();
    method public final boolean isStateSaved();
    method public final boolean isVisible();
    method public void onActivityCreated(android.os.Bundle);
    method public void onActivityResult(int, int, android.content.Intent);
@@ -4914,6 +4915,7 @@ package android.app {
    method public abstract android.app.FragmentTransaction hide(android.app.Fragment);
    method public abstract boolean isAddToBackStackAllowed();
    method public abstract boolean isEmpty();
    method public abstract android.app.FragmentTransaction postOnCommit(java.lang.Runnable);
    method public abstract android.app.FragmentTransaction remove(android.app.Fragment);
    method public abstract android.app.FragmentTransaction replace(int, android.app.Fragment);
    method public abstract android.app.FragmentTransaction replace(int, android.app.Fragment, java.lang.String);
+2 −0
Original line number Diff line number Diff line
@@ -4526,6 +4526,7 @@ package android.app {
    method public final boolean isInLayout();
    method public final boolean isRemoving();
    method public final boolean isResumed();
    method public final boolean isStateSaved();
    method public final boolean isVisible();
    method public void onActivityCreated(android.os.Bundle);
    method public void onActivityResult(int, int, android.content.Intent);
@@ -4764,6 +4765,7 @@ package android.app {
    method public abstract android.app.FragmentTransaction hide(android.app.Fragment);
    method public abstract boolean isAddToBackStackAllowed();
    method public abstract boolean isEmpty();
    method public abstract android.app.FragmentTransaction postOnCommit(java.lang.Runnable);
    method public abstract android.app.FragmentTransaction remove(android.app.Fragment);
    method public abstract android.app.FragmentTransaction replace(int, android.app.Fragment);
    method public abstract android.app.FragmentTransaction replace(int, android.app.Fragment, java.lang.String);
+24 −0
Original line number Diff line number Diff line
@@ -220,6 +220,8 @@ final class BackStackRecord extends FragmentTransaction implements
    int mIndex = -1;
    boolean mAllowOptimization;

    ArrayList<Runnable> mCommitRunnables;

    int mBreadCrumbTitleRes;
    CharSequence mBreadCrumbTitleText;
    int mBreadCrumbShortTitleRes;
@@ -620,6 +622,28 @@ final class BackStackRecord extends FragmentTransaction implements
        }
    }

    @Override
    public FragmentTransaction postOnCommit(Runnable runnable) {
        if (runnable == null) {
            throw new IllegalArgumentException("runnable cannot be null");
        }
        disallowAddToBackStack();
        if (mCommitRunnables == null) {
            mCommitRunnables = new ArrayList<>();
        }
        mCommitRunnables.add(runnable);
        return this;
    }

    public void runOnCommitRunnables() {
        if (mCommitRunnables != null) {
            for (int i = 0, N = mCommitRunnables.size(); i < N; i++) {
                mCommitRunnables.get(i).run();
            }
            mCommitRunnables = null;
        }
    }

    public int commit() {
        return commitInternal(false);
    }
+26 −5
Original line number Diff line number Diff line
@@ -714,14 +714,20 @@ public class Fragment implements ComponentCallbacks2, OnCreateContextMenuListene
    }

    /**
     * Supply the construction arguments for this fragment.  This can only
     * be called before the fragment has been attached to its activity; that
     * is, you should call it immediately after constructing the fragment.  The
     * arguments supplied here will be retained across fragment destroy and
     * Supply the construction arguments for this fragment.
     * The arguments supplied here will be retained across fragment destroy and
     * creation.
     *
     * <p>This method cannot be called if the fragment is added to a FragmentManager and
     * if {@link #isStateSaved()} would return true. Prior to {@link Build.VERSION_CODES#O},
     * this method may only be called if the fragment has not yet been added to a FragmentManager.
     * </p>
     */
    public void setArguments(Bundle args) {
        if (mIndex >= 0) {
        // The isStateSaved requirement below was only added in Android O and is compatible
        // because it loosens previous requirements rather than making them more strict.
        // See method javadoc.
        if (mIndex >= 0 && isStateSaved()) {
            throw new IllegalStateException("Fragment already active");
        }
        mArguments = args;
@@ -734,6 +740,21 @@ public class Fragment implements ComponentCallbacks2, OnCreateContextMenuListene
        return mArguments;
    }

    /**
     * Returns true if this fragment is added and its state has already been saved
     * by its host. Any operations that would change saved state should not be performed
     * if this method returns true, and some operations such as {@link #setArguments(Bundle)}
     * will fail.
     *
     * @return true if this fragment's state has already been saved by its host
     */
    public final boolean isStateSaved() {
        if (mFragmentManager == null) {
            return false;
        }
        return mFragmentManager.isStateSaved();
    }

    /**
     * Set the initial saved state that this Fragment should restore itself
     * from when first being constructed, as returned by
Loading