Prevent "new mode" and "choose schedule" dialogs from being created without a listener
This can happen if the activity is recreated; our approach doesn't support this case very well. With this change, the dialog is not reshown when the activity is recreated, which is not optimal but better than crashing (as it does today). There is no lost work because it's the first choice, and the follow-on steps (icon picker, etc) can be recreated without problems. Fixes: 359746551 Test: manual, with don't keep activities Flag: android.app.modes_ui Change-Id: I84bdeb0007e8c50ec9dd8af61991c7e55ddb8298
This commit is contained in:
@@ -81,6 +81,17 @@ public class ZenModeScheduleChooserDialog extends InstrumentedDialogFragment {
|
||||
dialog.show(parent.getParentFragmentManager(), TAG);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
if (mOptionListener == null) {
|
||||
// Probably the dialog fragment was recreated after its activity being destroyed.
|
||||
// It's pointless to re-show the dialog if we can't do anything when its options are
|
||||
// selected, so we don't.
|
||||
dismiss();
|
||||
}
|
||||
}
|
||||
|
||||
@NonNull
|
||||
@Override
|
||||
public Dialog onCreateDialog(@Nullable Bundle savedInstanceState) {
|
||||
|
@@ -70,6 +70,17 @@ public class ZenModesListAddModeTypeChooserDialog extends InstrumentedDialogFrag
|
||||
dialog.show(parent.getParentFragmentManager(), TAG);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
if (mChooseModeTypeListener == null) {
|
||||
// Probably the dialog fragment was recreated after its activity being destroyed.
|
||||
// It's pointless to re-show the dialog if we can't do anything when its options are
|
||||
// selected, so we don't.
|
||||
dismiss();
|
||||
}
|
||||
}
|
||||
|
||||
@NonNull
|
||||
@Override
|
||||
public Dialog onCreateDialog(@Nullable Bundle savedInstanceState) {
|
||||
|
Reference in New Issue
Block a user