summaryrefslogtreecommitdiffstats
path: root/core
diff options
context:
space:
mode:
authorTodd Kennedy <toddke@google.com>2015-10-19 15:31:51 -0700
committerTodd Kennedy <toddke@google.com>2015-10-19 16:40:03 -0700
commit2ee19c7f46ab488f19380f4c70904a1ac00fee9a (patch)
tree0b1e1ea357af5aa1357ade1d667be532b729c2c6 /core
parent7f2deeeef53887dcad74b8aed86936983353cec4 (diff)
downloadframeworks_base-2ee19c7f46ab488f19380f4c70904a1ac00fee9a.zip
frameworks_base-2ee19c7f46ab488f19380f4c70904a1ac00fee9a.tar.gz
frameworks_base-2ee19c7f46ab488f19380f4c70904a1ac00fee9a.tar.bz2
Retain fragment loaders
Remove the partial fix [it did not work for child fragment managers] and replace with a more general fix that works with all fragments. Bug: 23838271 Change-Id: I88b465f6a06a6ad627b9651b9e2eea41fae08972
Diffstat (limited to 'core')
-rw-r--r--core/java/android/app/Fragment.java5
-rw-r--r--core/java/android/app/FragmentController.java1
-rw-r--r--core/java/android/app/FragmentHostCallback.java11
-rw-r--r--core/java/android/app/FragmentManager.java11
4 files changed, 12 insertions, 16 deletions
diff --git a/core/java/android/app/Fragment.java b/core/java/android/app/Fragment.java
index d50483e..29e8dd4 100644
--- a/core/java/android/app/Fragment.java
+++ b/core/java/android/app/Fragment.java
@@ -460,9 +460,6 @@ public class Fragment implements ComponentCallbacks2, OnCreateContextMenuListene
// If set this fragment is being retained across the current config change.
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.
boolean mHasMenu;
@@ -2404,7 +2401,7 @@ public class Fragment implements ComponentCallbacks2, OnCreateContextMenuListene
mLoaderManager = mHost.getLoaderManager(mWho, mLoadersStarted, false);
}
if (mLoaderManager != null) {
- if (mRetainLoader) {
+ if (mHost.getRetainLoaders()) {
mLoaderManager.doRetain();
} else {
mLoaderManager.doStop();
diff --git a/core/java/android/app/FragmentController.java b/core/java/android/app/FragmentController.java
index 1b45137..28dadfa 100644
--- a/core/java/android/app/FragmentController.java
+++ b/core/java/android/app/FragmentController.java
@@ -341,7 +341,6 @@ public class FragmentController {
*/
public void doLoaderStop(boolean retain) {
mHost.doLoaderStop(retain);
- mHost.mFragmentManager.setRetainLoader(retain);
}
/**
diff --git a/core/java/android/app/FragmentHostCallback.java b/core/java/android/app/FragmentHostCallback.java
index 7b01307..13517e6 100644
--- a/core/java/android/app/FragmentHostCallback.java
+++ b/core/java/android/app/FragmentHostCallback.java
@@ -42,9 +42,14 @@ public abstract class FragmentHostCallback<E> extends FragmentContainer {
private final Handler mHandler;
final int mWindowAnimations;
final FragmentManagerImpl mFragmentManager = new FragmentManagerImpl();
+ /** The loader managers for individual fragments [i.e. Fragment#getLoaderManager()] */
private ArrayMap<String, LoaderManager> mAllLoaderManagers;
+ /** Whether or not fragment loaders should retain their state */
+ private boolean mRetainLoaders;
+ /** The loader manger for the fragment host [i.e. Activity#getLoaderManager()] */
private LoaderManagerImpl mLoaderManager;
private boolean mCheckedForLoaderManager;
+ /** Whether or not the fragment host loader manager was started */
private boolean mLoadersStarted;
public FragmentHostCallback(Context context, Handler handler, int windowAnimations) {
@@ -166,6 +171,10 @@ public abstract class FragmentHostCallback<E> extends FragmentContainer {
return true;
}
+ boolean getRetainLoaders() {
+ return mRetainLoaders;
+ }
+
Activity getActivity() {
return mActivity;
}
@@ -217,6 +226,8 @@ public abstract class FragmentHostCallback<E> extends FragmentContainer {
}
void doLoaderStop(boolean retain) {
+ mRetainLoaders = retain;
+
if (mLoaderManager == null) {
return;
}
diff --git a/core/java/android/app/FragmentManager.java b/core/java/android/app/FragmentManager.java
index 51d6132..132ffef 100644
--- a/core/java/android/app/FragmentManager.java
+++ b/core/java/android/app/FragmentManager.java
@@ -869,17 +869,6 @@ 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,
boolean keepActive) {
if (DEBUG && false) Log.v(TAG, "moveToState: " + f