MangaController overhaul (#7244)
This commit is contained in:
+19
@@ -4,6 +4,7 @@ import android.view.LayoutInflater
|
||||
import android.view.inputmethod.InputMethodManager
|
||||
import android.widget.TextView
|
||||
import androidx.annotation.StringRes
|
||||
import androidx.appcompat.app.AlertDialog
|
||||
import androidx.core.content.getSystemService
|
||||
import androidx.core.view.isVisible
|
||||
import androidx.core.widget.doAfterTextChanged
|
||||
@@ -11,6 +12,8 @@ import androidx.recyclerview.widget.LinearLayoutManager
|
||||
import com.google.android.material.dialog.MaterialAlertDialogBuilder
|
||||
import eu.kanade.tachiyomi.databinding.DialogStubQuadstatemultichoiceBinding
|
||||
import eu.kanade.tachiyomi.databinding.DialogStubTextinputBinding
|
||||
import kotlinx.coroutines.suspendCancellableCoroutine
|
||||
import kotlin.coroutines.resume
|
||||
|
||||
fun MaterialAlertDialogBuilder.setTextInput(
|
||||
hint: String? = null,
|
||||
@@ -71,3 +74,19 @@ fun MaterialAlertDialogBuilder.setQuadStateMultiChoiceItems(
|
||||
}
|
||||
return setView(binding.root)
|
||||
}
|
||||
|
||||
suspend fun MaterialAlertDialogBuilder.await(
|
||||
@StringRes positiveLabelId: Int,
|
||||
@StringRes negativeLabelId: Int,
|
||||
@StringRes neutralLabelId: Int? = null,
|
||||
) = suspendCancellableCoroutine<Int> { cont ->
|
||||
setPositiveButton(positiveLabelId) { _, _ -> cont.resume(AlertDialog.BUTTON_POSITIVE) }
|
||||
setNegativeButton(negativeLabelId) { _, _ -> cont.resume(AlertDialog.BUTTON_NEGATIVE) }
|
||||
if (neutralLabelId != null) {
|
||||
setNeutralButton(neutralLabelId) { _, _ -> cont.resume(AlertDialog.BUTTON_NEUTRAL) }
|
||||
}
|
||||
setOnDismissListener { cont.cancel() }
|
||||
|
||||
val dialog = show()
|
||||
cont.invokeOnCancellation { dialog.dismiss() }
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user