diff --git a/app/src/main/java/com/github/libretube/ui/preferences/HistorySettings.kt b/app/src/main/java/com/github/libretube/ui/preferences/HistorySettings.kt index c07ea0f9d..6e5f1ff86 100644 --- a/app/src/main/java/com/github/libretube/ui/preferences/HistorySettings.kt +++ b/app/src/main/java/com/github/libretube/ui/preferences/HistorySettings.kt @@ -1,13 +1,13 @@ package com.github.libretube.ui.preferences import android.os.Bundle -import androidx.lifecycle.lifecycleScope import androidx.preference.Preference import com.github.libretube.R import com.github.libretube.constants.PreferenceKeys import com.github.libretube.db.DatabaseHolder.Database import com.github.libretube.ui.base.BasePreferenceFragment import com.google.android.material.dialog.MaterialAlertDialogBuilder +import kotlinx.coroutines.CoroutineScope import kotlinx.coroutines.Dispatchers import kotlinx.coroutines.launch @@ -53,15 +53,15 @@ class HistorySettings : BasePreferenceFragment() { } } - private fun showClearDialog(title: Int, action: suspend () -> Unit) { + private fun showClearDialog(title: Int, actionOnConfirm: suspend () -> Unit) { MaterialAlertDialogBuilder(requireContext()) .setTitle(title) .setMessage(R.string.irreversible) .setNegativeButton(R.string.cancel, null) .setPositiveButton(R.string.okay) { _, _ -> // clear the selected preference preferences - lifecycleScope.launch(Dispatchers.IO) { - action() + CoroutineScope(Dispatchers.IO).launch { + actionOnConfirm.invoke() } } .show()