[Android] Fix IllegalArgumentException
Nicolas Pomepuy
git at videolan.org
Fri Aug 13 09:01:32 UTC 2021
vlc-android | branch: master | Nicolas Pomepuy <nicolas at videolabs.io> | Fri Aug 13 07:48:59 2021 +0200| [a89d6e7bc86ae7c7dac34abbc3f133c471531a01] | committer: Nicolas Pomepuy
Fix IllegalArgumentException
> https://code.videolan.org/videolan/vlc-android/commit/a89d6e7bc86ae7c7dac34abbc3f133c471531a01
---
.../src/org/videolan/vlc/media/PlaylistManager.kt | 14 ++++++++++----
1 file changed, 10 insertions(+), 4 deletions(-)
diff --git a/application/vlc-android/src/org/videolan/vlc/media/PlaylistManager.kt b/application/vlc-android/src/org/videolan/vlc/media/PlaylistManager.kt
index 66f99a00f..32123a881 100644
--- a/application/vlc-android/src/org/videolan/vlc/media/PlaylistManager.kt
+++ b/application/vlc-android/src/org/videolan/vlc/media/PlaylistManager.kt
@@ -630,16 +630,22 @@ class PlaylistManager(val service: PlaybackService) : MediaWrapperList.EventList
}
}
- fun previousTotalTime() = if (shuffling) {
- mediaList.copy.asSequence()
+ fun previousTotalTime() = when {
+ mediaList.size() == 0 -> {
+ 0
+ }
+ shuffling -> {
+ mediaList.copy.asSequence()
.filterIndexed { index, _ -> previous.contains(index) }
.map { it.length }
.sum()
- } else {
- mediaList.copy.asSequence()
+ }
+ else -> {
+ mediaList.copy.asSequence()
.take(currentIndex)
.map { it.length }
.sum()
+ }
}
/**
More information about the Android
mailing list