[Android] Subtitles: add ellipsize from preferences

Duncan McNamara git at videolan.org
Tue Nov 16 07:09:02 UTC 2021


vlc-android | branch: master | Duncan McNamara <dcn.mcnamara at gmail.com> | Tue Nov  9 19:43:00 2021 +0100| [7c3a4061258078cafe5aaf0e716302346ed0e442] | committer: Nicolas Pomepuy

Subtitles: add ellipsize from preferences

Closes #2244

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

 application/vlc-android/res/layout/video_track_item.xml        |  4 ++++
 .../src/org/videolan/vlc/gui/dialogs/adapters/TrackAdapter.kt  | 10 ++++++++++
 2 files changed, 14 insertions(+)

diff --git a/application/vlc-android/res/layout/video_track_item.xml b/application/vlc-android/res/layout/video_track_item.xml
index 22fa53846..098039ad7 100644
--- a/application/vlc-android/res/layout/video_track_item.xml
+++ b/application/vlc-android/res/layout/video_track_item.xml
@@ -47,6 +47,10 @@
                 android:layout_marginStart="16dp"
                 android:text="@{track.name}"
                 android:textColor="@{selected ? @color/white : @color/white_transparent_50}"
+                android:maxLines="1"
+                android:singleLine="true"
+                app:ellipsizeMode="@{true}"
+                app:selected="@{selected}"
                 app:layout_constraintBottom_toBottomOf="@+id/imageView11"
                 app:layout_constraintEnd_toEndOf="parent"
                 app:layout_constraintHorizontal_bias="0.5"
diff --git a/application/vlc-android/src/org/videolan/vlc/gui/dialogs/adapters/TrackAdapter.kt b/application/vlc-android/src/org/videolan/vlc/gui/dialogs/adapters/TrackAdapter.kt
index 46277810a..40b9b6d55 100644
--- a/application/vlc-android/src/org/videolan/vlc/gui/dialogs/adapters/TrackAdapter.kt
+++ b/application/vlc-android/src/org/videolan/vlc/gui/dialogs/adapters/TrackAdapter.kt
@@ -24,15 +24,19 @@
 
 package org.videolan.vlc.gui.dialogs.adapters
 
+import android.os.Handler
 import android.view.LayoutInflater
 import android.view.ViewGroup
 import androidx.recyclerview.widget.RecyclerView
 import org.videolan.libvlc.MediaPlayer
+import org.videolan.tools.Settings
 import org.videolan.vlc.databinding.VideoTrackItemBinding
+import org.videolan.vlc.gui.helpers.enableMarqueeEffect
 
 class TrackAdapter(private val tracks: Array<MediaPlayer.TrackDescription>, var selectedTrack: MediaPlayer.TrackDescription?) : RecyclerView.Adapter<TrackAdapter.ViewHolder>() {
 
     lateinit var trackSelectedListener: (MediaPlayer.TrackDescription) -> Unit
+    private val handler by lazy(LazyThreadSafetyMode.NONE) { Handler() }
 
     override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): ViewHolder {
         val inflater = LayoutInflater.from(parent.context)
@@ -50,6 +54,12 @@ class TrackAdapter(private val tracks: Array<MediaPlayer.TrackDescription>, var
         holder.bind(tracks[position], tracks[position] == selectedTrack)
     }
 
+    override fun onAttachedToRecyclerView(recyclerView: RecyclerView) {
+        super.onAttachedToRecyclerView(recyclerView)
+        if (Settings.listTitleEllipsize == 4) enableMarqueeEffect(recyclerView, handler)
+    }
+
+
     inner class ViewHolder(val binding: VideoTrackItemBinding) : RecyclerView.ViewHolder(binding.root) {
 
         init {



More information about the Android mailing list