[Android] Add media length to description

Geoffrey Métais git at videolan.org
Wed Feb 14 17:36:30 CET 2018


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

Add media length to description

(cherry picked from commit 5dc7a3f39a7c8d6007c23d53f754f9beb29a683e)

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

 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