[Android] Fix last playlist saved in the wrong preference

Geoffrey Métais git at videolan.org
Tue Apr 21 14:22:48 CEST 2020


vlc-android | branch: master | Geoffrey Métais <geoffrey.metais at gmail.com> | Mon Apr 20 15:22:39 2020 +0200| [584acc7f632efcf5327bc229997a5be41aeeaa8f] | committer: Nicolas Pomepuy

Fix last playlist saved in the wrong preference

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

 .../vlc-android/src/org/videolan/vlc/media/PlaylistManager.kt       | 6 +++---
 1 file changed, 3 insertions(+), 3 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 f5ab87e07..a5479891d 100644
--- a/application/vlc-android/src/org/videolan/vlc/media/PlaylistManager.kt
+++ b/application/vlc-android/src/org/videolan/vlc/media/PlaylistManager.kt
@@ -161,7 +161,7 @@ class PlaylistManager(val service: PlaybackService) : MediaWrapperList.EventList
         }
         val locations = settings.getString(if (audio) KEY_AUDIO_LAST_PLAYLIST else KEY_MEDIA_LAST_PLAYLIST, null)
                 ?.split(" ".toRegex())?.dropLastWhile { it.isEmpty() }?.toTypedArray()
-        if (locations?.isNotEmpty() != true) {
+        if (locations.isNullOrEmpty()) {
             loadingLastPlaylist = false
             return false
         }
@@ -485,7 +485,7 @@ class PlaylistManager(val service: PlaybackService) : MediaWrapperList.EventList
     private fun saveCurrentMedia() {
         val media = getCurrentMedia() ?: return
         val isAudio = isAudioList()
-        settings.putSingle(if (isAudio) "current_song" else "current_media", media.location)
+        settings.putSingle(if (isAudio) KEY_CURRENT_AUDIO else KEY_CURRENT_MEDIA, media.location)
     }
 
     private suspend fun saveMediaList() {
@@ -495,7 +495,7 @@ class PlaylistManager(val service: PlaybackService) : MediaWrapperList.EventList
             val list = mediaList.copy.takeIf { it.isNotEmpty() } ?: return at withContext
             for (mw in list) locations.append(" ").append(mw.uri.toString())
             //We save a concatenated String because putStringSet is APIv11.
-            settings.putSingle(if (isAudioList()) KEY_CURRENT_AUDIO else KEY_CURRENT_MEDIA, locations.toString().trim())
+            settings.putSingle(if (isAudioList()) KEY_AUDIO_LAST_PLAYLIST else KEY_MEDIA_LAST_PLAYLIST, locations.toString().trim())
         }
     }
 



More information about the Android mailing list