0
0
mirror of https://github.com/ankidroid/Anki-Android.git synced 2024-09-19 19:42:17 +02:00

refactor: arguments in show error dialog in multimedia fragment

This commit is contained in:
Ashish Yadav 2024-08-01 15:35:07 +05:30 committed by David Allison
parent f0a319379a
commit 1c878bbe25

View File

@ -99,13 +99,14 @@ abstract class MultimediaFragment(@LayoutRes layout: Int) : Fragment(layout) {
}
/**
* Creates and shows an AlertDialog with a predefined error message
* Creates and shows an AlertDialog with an error message
* from the application's resources. The dialog includes an "OK" button that,
* when clicked, finishes the current activity.
*/
fun showErrorDialog() {
fun showErrorDialog(errorMessage: String? = null) {
val message = errorMessage ?: resources.getString(R.string.something_wrong)
AlertDialog.Builder(requireContext()).show {
setMessage(getString(R.string.something_wrong))
setMessage(message)
setPositiveButton(getString(R.string.dialog_ok)) { _, _ ->
requireActivity().finish()
}