[Android] Add media length to description

Geoffrey Métais git at videolan.org
Tue Feb 13 15:17:29 CET 2018


vlc-android | branch: master | Geoffrey Métais <geoffrey.metais at gmail.com> | Tue Feb 13 15:16:42 2018 +0100| [5dc7a3f39a7c8d6007c23d53f754f9beb29a683e] | committer: Geoffrey Métais

Add media length to description

> https://code.videolan.org/videolan/vlc-android/commit/5dc7a3f39a7c8d6007c23d53f754f9beb29a683e
---

 medialibrary/src/org/videolan/medialibrary/Tools.java | 9 ++++-----
 1 file changed, 4 insertions(+), 5 deletions(-)

diff --git a/medialibrary/src/org/videolan/medialibrary/Tools.java b/medialibrary/src/org/videolan/medialibrary/Tools.java
index efd5ddbc6..2a59ca6e8 100644
--- a/medialibrary/src/org/videolan/medialibrary/Tools.java
+++ b/medialibrary/src/org/videolan/medialibrary/Tools.java
@@ -38,8 +38,7 @@ public class Tools {
     }
     public static String getProgressText(MediaWrapper media) {
         long lastTime = media.getTime();
-        if (lastTime == 0L)
-            return "";
+        if (lastTime == 0L) return "";
         return String.format("%s / %s",
                 millisToString(lastTime, true, false),
                 millisToString(media.getLength(), true, false));
@@ -71,10 +70,10 @@ public class Tools {
 
     public static void setMediaDescription (MediaLibraryItem item) {
         if (item.getItemType() == MediaLibraryItem.TYPE_MEDIA) {
-            MediaWrapper mw = (MediaWrapper) item;
+            final MediaWrapper mw = (MediaWrapper) item;
             if (mw.getType() == MediaWrapper.TYPE_VIDEO) {
-                String progress = getProgressText(mw);
-                String resolution = getResolution(mw);
+                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);
                 if (hasprogress && hasResolution)
                     item.setDescription(resolution+" - "+progress);



More information about the Android mailing list