Skip to content
Snippets Groups Projects
Commit 5a7fd027 authored by Nicolas Pomepuy's avatar Nicolas Pomepuy
Browse files

Fix Playlist cover not loading

parent 6b66c407
No related branches found
No related tags found
1 merge request!154Fix Playlist cover not loading
Pipeline #7910 passed with stage
in 3 minutes and 43 seconds
...@@ -58,18 +58,17 @@ ...@@ -58,18 +58,17 @@
</FrameLayout> </FrameLayout>
<ImageView <ImageView
android:id="@+id/cover" android:id="@+id/cover"
android:layout_width="0dp" android:layout_width="0dp"
android:layout_height="90dp" android:layout_height="90dp"
android:layout_marginStart="@dimen/tv_overscan_horizontal" android:layout_marginStart="@dimen/tv_overscan_horizontal"
android:layout_marginBottom="8dp" android:layout_marginBottom="8dp"
android:background="@{cover}" app:imageWidth="@{imageWidth}"
app:imageWidth="@{imageWidth}" app:layout_constraintBottom_toBottomOf="@+id/frameLayout"
app:layout_constraintBottom_toBottomOf="@+id/frameLayout" app:layout_constraintDimensionRatio="1"
app:layout_constraintDimensionRatio="1" app:layout_constraintStart_toStartOf="parent"
app:layout_constraintStart_toStartOf="parent" app:media="@{item}"
app:mediaWithWidth="@{item}" tools:srcCompat="@tools:sample/avatars"/>
tools:srcCompat="@tools:sample/avatars" />
<TextView <TextView
android:id="@+id/albumTitle" android:id="@+id/albumTitle"
......
...@@ -43,9 +43,15 @@ private const val TAG = "ImageLoader" ...@@ -43,9 +43,15 @@ private const val TAG = "ImageLoader"
@MainThread @MainThread
@BindingAdapter(value = ["media", "imageWidth"], requireAll = false) @BindingAdapter(value = ["media", "imageWidth"], requireAll = false)
fun loadImage(v: View, item: MediaLibraryItem?, imageWidth: Int = 0) { fun loadImage(v: View, item: MediaLibraryItem?, imageWidth: Int = 0) {
if (item === null if (item === null) return
|| item.itemType == MediaLibraryItem.TYPE_PLAYLIST)
if (item.itemType == MediaLibraryItem.TYPE_PLAYLIST) {
if (imageWidth != 0) {
loadPlaylistImageWithWidth(v as ImageView, item, imageWidth)
}
return return
}
val binding = DataBindingUtil.findBinding<ViewDataBinding>(v) val binding = DataBindingUtil.findBinding<ViewDataBinding>(v)
if (item.itemType == MediaLibraryItem.TYPE_GENRE && !isForTV(binding)) { if (item.itemType == MediaLibraryItem.TYPE_GENRE && !isForTV(binding)) {
return return
...@@ -67,8 +73,6 @@ fun loadImage(v: View, item: MediaLibraryItem?, imageWidth: Int = 0) { ...@@ -67,8 +73,6 @@ fun loadImage(v: View, item: MediaLibraryItem?, imageWidth: Int = 0) {
else AppScope.launch { getImage(v, findInLibrary(item, isMedia, isGroup), binding, imageWidth) } else AppScope.launch { getImage(v, findInLibrary(item, isMedia, isGroup), binding, imageWidth) }
} }
@MainThread
@BindingAdapter(value = ["bind:mediaWithWidth", "bind:imageWidth"], requireAll = true)
fun loadPlaylistImageWithWidth(v: ImageView, item: MediaLibraryItem?, imageWidth: Int) { fun loadPlaylistImageWithWidth(v: ImageView, item: MediaLibraryItem?, imageWidth: Int) {
if (imageWidth == 0) return if (imageWidth == 0) return
if (item == null) return if (item == null) return
...@@ -100,7 +104,6 @@ fun placeHolderView(v: View, item: MediaLibraryItem?) { ...@@ -100,7 +104,6 @@ fun placeHolderView(v: View, item: MediaLibraryItem?) {
} else { } else {
v.background = null v.background = null
} }
} }
fun isForTV(binding: ViewDataBinding?) = (binding is MediaBrowserTvItemBinding) || binding is MediaBrowserTvItemBinding fun isForTV(binding: ViewDataBinding?) = (binding is MediaBrowserTvItemBinding) || binding is MediaBrowserTvItemBinding
...@@ -113,7 +116,6 @@ fun placeHolderImageView(v: View, item: MediaLibraryItem?) { ...@@ -113,7 +116,6 @@ fun placeHolderImageView(v: View, item: MediaLibraryItem?) {
} else { } else {
v.background = UiTools.getDefaultAudioDrawable(v.context) v.background = UiTools.getDefaultAudioDrawable(v.context)
} }
} }
@BindingAdapter("icvTitle") @BindingAdapter("icvTitle")
...@@ -190,7 +192,6 @@ private suspend fun getPlaylistImage(v: View, item: MediaLibraryItem, binding: V ...@@ -190,7 +192,6 @@ private suspend fun getPlaylistImage(v: View, item: MediaLibraryItem, binding: V
binding.addOnRebindCallback(rebindCallbacks!!) binding.addOnRebindCallback(rebindCallbacks!!)
} }
var playlistImage = if (!bindChanged) ThumbnailsProvider.getPlaylistImage("playlist:${item.id}", item.tracks.toList(), width) else null var playlistImage = if (!bindChanged) ThumbnailsProvider.getPlaylistImage("playlist:${item.id}", item.tracks.toList(), width) else null
if (!bindChanged && playlistImage == null) playlistImage = UiTools.getDefaultAudioDrawable(VLCApplication.appContext).bitmap if (!bindChanged && playlistImage == null) playlistImage = UiTools.getDefaultAudioDrawable(VLCApplication.appContext).bitmap
if (!bindChanged) updateImageView(playlistImage, v, binding) if (!bindChanged) updateImageView(playlistImage, v, binding)
...@@ -198,7 +199,6 @@ private suspend fun getPlaylistImage(v: View, item: MediaLibraryItem, binding: V ...@@ -198,7 +199,6 @@ private suspend fun getPlaylistImage(v: View, item: MediaLibraryItem, binding: V
binding?.removeOnRebindCallback(rebindCallbacks!!) binding?.removeOnRebindCallback(rebindCallbacks!!)
} }
@MainThread @MainThread
fun updateImageView(bitmap: Bitmap?, target: View, vdb: ViewDataBinding?) { fun updateImageView(bitmap: Bitmap?, target: View, vdb: ViewDataBinding?) {
if (bitmap === null || bitmap.width <= 1 || bitmap.height <= 1) return if (bitmap === null || bitmap.width <= 1 || bitmap.height <= 1) return
......
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