Tim Malseed
07/16/2020, 3:37 AMcoroutineScope.launch {
val songs = mutableListOf<Song>()
mediaProvider.findSongs().collect { (song, progress) ->
songs.add(song)
listeners.forEach { listener -> listener.onProgress(progress, song) }
}
listeners.forEach { listener -> listener.onComplete() }
}
The scope is instantiated via CoroutineScope(Dispatchers.Main)
Despite listener.onProgress
being called on the main thread - and successful log messages when it is called, the UI updates I’m making in response don’t seem to have any effect.
Are the listener.onProgress(progress, song)
calls somehow being gathered up and then all executed at the end?
Ooh I think I might be blocking the main thread somewhereoctylFractal
07/16/2020, 3:39 AMfindSongs()
is a Flow, but did you move it off of the main thread while it works?Tim Malseed
07/16/2020, 3:40 AM.flowOn(<http://Dispatchers.IO|Dispatchers.IO>)
call, but I’ve accidentally removed it at some point. That will be it!