[Android] Fix image scale issue in video player playlist

Nicolas Pomepuy git at videolan.org
Wed Nov 27 15:26:09 CET 2019


vlc-android | branch: 3.2.x | Nicolas Pomepuy <nicolas.pomepuy at gmail.com> | Mon Nov 25 14:35:21 2019 +0100| [3057d48fa15356d7e5e3c956a0d9c70b8a5094fb] | committer: Geoffrey Métais

Fix image scale issue in video player playlist

Fixes #1095

(cherry picked from commit 2b9990d9f0a20ac1298f7cd11c577808794e9551)

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

 vlc-android/res/layout/playlist_item.xml                      | 7 ++++++-
 vlc-android/src/org/videolan/vlc/gui/audio/PlaylistAdapter.kt | 2 ++
 vlc-android/src/org/videolan/vlc/gui/helpers/ImageLoader.kt   | 3 ++-
 3 files changed, 10 insertions(+), 2 deletions(-)

diff --git a/vlc-android/res/layout/playlist_item.xml b/vlc-android/res/layout/playlist_item.xml
index 2ec3e110f..885096c90 100644
--- a/vlc-android/res/layout/playlist_item.xml
+++ b/vlc-android/res/layout/playlist_item.xml
@@ -27,6 +27,10 @@
                 name="subTitle"
                 type="String"/>
 
+        <variable
+                name="scaleType"
+                type="android.widget.ImageView.ScaleType" />
+
     </data>
 
     <androidx.constraintlayout.widget.ConstraintLayout
@@ -65,7 +69,8 @@
                 app:layout_constraintDimensionRatio="1"
                 android:layout_marginStart="8dp"
                 app:media="@{media}"
-                android:background="@{cover}"
+                android:scaleType="@{scaleType}"
+                android:src="@{cover}"
                 app:layout_constraintTop_toTopOf="parent"
                 app:layout_constraintBottom_toBottomOf="parent"
                 android:layout_marginTop="4dp"
diff --git a/vlc-android/src/org/videolan/vlc/gui/audio/PlaylistAdapter.kt b/vlc-android/src/org/videolan/vlc/gui/audio/PlaylistAdapter.kt
index 5e762af0f..c4de1e6b0 100644
--- a/vlc-android/src/org/videolan/vlc/gui/audio/PlaylistAdapter.kt
+++ b/vlc-android/src/org/videolan/vlc/gui/audio/PlaylistAdapter.kt
@@ -32,6 +32,7 @@ import android.os.Message
 import android.view.LayoutInflater
 import android.view.View
 import android.view.ViewGroup
+import android.widget.ImageView
 import android.widget.Toast
 import androidx.annotation.MainThread
 import androidx.constraintlayout.widget.ConstraintLayout
@@ -106,6 +107,7 @@ class PlaylistAdapter(private val player: IPlayer) : DiffUtilAdapter<AbstractMed
         val media = getItem(position)
         holder.binding.media = media
         holder.binding.subTitle = MediaUtils.getMediaSubtitle(media)
+        holder.binding.scaleType = ImageView.ScaleType.CENTER_CROP
         if (currentIndex == position) {
             if (mModel?.playing != false) holder.binding.playing.start() else holder.binding.playing.stop()
             holder.binding.playing.visibility = View.VISIBLE
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 4611dbe15..99ff44b06 100644
--- a/vlc-android/src/org/videolan/vlc/gui/helpers/ImageLoader.kt
+++ b/vlc-android/src/org/videolan/vlc/gui/helpers/ImageLoader.kt
@@ -33,6 +33,7 @@ import org.videolan.vlc.R
 import org.videolan.vlc.VLCApplication
 import org.videolan.vlc.databinding.AudioBrowserCardItemBinding
 import org.videolan.vlc.databinding.MediaBrowserTvItemBinding
+import org.videolan.vlc.databinding.PlaylistItemBinding
 import org.videolan.vlc.gui.tv.TvUtil
 import org.videolan.vlc.util.AppScope
 import org.videolan.vlc.util.HttpImageLoader
@@ -226,7 +227,7 @@ private suspend fun getImage(v: View, item: MediaLibraryItem, binding: ViewDataB
     binding?.removeOnRebindCallback(rebindCallbacks!!)
 }
 
-private fun isCard(binding: ViewDataBinding?) = binding is AudioBrowserCardItemBinding
+private fun isCard(binding: ViewDataBinding?) = binding is AudioBrowserCardItemBinding || binding is PlaylistItemBinding
 
 private suspend fun getPlaylistImage(v: View, item: MediaLibraryItem, binding: ViewDataBinding?, width: Int) {
     var bindChanged = false



More information about the Android mailing list