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

Commit 9cfbe957 authored by Jason Monk's avatar Jason Monk Committed by Android (Google) Code Review
Browse files

Merge "Allow FragmentContainer to play a role in fragment construction"

parents e5630207 b2852cab
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -4592,6 +4592,7 @@ package android.app {
  public abstract class FragmentContainer {
    ctor public FragmentContainer();
    method public android.app.Fragment instantiate(android.content.Context, java.lang.String, android.os.Bundle);
    method public abstract android.view.View onFindViewById(int);
    method public abstract boolean onHasView();
  }
+1 −0
Original line number Diff line number Diff line
@@ -4749,6 +4749,7 @@ package android.app {
  public abstract class FragmentContainer {
    ctor public FragmentContainer();
    method public android.app.Fragment instantiate(android.content.Context, java.lang.String, android.os.Bundle);
    method public abstract android.view.View onFindViewById(int);
    method public abstract boolean onHasView();
  }
+1 −0
Original line number Diff line number Diff line
@@ -4602,6 +4602,7 @@ package android.app {
  public abstract class FragmentContainer {
    ctor public FragmentContainer();
    method public android.app.Fragment instantiate(android.content.Context, java.lang.String, android.os.Bundle);
    method public abstract android.view.View onFindViewById(int);
    method public abstract boolean onHasView();
  }
+7 −3
Original line number Diff line number Diff line
@@ -102,15 +102,19 @@ final class FragmentState implements Parcelable {
        mSavedFragmentState = in.readBundle();
    }

    public Fragment instantiate(FragmentHostCallback host, Fragment parent,
            FragmentManagerNonConfig childNonConfig) {
    public Fragment instantiate(FragmentHostCallback host, FragmentContainer container,
            Fragment parent, FragmentManagerNonConfig childNonConfig) {
        if (mInstance == null) {
            final Context context = host.getContext();
            if (mArguments != null) {
                mArguments.setClassLoader(context.getClassLoader());
            }

            if (container != null) {
                mInstance = container.instantiate(context, mClassName, mArguments);
            } else {
                mInstance = Fragment.instantiate(context, mClassName, mArguments);
            }

            if (mSavedFragmentState != null) {
                mSavedFragmentState.setClassLoader(context.getClassLoader());
+11 −0
Original line number Diff line number Diff line
@@ -18,6 +18,8 @@ package android.app;

import android.annotation.IdRes;
import android.annotation.Nullable;
import android.content.Context;
import android.os.Bundle;
import android.view.View;

/**
@@ -35,4 +37,13 @@ public abstract class FragmentContainer {
     * Return {@code true} if the container holds any view.
     */
    public abstract boolean onHasView();

    /**
     * Creates an instance of the specified fragment, can be overridden to construct fragments
     * with dependencies, or change the fragment being constructed. By default just calls
     * {@link Fragment#instantiate(Context, String, Bundle)}.
     */
    public Fragment instantiate(Context context, String className, Bundle arguments) {
        return Fragment.instantiate(context, className, arguments);
    }
}
Loading