fix: defer settings fragment transaction until dialog is shown
This commit is contained in:
+9
-8
@@ -47,14 +47,6 @@ class SettingsDialogFragment : DialogFragment() {
|
||||
override fun onCreateDialog(savedInstanceState: Bundle?): Dialog {
|
||||
val dialogView = LayoutInflater.from(requireContext()).inflate(R.layout.dialog_settings, null)
|
||||
|
||||
childFragmentManager.commitNow {
|
||||
replace(
|
||||
R.id.settingsFragmentContainer,
|
||||
SettingsPreferencesFragment(),
|
||||
SETTINGS_PREFS_TAG,
|
||||
)
|
||||
}
|
||||
|
||||
progress = dialogView.findViewById(R.id.settingsApplyProgress)
|
||||
errorText = dialogView.findViewById(R.id.settingsErrorText)
|
||||
saveButton = dialogView.findViewById(R.id.settingsSaveAndCloseButton)
|
||||
@@ -69,6 +61,15 @@ class SettingsDialogFragment : DialogFragment() {
|
||||
dialog.setCanceledOnTouchOutside(false)
|
||||
|
||||
dialog.setOnShowListener {
|
||||
if (findPreferencesFragment() == null) {
|
||||
childFragmentManager.commitNow {
|
||||
replace(
|
||||
R.id.settingsFragmentContainer,
|
||||
SettingsPreferencesFragment(),
|
||||
SETTINGS_PREFS_TAG,
|
||||
)
|
||||
}
|
||||
}
|
||||
saveButton?.setOnClickListener {
|
||||
onSaveClicked()
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user