summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTodd Kennedy <toddke@google.com>2015-05-05 15:53:27 +0000
committerAndroid (Google) Code Review <android-gerrit@google.com>2015-05-05 15:53:29 +0000
commit3266f60ba0c2a37883446cadbfc00bb8354824d0 (patch)
tree93384e13842b98b4a33f47015d8fe5347758a414
parente02b7868c6c8f856a21f36569a77dab7f1cc7c78 (diff)
parent434bd65ca61ff5cec46fce9fbe866d8ee40579da (diff)
downloadframeworks_base-3266f60ba0c2a37883446cadbfc00bb8354824d0.zip
frameworks_base-3266f60ba0c2a37883446cadbfc00bb8354824d0.tar.gz
frameworks_base-3266f60ba0c2a37883446cadbfc00bb8354824d0.tar.bz2
Merge "Call Activity#onAttachFragment()" into mnc-dev
-rw-r--r--api/current.txt1
-rw-r--r--api/system-current.txt1
-rw-r--r--core/java/android/app/Activity.java5
-rw-r--r--core/java/android/app/Fragment.java6
-rw-r--r--core/java/android/app/FragmentHostCallback.java17
-rw-r--r--core/java/android/app/FragmentManager.java8
6 files changed, 25 insertions, 13 deletions
diff --git a/api/current.txt b/api/current.txt
index 07a4ff7..e3bb0b8 100644
--- a/api/current.txt
+++ b/api/current.txt
@@ -4495,6 +4495,7 @@ package android.app {
public abstract class FragmentHostCallback extends android.app.FragmentContainer {
ctor public FragmentHostCallback(android.content.Context, android.os.Handler, int);
+ method public void onAttachFragment(android.app.Fragment);
method public void onDump(java.lang.String, java.io.FileDescriptor, java.io.PrintWriter, java.lang.String[]);
method public android.view.View onFindViewById(int);
method public abstract E onGetHost();
diff --git a/api/system-current.txt b/api/system-current.txt
index e068a40..535bfc7 100644
--- a/api/system-current.txt
+++ b/api/system-current.txt
@@ -4587,6 +4587,7 @@ package android.app {
public abstract class FragmentHostCallback extends android.app.FragmentContainer {
ctor public FragmentHostCallback(android.content.Context, android.os.Handler, int);
+ method public void onAttachFragment(android.app.Fragment);
method public void onDump(java.lang.String, java.io.FileDescriptor, java.io.PrintWriter, java.lang.String[]);
method public android.view.View onFindViewById(int);
method public abstract E onGetHost();
diff --git a/core/java/android/app/Activity.java b/core/java/android/app/Activity.java
index afbddd9..7260d10 100644
--- a/core/java/android/app/Activity.java
+++ b/core/java/android/app/Activity.java
@@ -6498,6 +6498,11 @@ public class Activity extends ContextThemeWrapper
return (w == null) ? 0 : w.getAttributes().windowAnimations;
}
+ @Override
+ public void onAttachFragment(Fragment fragment) {
+ Activity.this.onAttachFragment(fragment);
+ }
+
@Nullable
@Override
public View onFindViewById(int id) {
diff --git a/core/java/android/app/Fragment.java b/core/java/android/app/Fragment.java
index 91d810e..40c5c64 100644
--- a/core/java/android/app/Fragment.java
+++ b/core/java/android/app/Fragment.java
@@ -1314,6 +1314,12 @@ public class Fragment implements ComponentCallbacks2, OnCreateContextMenuListene
com.android.internal.R.styleable.Fragment_fragmentAllowReturnTransitionOverlap, true);
}
a.recycle();
+
+ final Activity hostActivity = mHost == null ? null : mHost.getActivity();
+ if (hostActivity != null) {
+ mCalled = false;
+ onInflate(hostActivity, attrs, savedInstanceState);
+ }
}
/**
diff --git a/core/java/android/app/FragmentHostCallback.java b/core/java/android/app/FragmentHostCallback.java
index dad2c79..3e753f0 100644
--- a/core/java/android/app/FragmentHostCallback.java
+++ b/core/java/android/app/FragmentHostCallback.java
@@ -23,7 +23,6 @@ import android.content.Intent;
import android.os.Bundle;
import android.os.Handler;
import android.util.ArrayMap;
-import android.util.AttributeSet;
import android.view.LayoutInflater;
import android.view.View;
@@ -140,6 +139,14 @@ public abstract class FragmentHostCallback<E> extends FragmentContainer {
return mWindowAnimations;
}
+ /**
+ * Called when a {@link Fragment} is being attached to this host, immediately
+ * after the call to its {@link Fragment#onAttach(Context)} method and before
+ * {@link Fragment#onCreate(Bundle)}.
+ */
+ public void onAttachFragment(Fragment fragment) {
+ }
+
@Nullable
@Override
public View onFindViewById(int id) {
@@ -187,14 +194,6 @@ public abstract class FragmentHostCallback<E> extends FragmentContainer {
}
}
- void onFragmentInflate(Fragment fragment, AttributeSet attrs, Bundle savedInstanceState) {
- fragment.onInflate(mContext, attrs, savedInstanceState);
- }
-
- void onFragmentAttach(Fragment fragment) {
- fragment.onAttach(mContext);
- }
-
void doLoaderStart() {
if (mLoadersStarted) {
return;
diff --git a/core/java/android/app/FragmentManager.java b/core/java/android/app/FragmentManager.java
index 62436e9..6b5239d 100644
--- a/core/java/android/app/FragmentManager.java
+++ b/core/java/android/app/FragmentManager.java
@@ -844,13 +844,13 @@ final class FragmentManagerImpl extends FragmentManager implements LayoutInflate
f.mFragmentManager = mParent != null
? mParent.mChildFragmentManager : mHost.getFragmentManagerImpl();
f.mCalled = false;
- mHost.onFragmentAttach(f);
+ f.onAttach(mHost.getContext());
if (!f.mCalled) {
throw new SuperNotCalledException("Fragment " + f
+ " did not call through to super.onAttach()");
}
if (f.mParentFragment == null) {
- mHost.onFragmentAttach(f);
+ mHost.onAttachFragment(f);
}
if (!f.mRetaining) {
@@ -2107,7 +2107,7 @@ final class FragmentManagerImpl extends FragmentManager implements LayoutInflate
fragment.mTag = tag;
fragment.mInLayout = true;
fragment.mFragmentManager = this;
- mHost.onFragmentInflate(fragment, attrs, fragment.mSavedFragmentState);
+ fragment.onInflate(mHost.getContext(), attrs, fragment.mSavedFragmentState);
addFragment(fragment, true);
} else if (fragment.mInLayout) {
// A fragment already exists and it is not one we restored from
@@ -2124,7 +2124,7 @@ final class FragmentManagerImpl extends FragmentManager implements LayoutInflate
// from last saved state), then give it the attributes to
// initialize itself.
if (!fragment.mRetaining) {
- mHost.onFragmentInflate(fragment, attrs, fragment.mSavedFragmentState);
+ fragment.onInflate(mHost.getContext(), attrs, fragment.mSavedFragmentState);
}
}