+ " did not call through to super.onViewStateRestored()");
}
}
-
+
final void setIndex(int index, Fragment parent) {
mIndex = index;
if (parent != null) {
} else {
mWho = "android:fragment:" + mIndex;
}
- }
-
+ }
+
final boolean isInBackStack() {
return mBackStackNesting > 0;
}
}
/**
+ * Returns the parent Fragment containing this Fragment. If this Fragment
+ * is attached directly to an Activity, returns null.
+ */
+ final public Fragment getParentFragment() {
+ return mParentFragment;
+ }
+
+ /**
* Return true if the fragment is currently added to its activity.
*/
final public boolean isAdded() {
public void onCreate(Bundle savedInstanceState) {
mCalled = true;
}
-
- /**
- * Called immediately after {@link #onCreateView(LayoutInflater, ViewGroup, Bundle)}
- * has returned, but before any saved state has been restored in to the view.
- * This gives subclasses a chance to initialize themselves once
- * they know their view hierarchy has been completely created. The fragment's
- * view hierarchy is not however attached to its parent at this point.
- * @param view The View returned by {@link #onCreateView(LayoutInflater, ViewGroup, Bundle)}.
- * @param savedInstanceState If non-null, this fragment is being re-constructed
- * from a previous saved state as given here.
- */
- public void onViewCreated(View view, Bundle savedInstanceState) {
- }
-
+
/**
* Called to have the fragment instantiate its user interface view.
* This is optional, and non-graphical fragments can return null (which
Bundle savedInstanceState) {
return null;
}
+
+ /**
+ * Called immediately after {@link #onCreateView(LayoutInflater, ViewGroup, Bundle)}
+ * has returned, but before any saved state has been restored in to the view.
+ * This gives subclasses a chance to initialize themselves once
+ * they know their view hierarchy has been completely created. The fragment's
+ * view hierarchy is not however attached to its parent at this point.
+ * @param view The View returned by {@link #onCreateView(LayoutInflater, ViewGroup, Bundle)}.
+ * @param savedInstanceState If non-null, this fragment is being re-constructed
+ * from a previous saved state as given here.
+ */
+ public void onViewCreated(View view, Bundle savedInstanceState) {
+ }
/**
* Get the root view for the fragment's layout (the one returned by {@link #onCreateView}),
* as this callback tells the fragment when it is fully associated with
* the new activity instance. This is called after {@link #onCreateView}
* and before {@link #onViewStateRestored(Bundle)}.
- *
+ *
* @param savedInstanceState If the fragment is being re-created from
* a previous saved state, this is the state.
*/
* whether check box widgets are currently checked. This is called
* after {@link #onActivityCreated(Bundle)} and before
* {@link #onStart()}.
- *
+ *
* @param savedInstanceState If the fragment is being re-created from
* a previous saved state, this is the state.
*/
writer.print(prefix); writer.print("mActivity=");
writer.println(mActivity);
}
- if (mChildFragmentManager != null) {
- writer.print(prefix); writer.print("mChildFragmentManager=");
- writer.println(mChildFragmentManager);
- }
if (mParentFragment != null) {
writer.print(prefix); writer.print("mParentFragment=");
writer.println(mParentFragment);
mLoaderManager.dump(prefix + " ", fd, writer, args);
}
if (mChildFragmentManager != null) {
- writer.print(prefix); writer.println("Child Fragment Manager:");
+ writer.print(prefix); writer.println("Child " + mChildFragmentManager + ":");
mChildFragmentManager.dump(prefix + " ", fd, writer, args);
}
}
}
void performCreate(Bundle savedInstanceState) {
+ if (mChildFragmentManager != null) {
+ mChildFragmentManager.noteStateNotSaved();
+ }
mCalled = false;
onCreate(savedInstanceState);
if (!mCalled) {
}
}
+ View performCreateView(LayoutInflater inflater, ViewGroup container,
+ Bundle savedInstanceState) {
+ if (mChildFragmentManager != null) {
+ mChildFragmentManager.noteStateNotSaved();
+ }
+ return onCreateView(inflater, container, savedInstanceState);
+ }
+
void performActivityCreated(Bundle savedInstanceState) {
+ if (mChildFragmentManager != null) {
+ mChildFragmentManager.noteStateNotSaved();
+ }
mCalled = false;
onActivityCreated(savedInstanceState);
if (!mCalled) {
void performResume() {
if (mChildFragmentManager != null) {
+ mChildFragmentManager.noteStateNotSaved();
mChildFragmentManager.execPendingActions();
}
mCalled = false;
throw new SuperNotCalledException("Fragment " + f
+ " did not call through to super.onAttach()");
}
- mActivity.onAttachFragment(f);
+ if (f.mParentFragment == null) {
+ mActivity.onAttachFragment(f);
+ }
if (!f.mRetaining) {
f.performCreate(f.mSavedFragmentState);
// For fragments that are part of the content view
// layout, we need to instantiate the view immediately
// and the inflater will take care of adding it.
- f.mView = f.onCreateView(f.getLayoutInflater(f.mSavedFragmentState),
- null, f.mSavedFragmentState);
+ f.mView = f.performCreateView(f.getLayoutInflater(
+ f.mSavedFragmentState), null, f.mSavedFragmentState);
if (f.mView != null) {
f.mView.setSaveFromParentEnabled(false);
if (f.mHidden) f.mView.setVisibility(View.GONE);
}
}
f.mContainer = container;
- f.mView = f.onCreateView(f.getLayoutInflater(f.mSavedFragmentState),
- container, f.mSavedFragmentState);
+ f.mView = f.performCreateView(f.getLayoutInflater(
+ f.mSavedFragmentState), container, f.mSavedFragmentState);
if (f.mView != null) {
f.mView.setSaveFromParentEnabled(false);
if (container != null) {
f.onViewCreated(f.mView, f.mSavedFragmentState);
}
}
-
+
f.performActivityCreated(f.mSavedFragmentState);
if (f.mView != null) {
f.restoreViewState(f.mSavedFragmentState);
public void dispatchDestroyView() {
moveToState(Fragment.CREATED, false);
}
-
+
public void dispatchDestroy() {
mDestroyed = true;
execPendingActions();