[Android] ImageLoader: remove IO ops from main thread

Geoffrey Métais git at videolan.org
Thu Sep 12 16:34:34 CEST 2019


vlc-android | branch: master | Geoffrey Métais <geoffrey.metais at gmail.com> | Thu Sep 12 15:32:44 2019 +0200| [c5876803152c0fa32c7efa31c8f0dedfa070a489] | committer: Geoffrey Métais

ImageLoader: remove IO ops from main thread

> https://code.videolan.org/videolan/vlc-android/commit/c5876803152c0fa32c7efa31c8f0dedfa070a489
---

 vlc-android/src/org/videolan/vlc/gui/helpers/ImageLoader.kt | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/vlc-android/src/org/videolan/vlc/gui/helpers/ImageLoader.kt b/vlc-android/src/org/videolan/vlc/gui/helpers/ImageLoader.kt
index 8bb6e4e28..5e16dbab5 100644
--- a/vlc-android/src/org/videolan/vlc/gui/helpers/ImageLoader.kt
+++ b/vlc-android/src/org/videolan/vlc/gui/helpers/ImageLoader.kt
@@ -241,7 +241,10 @@ private suspend fun getPlaylistImage(v: View, item: MediaLibraryItem, binding: V
         binding.addOnRebindCallback(rebindCallbacks!!)
     }
 
-    var playlistImage = if (!bindChanged) ThumbnailsProvider.getPlaylistImage("playlist:${item.id}", item.tracks.toList(), width) else null
+    var playlistImage = if (!bindChanged) {
+        val tracks = withContext(Dispatchers.IO) { item.tracks.toList() }
+        ThumbnailsProvider.getPlaylistImage("playlist:${item.id}", tracks, width)
+    } else null
     if (!bindChanged && playlistImage == null) playlistImage = UiTools.getDefaultAudioDrawable(VLCApplication.appContext).bitmap
     if (!bindChanged) updateImageView(playlistImage, v, binding)
 



More information about the Android mailing list