Merge "save "retain loader" state" into mnc-dr-dev

This commit is contained in:
Todd Kennedy
2015-09-23 17:56:52 +00:00
committed by Android (Google) Code Review
3 changed files with 16 additions and 1 deletions

View File

@@ -460,6 +460,9 @@ public class Fragment implements ComponentCallbacks2, OnCreateContextMenuListene
// If set this fragment is being retained across the current config change. // If set this fragment is being retained across the current config change.
boolean mRetaining; boolean mRetaining;
// If set this fragment's loaders are being retained across the current config change.
boolean mRetainLoader;
// If set this fragment has menu items to contribute. // If set this fragment has menu items to contribute.
boolean mHasMenu; boolean mHasMenu;
@@ -2401,7 +2404,7 @@ public class Fragment implements ComponentCallbacks2, OnCreateContextMenuListene
mLoaderManager = mHost.getLoaderManager(mWho, mLoadersStarted, false); mLoaderManager = mHost.getLoaderManager(mWho, mLoadersStarted, false);
} }
if (mLoaderManager != null) { if (mLoaderManager != null) {
if (mRetaining) { if (mRetainLoader) {
mLoaderManager.doRetain(); mLoaderManager.doRetain();
} else { } else {
mLoaderManager.doStop(); mLoaderManager.doStop();

View File

@@ -341,6 +341,7 @@ public class FragmentController {
*/ */
public void doLoaderStop(boolean retain) { public void doLoaderStop(boolean retain) {
mHost.doLoaderStop(retain); mHost.doLoaderStop(retain);
mHost.mFragmentManager.setRetainLoader(retain);
} }
/** /**

View File

@@ -869,6 +869,17 @@ final class FragmentManagerImpl extends FragmentManager implements LayoutInflate
} }
} }
void setRetainLoader(boolean retain) {
if (mActive != null) {
for (int i=0; i<mActive.size(); i++) {
Fragment f = mActive.get(i);
if (f != null) {
f.mRetainLoader = retain;
}
}
}
}
void moveToState(Fragment f, int newState, int transit, int transitionStyle, void moveToState(Fragment f, int newState, int transit, int transitionStyle,
boolean keepActive) { boolean keepActive) {
if (DEBUG && false) Log.v(TAG, "moveToState: " + f if (DEBUG && false) Log.v(TAG, "moveToState: " + f