Merge "Don't initiate fragment transactions from onDestroy()" into jb-ub-mail-ur10

This commit is contained in:
Tony Mantler 2013-10-30 21:12:06 +00:00 committed by Android (Google) Code Review
commit 2a33eccd19

View File

@ -193,8 +193,12 @@ public class AccountCheckSettingsFragment extends Fragment {
Utility.cancelTaskInterrupt(mAccountCheckTask); Utility.cancelTaskInterrupt(mAccountCheckTask);
mAccountCheckTask = null; mAccountCheckTask = null;
} }
// Make doubly sure that the dialog is gone before we're removed from the fragment manager // Make doubly sure that the dialog isn't pointing at us before we're removed from the
recoverAndDismissCheckingDialog(); // fragment manager
final Fragment f = getFragmentManager().findFragmentByTag(CheckingDialog.TAG);
if (f != null) {
f.setTargetFragment(null, 0);
}
} }
/** /**
@ -312,6 +316,9 @@ public class AccountCheckSettingsFragment extends Fragment {
getFragmentManager().findFragmentByTag(CheckingDialog.TAG); getFragmentManager().findFragmentByTag(CheckingDialog.TAG);
} }
if (mCheckingDialog != null) { if (mCheckingDialog != null) {
// TODO: dismissAllowingStateLoss() can cause the fragment to return later as a zombie
// after the fragment manager restores state, if it happens that this call is executed
// after the state is saved. Figure out a way to clean this up later. b/11435698
mCheckingDialog.dismissAllowingStateLoss(); mCheckingDialog.dismissAllowingStateLoss();
mCheckingDialog = null; mCheckingDialog = null;
} }
@ -700,8 +707,6 @@ public class AccountCheckSettingsFragment extends Fragment {
if (mProgressString == null) { if (mProgressString == null) {
mProgressString = getProgressString(getTargetRequestCode()); mProgressString = getProgressString(getTargetRequestCode());
} }
final AccountCheckSettingsFragment target =
(AccountCheckSettingsFragment) getTargetFragment();
final ProgressDialog dialog = new ProgressDialog(context); final ProgressDialog dialog = new ProgressDialog(context);
dialog.setIndeterminate(true); dialog.setIndeterminate(true);
@ -712,8 +717,13 @@ public class AccountCheckSettingsFragment extends Fragment {
@Override @Override
public void onClick(DialogInterface dialog, int which) { public void onClick(DialogInterface dialog, int which) {
dismiss(); dismiss();
final AccountCheckSettingsFragment target =
(AccountCheckSettingsFragment) getTargetFragment();
if (target != null) {
target.onCheckingDialogCancel(); target.onCheckingDialogCancel();
} }
}
}); });
return dialog; return dialog;
} }
@ -726,7 +736,9 @@ public class AccountCheckSettingsFragment extends Fragment {
public void onCancel(DialogInterface dialog) { public void onCancel(DialogInterface dialog) {
final AccountCheckSettingsFragment target = final AccountCheckSettingsFragment target =
(AccountCheckSettingsFragment) getTargetFragment(); (AccountCheckSettingsFragment) getTargetFragment();
if (target != null) {
target.onCheckingDialogCancel(); target.onCheckingDialogCancel();
}
super.onCancel(dialog); super.onCancel(dialog);
} }