Skip to content

Commit

Permalink
fix deprecated resume call in AlertDialogExtensions (#4775)
Browse files Browse the repository at this point in the history
  • Loading branch information
connyduck authored Nov 28, 2024
1 parent d3feca3 commit bc397e9
Showing 1 changed file with 1 addition and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ package com.keylesspalace.tusky.util
import android.content.DialogInterface
import androidx.annotation.StringRes
import androidx.appcompat.app.AlertDialog
import kotlinx.coroutines.ExperimentalCoroutinesApi
import kotlinx.coroutines.suspendCancellableCoroutine

/**
Expand All @@ -30,14 +29,13 @@ import kotlinx.coroutines.suspendCancellableCoroutine
* @param negativeText Optional text to show on the negative button
* @param neutralText Optional text to show on the neutral button
*/
@OptIn(ExperimentalCoroutinesApi::class)
suspend fun AlertDialog.await(
positiveText: String,
negativeText: String? = null,
neutralText: String? = null
) = suspendCancellableCoroutine { cont ->
val listener = DialogInterface.OnClickListener { _, which ->
cont.resume(which) { dismiss() }
cont.resume(which) { _, _, _ -> dismiss() }
}

setButton(AlertDialog.BUTTON_POSITIVE, positiveText, listener)
Expand Down

0 comments on commit bc397e9

Please sign in to comment.