[Android] Prevent continuation resume if completed
Geoffrey Métais
git at videolan.org
Tue Feb 26 14:59:42 CET 2019
vlc-android | branch: master | Geoffrey Métais <geoffrey.metais at gmail.com> | Tue Feb 26 14:56:15 2019 +0100| [a1d50354330b4d628e8f7e2b6c53f3592f68b79f] | committer: Geoffrey Métais
Prevent continuation resume if completed
> https://code.videolan.org/videolan/vlc-android/commit/a1d50354330b4d628e8f7e2b6c53f3592f68b79f
---
vlc-android/src/org/videolan/vlc/util/Kextensions.kt | 6 ++----
1 file changed, 2 insertions(+), 4 deletions(-)
diff --git a/vlc-android/src/org/videolan/vlc/util/Kextensions.kt b/vlc-android/src/org/videolan/vlc/util/Kextensions.kt
index a47066b22..f16a92550 100644
--- a/vlc-android/src/org/videolan/vlc/util/Kextensions.kt
+++ b/vlc-android/src/org/videolan/vlc/util/Kextensions.kt
@@ -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() {}
}
More information about the Android
mailing list