SetupWizard: Ensure page object isn't null if FM destroyed

Change-Id: Ia794e7656587ca803d02418d3d84d4df5027cd00
(cherry picked from commit 62b79e38809699edf47f8a4fad16fdf706ceaa5e)
This commit is contained in:
cretin45 2015-04-09 10:43:41 -07:00 committed by Ed Carrigan
parent e68543ad74
commit 317a15e0eb

View File

@ -43,11 +43,6 @@ public abstract class SetupPageFragment extends Fragment {
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setRetainInstance(true);
Bundle args = getArguments();
mKey = args.getString(Page.KEY_PAGE_ARGUMENT);
if (mKey == null) {
throw new IllegalArgumentException("No KEY_PAGE_ARGUMENT given");
}
SetupStats.addEvent(SetupStats.Categories.PAGE_LOAD, SetupStats.Action.PAGE_LOADED,
mKey, String.valueOf(System.currentTimeMillis()));
}
@ -65,6 +60,11 @@ public abstract class SetupPageFragment extends Fragment {
@Override
public void onAttach(Activity activity) {
super.onAttach(activity);
Bundle args = getArguments();
mKey = args.getString(Page.KEY_PAGE_ARGUMENT);
if (mKey == null) {
throw new IllegalArgumentException("No KEY_PAGE_ARGUMENT given");
}
if (!(activity instanceof SetupDataCallbacks)) {
throw new ClassCastException("Activity implement SetupDataCallbacks");
}
@ -90,6 +90,11 @@ public abstract class SetupPageFragment extends Fragment {
@Override
public void onActivityResult(int requestCode, int resultCode, Intent data) {
// On low mem devices, this fragment might get destroyed by
// fragment manager while we are in another activity.
if (mPage == null) {
mPage = mCallbacks.getPage(mKey);
}
mPage.onActivityResult(requestCode, resultCode, data);
}