[Android] Use pref ellipsize mode in audio and video play queue

Nicolas Pomepuy git at videolan.org
Tue Jan 21 15:14:50 CET 2020


vlc-android | branch: master | Nicolas Pomepuy <nicolas at videolabs.io> | Tue Jan 21 08:01:49 2020 +0100| [8acab5943072d599c87055e595b25a49b424b101] | committer: Nicolas Pomepuy

Use pref ellipsize mode in audio and video play queue

Fixes #1038

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

 vlc-android/res/layout/audio_browser_card_item.xml   |  2 +-
 vlc-android/res/layout/playlist_item.xml             | 20 +++++++++++---------
 .../org/videolan/vlc/gui/audio/PlaylistAdapter.kt    | 13 ++++++++++++-
 3 files changed, 24 insertions(+), 11 deletions(-)

diff --git a/vlc-android/res/layout/audio_browser_card_item.xml b/vlc-android/res/layout/audio_browser_card_item.xml
index 946cec596..bd5d23cfa 100644
--- a/vlc-android/res/layout/audio_browser_card_item.xml
+++ b/vlc-android/res/layout/audio_browser_card_item.xml
@@ -106,7 +106,7 @@
                     vlc:layout_constraintEnd_toStartOf="@+id/item_more"
                     vlc:layout_constraintStart_toStartOf="parent"
                     vlc:layout_constraintTop_toBottomOf="@id/media_cover"
-                    vlc:placeholder="@{item}"/>
+                    vlc:placeholder="@{item}" />
 
             <TextView
                 android:id="@+id/subtitle"
diff --git a/vlc-android/res/layout/playlist_item.xml b/vlc-android/res/layout/playlist_item.xml
index 19f520edc..8da739d30 100644
--- a/vlc-android/res/layout/playlist_item.xml
+++ b/vlc-android/res/layout/playlist_item.xml
@@ -93,22 +93,24 @@
                 android:id="@+id/audio_item_title"
                 android:layout_width="0dp"
                 android:layout_height="wrap_content"
+                android:layout_marginStart="8dp"
+                android:layout_marginTop="4dp"
+                android:layout_marginEnd="8dp"
+                android:gravity="center_vertical"
+                android:maxLines="1"
                 android:paddingLeft="8dp"
                 android:paddingRight="8dp"
                 android:singleLine="true"
-                android:ellipsize="middle"
                 android:text="@{media.title}"
-                android:textSize="14sp"
                 android:textColor="?attr/font_default"
-                app:layout_constraintTop_toTopOf="parent"
-                app:layout_constraintHorizontal_bias="0.5"
+                android:textSize="14sp"
+                app:ellipsizeMode="@{true}"
                 app:layout_constraintBottom_toTopOf="@+id/audio_item_subtitle"
-                android:layout_marginStart="8dp"
-                android:layout_marginEnd="8dp"
-                android:layout_marginTop="4dp"
-                tools:text="Symphonie n°1"
+                app:layout_constraintEnd_toEndOf="@+id/selector"
+                app:layout_constraintHorizontal_bias="0.5"
                 app:layout_constraintStart_toEndOf="@+id/coverImage"
-                app:layout_constraintEnd_toEndOf="@+id/selector"/>
+                app:layout_constraintTop_toTopOf="parent"
+                tools:text="Symphonie n°1" />
 
         <TextView
                 android:id="@+id/audio_item_subtitle"
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 80cea2275..b41a24766 100644
--- a/vlc-android/src/org/videolan/vlc/gui/audio/PlaylistAdapter.kt
+++ b/vlc-android/src/org/videolan/vlc/gui/audio/PlaylistAdapter.kt
@@ -28,6 +28,7 @@ import android.content.Context
 import android.graphics.Typeface
 import android.graphics.drawable.BitmapDrawable
 import android.os.Build
+import android.os.Handler
 import android.os.Message
 import android.view.LayoutInflater
 import android.view.View
@@ -44,11 +45,14 @@ import kotlinx.coroutines.ObsoleteCoroutinesApi
 import org.videolan.libvlc.util.AndroidUtil
 import org.videolan.medialibrary.interfaces.media.MediaWrapper
 import org.videolan.resources.AppContextProvider
+import org.videolan.tools.Settings
 import org.videolan.tools.WeakHandler
 import org.videolan.vlc.R
 import org.videolan.vlc.databinding.PlaylistItemBinding
 import org.videolan.vlc.gui.DiffUtilAdapter
+import org.videolan.vlc.gui.helpers.MarqueeViewHolder
 import org.videolan.vlc.gui.helpers.UiTools
+import org.videolan.vlc.gui.helpers.enableMarqueeEffect
 import org.videolan.vlc.gui.helpers.getBitmapFromDrawable
 import org.videolan.vlc.gui.view.MiniVisualizer
 import org.videolan.vlc.interfaces.SwipeDragHelperAdapter
@@ -65,6 +69,7 @@ class PlaylistAdapter(private val player: IPlayer) : DiffUtilAdapter<MediaWrappe
     private var defaultCoverAudio: BitmapDrawable
     private var model: PlaylistModel? = null
     private var currentPlayingVisu: MiniVisualizer? = null
+    private val handler by lazy(LazyThreadSafetyMode.NONE) { Handler() }
 
     init {
         val ctx = when (player) {
@@ -137,6 +142,11 @@ class PlaylistAdapter(private val player: IPlayer) : DiffUtilAdapter<MediaWrappe
         currentPlayingVisu = null
     }
 
+    override fun onAttachedToRecyclerView(recyclerView: RecyclerView) {
+        super.onAttachedToRecyclerView(recyclerView)
+        if (Settings.listTitleEllipsize == 4) enableMarqueeEffect(recyclerView, handler)
+    }
+
     override fun getItemCount() = dataset.size
 
     @MainThread
@@ -178,8 +188,9 @@ class PlaylistAdapter(private val player: IPlayer) : DiffUtilAdapter<MediaWrappe
     }
 
     inner class ViewHolder @TargetApi(Build.VERSION_CODES.M)
-    constructor(v: View) : RecyclerView.ViewHolder(v) {
+    constructor(v: View) : RecyclerView.ViewHolder(v), MarqueeViewHolder {
         var binding: PlaylistItemBinding = DataBindingUtil.bind(v)!!
+        override val titleView = binding.audioItemTitle
 
         init {
             binding.holder = this



More information about the Android mailing list