[Android] Revert "Set a fixed threadpool of image retrieval"
Geoffrey Métais
git at videolan.org
Wed Feb 20 09:43:09 CET 2019
vlc-android | branch: master | Geoffrey Métais <geoffrey.metais at gmail.com> | Tue Feb 19 18:14:01 2019 +0100| [61bf6ad41780cb529e8c2044cb3d821dc7d85865] | committer: Geoffrey Métais
Revert "Set a fixed threadpool of image retrieval"
This reverts commit 984bf7b537dae3ab2761d2c2455c894fa3050a0b.
> https://code.videolan.org/videolan/vlc-android/commit/61bf6ad41780cb529e8c2044cb3d821dc7d85865
---
vlc-android/src/org/videolan/vlc/gui/helpers/ImageLoader.kt | 11 ++++-------
1 file changed, 4 insertions(+), 7 deletions(-)
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 21a2ae49a..73b225f56 100644
--- a/vlc-android/src/org/videolan/vlc/gui/helpers/ImageLoader.kt
+++ b/vlc-android/src/org/videolan/vlc/gui/helpers/ImageLoader.kt
@@ -14,7 +14,6 @@ import androidx.databinding.OnRebindCallback
import androidx.databinding.ViewDataBinding
import androidx.leanback.widget.ImageCardView
import kotlinx.coroutines.Dispatchers
-import kotlinx.coroutines.asCoroutineDispatcher
import kotlinx.coroutines.launch
import kotlinx.coroutines.withContext
import org.videolan.medialibrary.media.Folder
@@ -25,12 +24,10 @@ import org.videolan.vlc.VLCApplication
import org.videolan.vlc.util.AppScope
import org.videolan.vlc.util.HttpImageLoader
import org.videolan.vlc.util.ThumbnailsProvider
-import java.util.concurrent.Executors
private val sBitmapCache = BitmapCache.getInstance()
private val sMedialibrary = VLCApplication.getMLInstance()
private const val TAG = "ImageLoader"
-private val dispatcher = Executors.newFixedThreadPool(1).asCoroutineDispatcher()
@MainThread
@BindingAdapter("media")
@@ -78,10 +75,10 @@ private suspend fun getImage(v: View, item: MediaLibraryItem, binding: ViewDataB
binding?.removeOnRebindCallback(rebindCallbacks!!)
}
-private suspend fun obtainBitmap(item: MediaLibraryItem, width: Int) = withContext(dispatcher) {
- when (item) {
- is MediaWrapper -> ThumbnailsProvider.getMediaThumbnail(item, width)
- is Folder -> ThumbnailsProvider.getFolderThumbnail(item, width)
+private suspend fun obtainBitmap(item: MediaLibraryItem, width: Int) = withContext(Dispatchers.IO) {
+ when {
+ item is MediaWrapper -> ThumbnailsProvider.getMediaThumbnail(item, width)
+ item is Folder -> ThumbnailsProvider.getFolderThumbnail(item, width)
else -> AudioUtil.readCoverBitmap(Uri.decode(item.artworkMrl), width)
}
}
More information about the Android
mailing list