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);
mAccountCheckTask = null;
}
// Make doubly sure that the dialog is gone before we're removed from the fragment manager
recoverAndDismissCheckingDialog();
// Make doubly sure that the dialog isn't pointing at us before we're removed from the
// 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);
}
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 = null;
}
@ -700,8 +707,6 @@ public class AccountCheckSettingsFragment extends Fragment {
if (mProgressString == null) {
mProgressString = getProgressString(getTargetRequestCode());
}
final AccountCheckSettingsFragment target =
(AccountCheckSettingsFragment) getTargetFragment();
final ProgressDialog dialog = new ProgressDialog(context);
dialog.setIndeterminate(true);
@ -712,8 +717,13 @@ public class AccountCheckSettingsFragment extends Fragment {
@Override
public void onClick(DialogInterface dialog, int which) {
dismiss();
final AccountCheckSettingsFragment target =
(AccountCheckSettingsFragment) getTargetFragment();
if (target != null) {
target.onCheckingDialogCancel();
}
}
});
return dialog;
}
@ -726,7 +736,9 @@ public class AccountCheckSettingsFragment extends Fragment {
public void onCancel(DialogInterface dialog) {
final AccountCheckSettingsFragment target =
(AccountCheckSettingsFragment) getTargetFragment();
if (target != null) {
target.onCheckingDialogCancel();
}
super.onCancel(dialog);
}