summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--api/current.txt2
-rw-r--r--api/system-current.txt2
-rw-r--r--api/test-current.txt2
-rw-r--r--core/java/android/app/DialogFragment.java4
-rw-r--r--core/java/android/app/Fragment.java14
-rw-r--r--core/java/android/app/FragmentManager.java46
-rw-r--r--packages/SystemUI/plugin/src/com/android/systemui/plugins/PluginFragment.java4
7 files changed, 58 insertions, 16 deletions
diff --git a/api/current.txt b/api/current.txt
index 6234168a3a99..5287984774cc 100644
--- a/api/current.txt
+++ b/api/current.txt
@@ -4610,6 +4610,7 @@ package android.app {
method public void onDestroyOptionsMenu();
method public void onDestroyView();
method public void onDetach();
+ method public android.view.LayoutInflater onGetLayoutInflater(android.os.Bundle);
method public void onHiddenChanged(boolean);
method public deprecated void onInflate(android.util.AttributeSet, android.os.Bundle);
method public void onInflate(android.content.Context, android.util.AttributeSet, android.os.Bundle);
@@ -4764,6 +4765,7 @@ package android.app {
method public abstract android.app.FragmentManager.BackStackEntry getBackStackEntryAt(int);
method public abstract int getBackStackEntryCount();
method public abstract android.app.Fragment getFragment(android.os.Bundle, java.lang.String);
+ method public abstract java.util.Collection<android.app.Fragment> getFragments();
method public abstract android.app.Fragment getPrimaryNavigationFragment();
method public void invalidateOptionsMenu();
method public abstract boolean isDestroyed();
diff --git a/api/system-current.txt b/api/system-current.txt
index 6a6b279d8f32..bec8d251c26f 100644
--- a/api/system-current.txt
+++ b/api/system-current.txt
@@ -4769,6 +4769,7 @@ package android.app {
method public void onDestroyOptionsMenu();
method public void onDestroyView();
method public void onDetach();
+ method public android.view.LayoutInflater onGetLayoutInflater(android.os.Bundle);
method public void onHiddenChanged(boolean);
method public deprecated void onInflate(android.util.AttributeSet, android.os.Bundle);
method public void onInflate(android.content.Context, android.util.AttributeSet, android.os.Bundle);
@@ -4923,6 +4924,7 @@ package android.app {
method public abstract android.app.FragmentManager.BackStackEntry getBackStackEntryAt(int);
method public abstract int getBackStackEntryCount();
method public abstract android.app.Fragment getFragment(android.os.Bundle, java.lang.String);
+ method public abstract java.util.Collection<android.app.Fragment> getFragments();
method public abstract android.app.Fragment getPrimaryNavigationFragment();
method public void invalidateOptionsMenu();
method public abstract boolean isDestroyed();
diff --git a/api/test-current.txt b/api/test-current.txt
index 1f342e6b9409..e9f94d96c96d 100644
--- a/api/test-current.txt
+++ b/api/test-current.txt
@@ -4622,6 +4622,7 @@ package android.app {
method public void onDestroyOptionsMenu();
method public void onDestroyView();
method public void onDetach();
+ method public android.view.LayoutInflater onGetLayoutInflater(android.os.Bundle);
method public void onHiddenChanged(boolean);
method public deprecated void onInflate(android.util.AttributeSet, android.os.Bundle);
method public void onInflate(android.content.Context, android.util.AttributeSet, android.os.Bundle);
@@ -4776,6 +4777,7 @@ package android.app {
method public abstract android.app.FragmentManager.BackStackEntry getBackStackEntryAt(int);
method public abstract int getBackStackEntryCount();
method public abstract android.app.Fragment getFragment(android.os.Bundle, java.lang.String);
+ method public abstract java.util.Collection<android.app.Fragment> getFragments();
method public abstract android.app.Fragment getPrimaryNavigationFragment();
method public void invalidateOptionsMenu();
method public abstract boolean isDestroyed();
diff --git a/core/java/android/app/DialogFragment.java b/core/java/android/app/DialogFragment.java
index 3198c7c086d1..7e0e4d827477 100644
--- a/core/java/android/app/DialogFragment.java
+++ b/core/java/android/app/DialogFragment.java
@@ -398,9 +398,9 @@ public class DialogFragment extends Fragment
/** @hide */
@Override
- public LayoutInflater getLayoutInflater(Bundle savedInstanceState) {
+ public LayoutInflater onGetLayoutInflater(Bundle savedInstanceState) {
if (!mShowsDialog) {
- return super.getLayoutInflater(savedInstanceState);
+ return super.onGetLayoutInflater(savedInstanceState);
}
mDialog = onCreateDialog(savedInstanceState);
diff --git a/core/java/android/app/Fragment.java b/core/java/android/app/Fragment.java
index 44fefd38048c..02fe101c9152 100644
--- a/core/java/android/app/Fragment.java
+++ b/core/java/android/app/Fragment.java
@@ -31,7 +31,6 @@ import android.content.res.TypedArray;
import android.os.Build;
import android.os.Build.VERSION_CODES;
import android.os.Bundle;
-import android.os.Handler;
import android.os.Looper;
import android.os.Parcel;
import android.os.Parcelable;
@@ -1357,11 +1356,16 @@ public class Fragment implements ComponentCallbacks2, OnCreateContextMenuListene
}
/**
- * @hide Hack so that DialogFragment can make its Dialog before creating
- * its views, and the view construction can use the dialog's context for
- * inflation. Maybe this should become a public API. Note sure.
+ * Returns the LayoutInflater used to inflate Views of this Fragment. The default
+ * implementation will throw an exception if the Fragment is not attached.
+ *
+ * @return The LayoutInflater used to inflate Views of this Fragment.
*/
- public LayoutInflater getLayoutInflater(Bundle savedInstanceState) {
+ public LayoutInflater onGetLayoutInflater(Bundle savedInstanceState) {
+ if (mHost == null) {
+ throw new IllegalStateException("onGetLayoutInflater() cannot be executed until the "
+ + "Fragment is attached to the FragmentManager.");
+ }
final LayoutInflater result = mHost.onGetLayoutInflater();
if (mHost.onUseFragmentManagerInflaterFactory()) {
getChildFragmentManager(); // Init if needed; use raw implementation below.
diff --git a/core/java/android/app/FragmentManager.java b/core/java/android/app/FragmentManager.java
index d710d8bb6221..5d025d96759a 100644
--- a/core/java/android/app/FragmentManager.java
+++ b/core/java/android/app/FragmentManager.java
@@ -54,6 +54,8 @@ import java.io.FileDescriptor;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.Arrays;
+import java.util.Collection;
+import java.util.Collections;
import java.util.List;
import java.util.concurrent.CopyOnWriteArrayList;
@@ -312,6 +314,16 @@ public abstract class FragmentManager {
public abstract Fragment getFragment(Bundle bundle, String key);
/**
+ * Get a collection of all fragments that are currently added to the FragmentManager.
+ * This may include those that are hidden as well as those that are shown.
+ * This will not include any fragments only in the back stack, or fragments that
+ * are detached or removed.
+ *
+ * @return A collection of all fragments that are added to the FragmentManager.
+ */
+ public abstract Collection<Fragment> getFragments();
+
+ /**
* Save the current instance state of the given Fragment. This can be
* used later when creating a new instance of the Fragment and adding
* it to the fragment manager, to have it create itself to match the
@@ -895,6 +907,16 @@ final class FragmentManagerImpl extends FragmentManager implements LayoutInflate
}
@Override
+ public Collection<Fragment> getFragments() {
+ if (mAdded == null) {
+ return Collections.EMPTY_LIST;
+ }
+ synchronized (mAdded) {
+ return (Collection<Fragment>) mAdded.clone();
+ }
+ }
+
+ @Override
public Fragment.SavedState saveFragmentInstanceState(Fragment fragment) {
if (fragment.mIndex < 0) {
throwException(new IllegalStateException("Fragment " + fragment
@@ -1226,7 +1248,7 @@ final class FragmentManagerImpl extends FragmentManager implements LayoutInflate
}
}
f.mContainer = container;
- f.mView = f.performCreateView(f.getLayoutInflater(
+ f.mView = f.performCreateView(f.onGetLayoutInflater(
f.mSavedFragmentState), container, f.mSavedFragmentState);
if (f.mView != null) {
f.mView.setSaveFromParentEnabled(false);
@@ -1398,7 +1420,7 @@ final class FragmentManagerImpl extends FragmentManager implements LayoutInflate
void ensureInflatedFragmentView(Fragment f) {
if (f.mFromLayout && !f.mPerformedCreateView) {
- f.mView = f.performCreateView(f.getLayoutInflater(
+ f.mView = f.performCreateView(f.onGetLayoutInflater(
f.mSavedFragmentState), null, f.mSavedFragmentState);
if (f.mView != null) {
f.mView.setSaveFromParentEnabled(false);
@@ -1620,7 +1642,9 @@ final class FragmentManagerImpl extends FragmentManager implements LayoutInflate
if (mAdded.contains(fragment)) {
throw new IllegalStateException("Fragment already added: " + fragment);
}
- mAdded.add(fragment);
+ synchronized (mAdded) {
+ mAdded.add(fragment);
+ }
fragment.mAdded = true;
fragment.mRemoving = false;
if (fragment.mView == null) {
@@ -1648,7 +1672,9 @@ final class FragmentManagerImpl extends FragmentManager implements LayoutInflate
}
}
if (mAdded != null) {
- mAdded.remove(fragment);
+ synchronized (mAdded) {
+ mAdded.remove(fragment);
+ }
}
if (fragment.mHasMenu && fragment.mMenuVisible) {
mNeedMenuInvalidate = true;
@@ -1698,7 +1724,9 @@ final class FragmentManagerImpl extends FragmentManager implements LayoutInflate
// We are not already in back stack, so need to remove the fragment.
if (mAdded != null) {
if (DEBUG) Log.v(TAG, "remove from detach: " + fragment);
- mAdded.remove(fragment);
+ synchronized (mAdded) {
+ mAdded.remove(fragment);
+ }
}
if (fragment.mHasMenu && fragment.mMenuVisible) {
mNeedMenuInvalidate = true;
@@ -1720,7 +1748,9 @@ final class FragmentManagerImpl extends FragmentManager implements LayoutInflate
throw new IllegalStateException("Fragment already added: " + fragment);
}
if (DEBUG) Log.v(TAG, "add from attach: " + fragment);
- mAdded.add(fragment);
+ synchronized (mAdded) {
+ mAdded.add(fragment);
+ }
fragment.mAdded = true;
if (fragment.mHasMenu && fragment.mMenuVisible) {
mNeedMenuInvalidate = true;
@@ -2762,7 +2792,9 @@ final class FragmentManagerImpl extends FragmentManager implements LayoutInflate
if (mAdded.contains(f)) {
throw new IllegalStateException("Already added!");
}
- mAdded.add(f);
+ synchronized (mAdded) {
+ mAdded.add(f);
+ }
}
} else {
mAdded = null;
diff --git a/packages/SystemUI/plugin/src/com/android/systemui/plugins/PluginFragment.java b/packages/SystemUI/plugin/src/com/android/systemui/plugins/PluginFragment.java
index 152dbc5e06be..1bfa567b6630 100644
--- a/packages/SystemUI/plugin/src/com/android/systemui/plugins/PluginFragment.java
+++ b/packages/SystemUI/plugin/src/com/android/systemui/plugins/PluginFragment.java
@@ -29,8 +29,8 @@ public abstract class PluginFragment extends Fragment implements Plugin {
}
@Override
- public LayoutInflater getLayoutInflater(Bundle savedInstanceState) {
- return super.getLayoutInflater(savedInstanceState).cloneInContext(getContext());
+ public LayoutInflater onGetLayoutInflater(Bundle savedInstanceState) {
+ return super.onGetLayoutInflater(savedInstanceState).cloneInContext(getContext());
}
@Override