OSDN Git Service

Revert "Make public getFragments() and onGetLayoutInflater() methods"
authorJeff Tinker <jtinker@google.com>
Wed, 29 Mar 2017 01:10:54 +0000 (01:10 +0000)
committerJeff Tinker <jtinker@google.com>
Wed, 29 Mar 2017 01:25:06 +0000 (01:25 +0000)
This reverts commit 599be3d01ed1811ae365085e67a15d082170b583.

This change is being reverted because it broke git_master build.

Change-Id: I54ab9cd3d9e08dcf870f472fda08cc44e57986d0
bug: 34703669

api/current.txt
api/system-current.txt
api/test-current.txt
core/java/android/app/DialogFragment.java
core/java/android/app/Fragment.java
core/java/android/app/FragmentManager.java

index eea3e3b..d10797c 100644 (file)
@@ -4609,7 +4609,6 @@ 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,7 +4763,6 @@ 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.List<android.app.Fragment> getFragments();
     method public abstract android.app.Fragment getPrimaryNavigationFragment();
     method public void invalidateOptionsMenu();
     method public abstract boolean isDestroyed();
index c07b928..c7b377e 100644 (file)
@@ -4768,7 +4768,6 @@ 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,7 +4922,6 @@ 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.List<android.app.Fragment> getFragments();
     method public abstract android.app.Fragment getPrimaryNavigationFragment();
     method public void invalidateOptionsMenu();
     method public abstract boolean isDestroyed();
index eef6200..882e9bb 100644 (file)
@@ -4621,7 +4621,6 @@ 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,7 +4775,6 @@ 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.List<android.app.Fragment> getFragments();
     method public abstract android.app.Fragment getPrimaryNavigationFragment();
     method public void invalidateOptionsMenu();
     method public abstract boolean isDestroyed();
index 7e0e4d8..3198c7c 100644 (file)
@@ -398,9 +398,9 @@ public class DialogFragment extends Fragment
 
     /** @hide */
     @Override
-    public LayoutInflater onGetLayoutInflater(Bundle savedInstanceState) {
+    public LayoutInflater getLayoutInflater(Bundle savedInstanceState) {
         if (!mShowsDialog) {
-            return super.onGetLayoutInflater(savedInstanceState);
+            return super.getLayoutInflater(savedInstanceState);
         }
 
         mDialog = onCreateDialog(savedInstanceState);
index 02fe101..44fefd3 100644 (file)
@@ -31,6 +31,7 @@ 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;
@@ -1356,16 +1357,11 @@ public class Fragment implements ComponentCallbacks2, OnCreateContextMenuListene
     }
 
     /**
-     * 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.
+     * @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.
      */
-    public LayoutInflater onGetLayoutInflater(Bundle savedInstanceState) {
-        if (mHost == null) {
-            throw new IllegalStateException("onGetLayoutInflater() cannot be executed until the "
-                    + "Fragment is attached to the FragmentManager.");
-        }
+    public LayoutInflater getLayoutInflater(Bundle savedInstanceState) {
         final LayoutInflater result = mHost.onGetLayoutInflater();
         if (mHost.onUseFragmentManagerInflaterFactory()) {
             getChildFragmentManager(); // Init if needed; use raw implementation below.
index 73d51bd..d710d8b 100644 (file)
@@ -54,7 +54,6 @@ import java.io.FileDescriptor;
 import java.io.PrintWriter;
 import java.util.ArrayList;
 import java.util.Arrays;
-import java.util.Collections;
 import java.util.List;
 import java.util.concurrent.CopyOnWriteArrayList;
 
@@ -313,16 +312,6 @@ public abstract class FragmentManager {
     public abstract Fragment getFragment(Bundle bundle, String key);
 
     /**
-     * Get a list 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 list of all fragments that are added to the FragmentManager.
-     */
-    public abstract List<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
@@ -906,16 +895,6 @@ final class FragmentManagerImpl extends FragmentManager implements LayoutInflate
     }
 
     @Override
-    public List<Fragment> getFragments() {
-        if (mAdded == null) {
-            return Collections.EMPTY_LIST;
-        }
-        synchronized (mAdded) {
-            return (List<Fragment>) mAdded.clone();
-        }
-    }
-
-    @Override
     public Fragment.SavedState saveFragmentInstanceState(Fragment fragment) {
         if (fragment.mIndex < 0) {
             throwException(new IllegalStateException("Fragment " + fragment
@@ -1247,7 +1226,7 @@ final class FragmentManagerImpl extends FragmentManager implements LayoutInflate
                                 }
                             }
                             f.mContainer = container;
-                            f.mView = f.performCreateView(f.onGetLayoutInflater(
+                            f.mView = f.performCreateView(f.getLayoutInflater(
                                     f.mSavedFragmentState), container, f.mSavedFragmentState);
                             if (f.mView != null) {
                                 f.mView.setSaveFromParentEnabled(false);
@@ -1419,7 +1398,7 @@ final class FragmentManagerImpl extends FragmentManager implements LayoutInflate
 
     void ensureInflatedFragmentView(Fragment f) {
         if (f.mFromLayout && !f.mPerformedCreateView) {
-            f.mView = f.performCreateView(f.onGetLayoutInflater(
+            f.mView = f.performCreateView(f.getLayoutInflater(
                     f.mSavedFragmentState), null, f.mSavedFragmentState);
             if (f.mView != null) {
                 f.mView.setSaveFromParentEnabled(false);
@@ -1641,9 +1620,7 @@ final class FragmentManagerImpl extends FragmentManager implements LayoutInflate
             if (mAdded.contains(fragment)) {
                 throw new IllegalStateException("Fragment already added: " + fragment);
             }
-            synchronized (mAdded) {
-                mAdded.add(fragment);
-            }
+            mAdded.add(fragment);
             fragment.mAdded = true;
             fragment.mRemoving = false;
             if (fragment.mView == null) {
@@ -1671,9 +1648,7 @@ final class FragmentManagerImpl extends FragmentManager implements LayoutInflate
                 }
             }
             if (mAdded != null) {
-                synchronized (mAdded) {
-                    mAdded.remove(fragment);
-                }
+                mAdded.remove(fragment);
             }
             if (fragment.mHasMenu && fragment.mMenuVisible) {
                 mNeedMenuInvalidate = true;
@@ -1723,9 +1698,7 @@ 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);
-                    synchronized (mAdded) {
-                        mAdded.remove(fragment);
-                    }
+                    mAdded.remove(fragment);
                 }
                 if (fragment.mHasMenu && fragment.mMenuVisible) {
                     mNeedMenuInvalidate = true;
@@ -1747,9 +1720,7 @@ final class FragmentManagerImpl extends FragmentManager implements LayoutInflate
                     throw new IllegalStateException("Fragment already added: " + fragment);
                 }
                 if (DEBUG) Log.v(TAG, "add from attach: " + fragment);
-                synchronized (mAdded) {
-                    mAdded.add(fragment);
-                }
+                mAdded.add(fragment);
                 fragment.mAdded = true;
                 if (fragment.mHasMenu && fragment.mMenuVisible) {
                     mNeedMenuInvalidate = true;
@@ -2791,9 +2762,7 @@ final class FragmentManagerImpl extends FragmentManager implements LayoutInflate
                 if (mAdded.contains(f)) {
                     throw new IllegalStateException("Already added!");
                 }
-                synchronized (mAdded) {
-                    mAdded.add(f);
-                }
+                mAdded.add(f);
             }
         } else {
             mAdded = null;