Skip to content
Snippets Groups Projects
Commit a1d50354 authored by Geoffrey Métais's avatar Geoffrey Métais
Browse files

Prevent continuation resume if completed

parent dfb5d9d9
No related branches found
No related tags found
No related merge requests found
Pipeline #5071 passed with stage
in 3 minutes and 51 seconds
......@@ -79,10 +79,8 @@ suspend inline fun <reified T> Context.getFromMl(crossinline block: Medialibrary
else suspendCancellableCoroutine { continuation ->
val listener = object : Medialibrary.OnMedialibraryReadyListener {
override fun onMedialibraryReady() {
if (!continuation.isCancelled) {
continuation.resume(block.invoke(ml))
let { launch { ml.removeOnMedialibraryReadyListener(it) } }
}
if (!continuation.isCompleted) continuation.resume(block.invoke(ml))
let { launch { ml.removeOnMedialibraryReadyListener(it) } }
}
override fun onMedialibraryIdle() {}
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment