Skip to content

Commit 0a6c2c0

Browse files
authored
Fix marker deletion confirmation crash (#75)
1 parent cfd0146 commit 0a6c2c0

1 file changed

Lines changed: 5 additions & 2 deletions

File tree

‎app/src/main/java/org/nitri/opentopo/view/MarkerEditorDialog.kt‎

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -115,18 +115,21 @@ class MarkerEditorDialog : DialogFragment() {
115115
}
116116

117117
private fun showDeleteConfirmation(markerId: Int) {
118+
// Selecting the editor's neutral button dismisses its AlertDialog, which can detach this
119+
// DialogFragment before the confirmation dialog's button callback runs.
120+
val fragmentManager = parentFragmentManager
121+
118122
AlertDialog.Builder(requireContext())
119123
.setTitle(R.string.confirm_delete)
120124
.setMessage(R.string.prompt_confirm_delete)
121125
.setPositiveButton(R.string.delete) { _, _ ->
122-
setFragmentResult(
126+
fragmentManager.setFragmentResult(
123127
RESULT_REQUEST_KEY,
124128
Bundle().apply {
125129
putString(RESULT_ACTION, RESULT_ACTION_DELETE)
126130
putInt(RESULT_MARKER_ID, markerId)
127131
}
128132
)
129-
dismiss()
130133
}
131134
.setNegativeButton(R.string.cancel, null)
132135
.create()

0 commit comments

Comments
 (0)