[Android] Minor fixes

Geoffrey Métais git at videolan.org
Mon Dec 16 17:52:59 CET 2019


vlc-android | branch: master | Geoffrey Métais <geoffrey.metais at gmail.com> | Fri Dec  6 12:01:26 2019 +0100| [5a56be3898bde3429220aa6f4f40aaae825b9e7d] | committer: Geoffrey Métais

Minor fixes

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

 .../src/org/videolan/vlc/util/ModelsHelper.kt      | 34 +++++++++++-----------
 .../test/org/videolan/vlc/util/ModelsHelperTest.kt |  2 +-
 .../vlc/viewmodels/mobile/VideosViewModelTest.kt   |  2 +-
 3 files changed, 19 insertions(+), 19 deletions(-)

diff --git a/vlc-android/src/org/videolan/vlc/util/ModelsHelper.kt b/vlc-android/src/org/videolan/vlc/util/ModelsHelper.kt
index 5950d6dab..a9062e1ca 100644
--- a/vlc-android/src/org/videolan/vlc/util/ModelsHelper.kt
+++ b/vlc-android/src/org/videolan/vlc/util/ModelsHelper.kt
@@ -264,23 +264,6 @@ object ModelsHelper {
         else -> 0L
     }
 
-    private fun Long.lengthToCategory(): String {
-        val value: Int
-        if (this == 0L) return "-"
-        if (this < 60000) return "< 1 min"
-        if (this < 600000) {
-            value = floor((this / 60000).toDouble()).toInt()
-            return "$value - ${(value + 1)} min"
-        }
-        return if (this < 3600000) {
-            value = (10 * floor((this / 600000).toDouble())).toInt()
-            "$value - ${(value + 10)} min"
-        } else {
-            value = floor((this / 3600000).toDouble()).toInt()
-            "$value - ${(value + 1)} h"
-        }
-    }
-
     private fun MediaLibraryItem.getYear() = when (itemType) {
         MediaLibraryItem.TYPE_ALBUM -> if ((this as AbstractAlbum).releaseYear <= 0) "-" else releaseYear.toString()
         MediaLibraryItem.TYPE_MEDIA -> if ((this as AbstractMediaWrapper).releaseYear <= 0) "-" else releaseYear.toString()
@@ -294,6 +277,23 @@ object ModelsHelper {
     }
 }
 
+fun Long.lengthToCategory(): String {
+    val value: Int
+    if (this == 0L) return "-"
+    if (this < 60000) return "< 1 min"
+    if (this < 600000) {
+        value = floor((this / 60000).toDouble()).toInt()
+        return "$value - ${(value + 1)} min"
+    }
+    return if (this < 3600000) {
+        value = (10 * floor((this / 600000).toDouble())).toInt()
+        "$value - ${(value + 10)} min"
+    } else {
+        value = floor((this / 3600000).toDouble()).toInt()
+        "$value - ${(value + 1)} h"
+    }
+}
+
 object EmptyPBSCallback : PlaybackService.Callback {
     override fun update() {}
     override fun onMediaEvent(event: IMedia.Event) {}
diff --git a/vlc-android/test/org/videolan/vlc/util/ModelsHelperTest.kt b/vlc-android/test/org/videolan/vlc/util/ModelsHelperTest.kt
index 01108b71b..8f88c0ef8 100644
--- a/vlc-android/test/org/videolan/vlc/util/ModelsHelperTest.kt
+++ b/vlc-android/test/org/videolan/vlc/util/ModelsHelperTest.kt
@@ -69,7 +69,7 @@ class ModelsHelperTest : BaseTest() {
     @Test
     fun withDurationSortingAndPreviousItemIsNullAndCurrentItemIsAlbum_headerShouldBeLengthToCategory() {
         val item = MLServiceLocator.getAbstractAlbum(dataSource.uuid, "Abc", 2018, "Artwork", "Dummy", 9, 1, 48000)
-        assertEquals(ModelsHelper.lengthToCategory(item.duration), getHeader(context, Medialibrary.SORT_DURATION, item, null))
+        assertEquals(item.duration.lengthToCategory(), getHeader(context, Medialibrary.SORT_DURATION, item, null))
     }
 
     @Test
diff --git a/vlc-android/test/org/videolan/vlc/viewmodels/mobile/VideosViewModelTest.kt b/vlc-android/test/org/videolan/vlc/viewmodels/mobile/VideosViewModelTest.kt
index 06f7c7e58..202bf4416 100644
--- a/vlc-android/test/org/videolan/vlc/viewmodels/mobile/VideosViewModelTest.kt
+++ b/vlc-android/test/org/videolan/vlc/viewmodels/mobile/VideosViewModelTest.kt
@@ -21,7 +21,7 @@ class VideosViewModelTest : BaseTest() {
     }
 
     private fun setupViewModel(folder: AbstractFolder?) {
-        videosViewModel = VideosViewModel(context, folder)
+        videosViewModel = VideosViewModel(context, VideoGroupingType.NONE, folder, null)
     }
 
     @Test



More information about the Android mailing list