Skip to content

Commit

Permalink
Don't close the dialog when clicking a button
Browse files Browse the repository at this point in the history
  • Loading branch information
Pittvandewitt committed Feb 10, 2025
1 parent c88410a commit 8dba201
Showing 1 changed file with 12 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -69,15 +69,20 @@ class AddToPlaylistDialog : DialogFragment() {

return MaterialAlertDialogBuilder(requireContext())
.setTitle(R.string.addToPlaylist)
.setNegativeButton(R.string.createPlaylist) { _, _ ->
CreatePlaylistDialog().show(childFragmentManager, null)
}
.setPositiveButton(R.string.addToPlaylist) { _, _ ->
val selectedItemPosition = binding.playlistsSpinner.selectedItemPosition
viewModel.onPostiveButtonClick(selectedItemPosition)
}
.setNegativeButton(R.string.createPlaylist, null)
.setPositiveButton(R.string.addToPlaylist, null)
.setView(binding.root)
.show()
.apply {
// Click listeners without closing the dialog
getButton(DialogInterface.BUTTON_NEGATIVE).setOnClickListener {
CreatePlaylistDialog().show(childFragmentManager, null)
}
getButton(DialogInterface.BUTTON_POSITIVE).setOnClickListener {
val selectedItemPosition = binding.playlistsSpinner.selectedItemPosition
viewModel.onPostiveButtonClick(selectedItemPosition)
}
}
}

override fun onDismiss(dialog: DialogInterface) {
Expand Down

0 comments on commit 8dba201

Please sign in to comment.