@@ -615,16 +615,16 @@ final void restoreViewState(Bundle savedInstanceState) {
615615 + " did not call through to super.onViewStateRestored()" );
616616 }
617617 }
618-
618+
619619 final void setIndex (int index , Fragment parent ) {
620620 mIndex = index ;
621621 if (parent != null ) {
622622 mWho = parent .mWho + ":" + mIndex ;
623623 } else {
624624 mWho = "android:fragment:" + mIndex ;
625625 }
626- }
627-
626+ }
627+
628628 final boolean isInBackStack () {
629629 return mBackStackNesting > 0 ;
630630 }
@@ -831,6 +831,14 @@ final public FragmentManager getChildFragmentManager() {
831831 return mChildFragmentManager ;
832832 }
833833
834+ /**
835+ * Returns the parent Fragment containing this Fragment. If this Fragment
836+ * is attached directly to an Activity, returns null.
837+ */
838+ final public Fragment getParentFragment () {
839+ return mParentFragment ;
840+ }
841+
834842 /**
835843 * Return true if the fragment is currently added to its activity.
836844 */
@@ -1180,20 +1188,7 @@ public Animator onCreateAnimator(int transit, boolean enter, int nextAnim) {
11801188 public void onCreate (Bundle savedInstanceState ) {
11811189 mCalled = true ;
11821190 }
1183-
1184- /**
1185- * Called immediately after {@link #onCreateView(LayoutInflater, ViewGroup, Bundle)}
1186- * has returned, but before any saved state has been restored in to the view.
1187- * This gives subclasses a chance to initialize themselves once
1188- * they know their view hierarchy has been completely created. The fragment's
1189- * view hierarchy is not however attached to its parent at this point.
1190- * @param view The View returned by {@link #onCreateView(LayoutInflater, ViewGroup, Bundle)}.
1191- * @param savedInstanceState If non-null, this fragment is being re-constructed
1192- * from a previous saved state as given here.
1193- */
1194- public void onViewCreated (View view , Bundle savedInstanceState ) {
1195- }
1196-
1191+
11971192 /**
11981193 * Called to have the fragment instantiate its user interface view.
11991194 * This is optional, and non-graphical fragments can return null (which
@@ -1217,6 +1212,19 @@ public View onCreateView(LayoutInflater inflater, ViewGroup container,
12171212 Bundle savedInstanceState ) {
12181213 return null ;
12191214 }
1215+
1216+ /**
1217+ * Called immediately after {@link #onCreateView(LayoutInflater, ViewGroup, Bundle)}
1218+ * has returned, but before any saved state has been restored in to the view.
1219+ * This gives subclasses a chance to initialize themselves once
1220+ * they know their view hierarchy has been completely created. The fragment's
1221+ * view hierarchy is not however attached to its parent at this point.
1222+ * @param view The View returned by {@link #onCreateView(LayoutInflater, ViewGroup, Bundle)}.
1223+ * @param savedInstanceState If non-null, this fragment is being re-constructed
1224+ * from a previous saved state as given here.
1225+ */
1226+ public void onViewCreated (View view , Bundle savedInstanceState ) {
1227+ }
12201228
12211229 /**
12221230 * Get the root view for the fragment's layout (the one returned by {@link #onCreateView}),
@@ -1237,7 +1245,7 @@ public View getView() {
12371245 * as this callback tells the fragment when it is fully associated with
12381246 * the new activity instance. This is called after {@link #onCreateView}
12391247 * and before {@link #onViewStateRestored(Bundle)}.
1240- *
1248+ *
12411249 * @param savedInstanceState If the fragment is being re-created from
12421250 * a previous saved state, this is the state.
12431251 */
@@ -1252,7 +1260,7 @@ public void onActivityCreated(Bundle savedInstanceState) {
12521260 * whether check box widgets are currently checked. This is called
12531261 * after {@link #onActivityCreated(Bundle)} and before
12541262 * {@link #onStart()}.
1255- *
1263+ *
12561264 * @param savedInstanceState If the fragment is being re-created from
12571265 * a previous saved state, this is the state.
12581266 */
@@ -1590,10 +1598,6 @@ public void dump(String prefix, FileDescriptor fd, PrintWriter writer, String[]
15901598 writer .print (prefix ); writer .print ("mActivity=" );
15911599 writer .println (mActivity );
15921600 }
1593- if (mChildFragmentManager != null ) {
1594- writer .print (prefix ); writer .print ("mChildFragmentManager=" );
1595- writer .println (mChildFragmentManager );
1596- }
15971601 if (mParentFragment != null ) {
15981602 writer .print (prefix ); writer .print ("mParentFragment=" );
15991603 writer .println (mParentFragment );
@@ -1633,7 +1637,7 @@ public void dump(String prefix, FileDescriptor fd, PrintWriter writer, String[]
16331637 mLoaderManager .dump (prefix + " " , fd , writer , args );
16341638 }
16351639 if (mChildFragmentManager != null ) {
1636- writer .print (prefix ); writer .println ("Child Fragment Manager :" );
1640+ writer .print (prefix ); writer .println ("Child " + mChildFragmentManager + " :" );
16371641 mChildFragmentManager .dump (prefix + " " , fd , writer , args );
16381642 }
16391643 }
@@ -1662,6 +1666,9 @@ public View findViewById(int id) {
16621666 }
16631667
16641668 void performCreate (Bundle savedInstanceState ) {
1669+ if (mChildFragmentManager != null ) {
1670+ mChildFragmentManager .noteStateNotSaved ();
1671+ }
16651672 mCalled = false ;
16661673 onCreate (savedInstanceState );
16671674 if (!mCalled ) {
@@ -1680,7 +1687,18 @@ void performCreate(Bundle savedInstanceState) {
16801687 }
16811688 }
16821689
1690+ View performCreateView (LayoutInflater inflater , ViewGroup container ,
1691+ Bundle savedInstanceState ) {
1692+ if (mChildFragmentManager != null ) {
1693+ mChildFragmentManager .noteStateNotSaved ();
1694+ }
1695+ return onCreateView (inflater , container , savedInstanceState );
1696+ }
1697+
16831698 void performActivityCreated (Bundle savedInstanceState ) {
1699+ if (mChildFragmentManager != null ) {
1700+ mChildFragmentManager .noteStateNotSaved ();
1701+ }
16841702 mCalled = false ;
16851703 onActivityCreated (savedInstanceState );
16861704 if (!mCalled ) {
@@ -1713,6 +1731,7 @@ void performStart() {
17131731
17141732 void performResume () {
17151733 if (mChildFragmentManager != null ) {
1734+ mChildFragmentManager .noteStateNotSaved ();
17161735 mChildFragmentManager .execPendingActions ();
17171736 }
17181737 mCalled = false ;
0 commit comments