[Android] Display the videos time and progress on the TV home screen

Nicolas Pomepuy git at videolan.org
Wed Feb 9 14:56:38 UTC 2022


vlc-android | branch: master | Nicolas Pomepuy <nicolas at videolabs.io> | Thu Jan 20 13:20:10 2022 +0100| [4e590b657ca205b6d39235cac2336594b4112694] | committer: Nicolas Pomepuy

Display the videos time and progress on the TV home screen

> https://code.videolan.org/videolan/vlc-android/commit/4e590b657ca205b6d39235cac2336594b4112694
---

 .../src/main/java/org/videolan/television/ui/CardPresenter.kt    | 6 +++++-
 medialibrary/src/org/videolan/medialibrary/Tools.java            | 9 +++------
 2 files changed, 8 insertions(+), 7 deletions(-)

diff --git a/application/television/src/main/java/org/videolan/television/ui/CardPresenter.kt b/application/television/src/main/java/org/videolan/television/ui/CardPresenter.kt
index f3233c731..9642c032b 100644
--- a/application/television/src/main/java/org/videolan/television/ui/CardPresenter.kt
+++ b/application/television/src/main/java/org/videolan/television/ui/CardPresenter.kt
@@ -141,6 +141,7 @@ class CardPresenter(private val context: Activity, private val isPoster: Boolean
         val holder = viewHolder as ViewHolder
         when (item) {
             is MediaWrapper -> {
+                Tools.setMediaDescription(item)
                 holder.cardView.titleText = item.title
                 holder.cardView.contentText = item.description
                 holder.updateCardViewImage(item)
@@ -191,7 +192,10 @@ class CardPresenter(private val context: Activity, private val isPoster: Boolean
             val media = item as MediaLibraryItem
             for (data in payloads) {
                 when (data as Int) {
-                    UPDATE_DESCRIPTION -> holder.cardView.contentText = media.description
+                    UPDATE_DESCRIPTION -> {
+                        Tools.setMediaDescription(item)
+                        holder.cardView.contentText = media.description
+                    }
                     UPDATE_THUMB -> loadImage(holder.cardView, media)
                     UPDATE_TIME -> {
                         val mediaWrapper = item as MediaWrapper
diff --git a/medialibrary/src/org/videolan/medialibrary/Tools.java b/medialibrary/src/org/videolan/medialibrary/Tools.java
index 720c68c9e..6faf811d8 100644
--- a/medialibrary/src/org/videolan/medialibrary/Tools.java
+++ b/medialibrary/src/org/videolan/medialibrary/Tools.java
@@ -88,18 +88,15 @@ public class Tools {
             final MediaWrapper mw = (MediaWrapper) item;
             if (mw.getType() == MediaWrapper.TYPE_VIDEO) {
                 final String progress = mw.getLength() == 0L ? null : mw.getTime() == 0L ? Tools.millisToString(mw.getLength()) : getProgressText(mw);
-                final String resolution = getResolution(mw);
-                boolean hasprogress = !TextUtils.isEmpty(progress), hasResolution = !TextUtils.isEmpty(resolution);
+                boolean hasprogress = !TextUtils.isEmpty(progress);
                 final StringBuilder sb = new StringBuilder();
-                if (hasprogress && hasResolution) sb.append(resolution).append(" - ").append(progress);
-                else if (hasprogress) sb.append(progress);
-                else sb.append(resolution);
+                if (hasprogress) sb.append(progress); else sb.append(Tools.millisToString(mw.getLength()));
                 item.setDescription(sb.toString());
             } else if (mw.getType() == MediaWrapper.TYPE_AUDIO) {
                 final String artist = mw.getReferenceArtist(), album = mw.getAlbum();
                 final StringBuilder sb = new StringBuilder();
                 boolean hasArtist = !TextUtils.isEmpty(artist), hasAlbum = !TextUtils.isEmpty(album);
-                if (hasArtist && hasAlbum) sb.append(artist).append(" - ").append(album);
+                if (hasArtist && hasAlbum) sb.append(artist).append(" ยท ").append(album);
                 else if (hasArtist) sb.append(artist);
                 else sb.append(album);
                 item.setDescription(sb.toString());



More information about the Android mailing list