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

Medialibrary: Fix ConcurrentAccessException

parent eda18539
No related branches found
No related tags found
No related merge requests found
......@@ -73,8 +73,9 @@ suspend inline fun <reified T> Context.getFromMl(crossinline block: Medialibrary
else suspendCoroutine { continuation ->
ml.addOnMedialibraryReadyListener(object : Medialibrary.OnMedialibraryReadyListener {
override fun onMedialibraryReady() {
ml.removeOnMedialibraryReadyListener(this)
val listener = this
continuation.resume(block.invoke(ml))
launch { ml.removeOnMedialibraryReadyListener(listener) }
}
override fun onMedialibraryIdle() {}
})
......
......@@ -60,8 +60,11 @@ suspend fun updatePrograms(context: Context, channelId: Long) {
ml.addOnMedialibraryReadyListener(object : Medialibrary.OnMedialibraryReadyListener {
override fun onMedialibraryIdle() {}
override fun onMedialibraryReady() {
ml.removeOnMedialibraryReadyListener(this)
GlobalScope.launch { updatePrograms(context, channelId) }
val listener = this
GlobalScope.launch {
ml.removeOnMedialibraryReadyListener(listener)
updatePrograms(context, channelId)
}
}
})
......
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