[Android] Settings: Fix putStringSet call

Geoffrey Métais git at videolan.org
Fri Mar 27 07:42:19 CET 2020


vlc-android | branch: master | Geoffrey Métais <geoffrey.metais at gmail.com> | Wed Mar 25 17:51:43 2020 +0100| [b8b0cc652d504961788cf7c47455bd3beac54437] | committer: Nicolas Pomepuy

Settings: Fix putStringSet call

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

 application/tools/src/main/java/org/videolan/tools/Settings.kt          | 1 +
 .../vlc-android/src/org/videolan/vlc/viewmodels/SubtitlesModel.kt       | 2 +-
 2 files changed, 2 insertions(+), 1 deletion(-)

diff --git a/application/tools/src/main/java/org/videolan/tools/Settings.kt b/application/tools/src/main/java/org/videolan/tools/Settings.kt
index 941bb3c58..5ececa0ce 100644
--- a/application/tools/src/main/java/org/videolan/tools/Settings.kt
+++ b/application/tools/src/main/java/org/videolan/tools/Settings.kt
@@ -113,6 +113,7 @@ fun SharedPreferences.putSingle(key: String, value: Any) {
         is Float -> edit().putFloat(key, value).apply()
         is Long -> edit().putLong(key, value).apply()
         is String -> edit().putString(key, value).apply()
+        is List<*> -> edit().putStringSet(key, value.toSet() as Set<String>).apply()
         else -> throw IllegalArgumentException("value class is invalid!")
     }
 }
diff --git a/application/vlc-android/src/org/videolan/vlc/viewmodels/SubtitlesModel.kt b/application/vlc-android/src/org/videolan/vlc/viewmodels/SubtitlesModel.kt
index 097082530..1807178c9 100644
--- a/application/vlc-android/src/org/videolan/vlc/viewmodels/SubtitlesModel.kt
+++ b/application/vlc-android/src/org/videolan/vlc/viewmodels/SubtitlesModel.kt
@@ -181,7 +181,7 @@ class SubtitlesModel(private val context: Context, private val mediaUri: Uri, va
         return Settings.getInstance(context).getStringSet(LAST_USED_LANGUAGES, setOf(language))?.map { it.getCompliantLanguageID() } ?: emptyList()
     }
 
-    fun saveLastUsedLanguage(lastUsedLanguages: List<String>) = Settings.getInstance(context).putSingle(LAST_USED_LANGUAGES, lastUsedLanguages.toSet())
+    fun saveLastUsedLanguage(lastUsedLanguages: List<String>) = Settings.getInstance(context).putSingle(LAST_USED_LANGUAGES, lastUsedLanguages)
 
     class Factory(private val context: Context, private val mediaUri: Uri): ViewModelProvider.NewInstanceFactory() {
         override fun <T : ViewModel> create(modelClass: Class<T>): T {



More information about the Android mailing list