[Android] Medialibrary: set album getDuration return to Long

Duncan McNamara git at videolan.org
Wed Jul 10 15:05:51 CEST 2019


vlc-android | branch: master | Duncan McNamara <dcn.mcnamara at gmail.com> | Mon Jul  8 15:59:21 2019 +0200| [9f6030862402eaff0a019f95d96eeab02daf270e] | committer: Geoffrey Métais

Medialibrary: set album getDuration return to Long

Album durations were Integers were as media durations were Longs.

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

 .../videolan/medialibrary/interfaces/media/AbstractAlbum.java  |  8 ++++----
 .../src/org/videolan/medialibrary/stubs/StubDataSource.java    |  2 +-
 vlc-android/src/org/videolan/vlc/util/ModelsHelper.kt          | 10 +++++-----
 3 files changed, 10 insertions(+), 10 deletions(-)

diff --git a/medialibrary/src/org/videolan/medialibrary/interfaces/media/AbstractAlbum.java b/medialibrary/src/org/videolan/medialibrary/interfaces/media/AbstractAlbum.java
index 747b47f1d..054178e32 100644
--- a/medialibrary/src/org/videolan/medialibrary/interfaces/media/AbstractAlbum.java
+++ b/medialibrary/src/org/videolan/medialibrary/interfaces/media/AbstractAlbum.java
@@ -20,7 +20,7 @@ public abstract class AbstractAlbum extends MediaLibraryItem {
     protected String albumArtist;
     protected long albumArtistId;
     protected int mTracksCount;
-    protected int duration;
+    protected long duration;
 
     public AbstractAlbum(long id, String title, int releaseYear, String artworkMrl, String albumArtist, long albumArtistId, int nbTracks, int duration) {
         super(id, title);
@@ -45,7 +45,7 @@ public abstract class AbstractAlbum extends MediaLibraryItem {
         this.albumArtist = in.readString();
         this.albumArtistId = in.readLong();
         this.mTracksCount = in.readInt();
-        this.duration = in.readInt();
+        this.duration = in.readLong();
     }
 
     abstract public int getRealTracksCount();
@@ -79,7 +79,7 @@ public abstract class AbstractAlbum extends MediaLibraryItem {
         return mTracksCount;
     }
 
-    public int getDuration() {
+    public long getDuration() {
         return duration;
     }
 
@@ -114,6 +114,6 @@ public abstract class AbstractAlbum extends MediaLibraryItem {
         parcel.writeString(albumArtist);
         parcel.writeLong(albumArtistId);
         parcel.writeInt(mTracksCount);
-        parcel.writeInt(duration);
+        parcel.writeLong(duration);
     }
 }
diff --git a/medialibrary/src/org/videolan/medialibrary/stubs/StubDataSource.java b/medialibrary/src/org/videolan/medialibrary/stubs/StubDataSource.java
index a7d50eb3e..255b6981d 100644
--- a/medialibrary/src/org/videolan/medialibrary/stubs/StubDataSource.java
+++ b/medialibrary/src/org/videolan/medialibrary/stubs/StubDataSource.java
@@ -164,7 +164,7 @@ public class StubDataSource {
                 case SORT_DEFAULT:
                 case SORT_ALBUM: return o1.getTitle().compareTo(o2.getTitle());
                 case SORT_RELEASEDATE: return o1.getReleaseYear() - o2.getReleaseYear();
-                case SORT_DURATION: return o1.getDuration() - o2.getDuration();
+                case SORT_DURATION: return (int)(o1.getDuration() - o2.getDuration());
                 default: return 0;
             }
         }
diff --git a/vlc-android/src/org/videolan/vlc/util/ModelsHelper.kt b/vlc-android/src/org/videolan/vlc/util/ModelsHelper.kt
index ee8dbe3ec..d2f3eccae 100644
--- a/vlc-android/src/org/videolan/vlc/util/ModelsHelper.kt
+++ b/vlc-android/src/org/videolan/vlc/util/ModelsHelper.kt
@@ -191,17 +191,17 @@ object ModelsHelper {
             && (item.id == 1L || item.id == 2L) || item.itemType == MediaLibraryItem.TYPE_ALBUM
             && item.title == AbstractAlbum.SpecialRes.UNKNOWN_ALBUM
 
-    private fun getLength(media: MediaLibraryItem): Int {
+    private fun getLength(media: MediaLibraryItem): Long {
         return when {
             media.itemType == MediaLibraryItem.TYPE_ALBUM -> (media as AbstractAlbum).duration
-            media.itemType == MediaLibraryItem.TYPE_MEDIA -> (media as AbstractMediaWrapper).length.toInt()
-            else -> 0
+            media.itemType == MediaLibraryItem.TYPE_MEDIA -> (media as AbstractMediaWrapper).length
+            else -> 0L
         }
     }
 
-    private fun lengthToCategory(length: Int): String {
+    private fun lengthToCategory(length: Long): String {
         val value: Int
-        if (length == 0) return "-"
+        if (length == 0L) return "-"
         if (length < 60000) return "< 1 min"
         if (length < 600000) {
             value = Math.floor((length / 60000).toDouble()).toInt()



More information about the Android mailing list