music: fix settings update insanity
For some reason StringSet updates will simply not go to the listener. Despite it working just fine in previous versions. I have to derialize all the location to a string and use that.
This commit is contained in:
@@ -19,7 +19,6 @@
|
||||
package org.oxycblt.auxio.music
|
||||
|
||||
import android.content.Context
|
||||
import android.net.Uri
|
||||
import androidx.core.content.edit
|
||||
import dagger.hilt.android.qualifiers.ApplicationContext
|
||||
import javax.inject.Inject
|
||||
@@ -55,21 +54,19 @@ interface MusicSettings : Settings<MusicSettings.Listener> {
|
||||
|
||||
class MusicSettingsImpl @Inject constructor(@ApplicationContext private val context: Context) :
|
||||
Settings.Impl<MusicSettings.Listener>(context), MusicSettings {
|
||||
|
||||
override var musicLocations: List<MusicLocation>
|
||||
get() {
|
||||
val dirs =
|
||||
sharedPreferences.getStringSet(getString(R.string.set_key_music_locations), null) ?:
|
||||
emptySet()
|
||||
return dirs.mapNotNull {
|
||||
MusicLocation.existing(context, Uri.parse(it))
|
||||
}
|
||||
val locations =
|
||||
sharedPreferences.getString(getString(R.string.set_key_music_locations), null)
|
||||
?: return emptyList()
|
||||
return MusicLocation.existing(context, locations)
|
||||
}
|
||||
set(value) {
|
||||
sharedPreferences.edit {
|
||||
putStringSet(
|
||||
getString(R.string.set_key_music_locations),
|
||||
value.map { it.toString() }.toSet())
|
||||
apply()
|
||||
putString(
|
||||
getString(R.string.set_key_music_locations), MusicLocation.toString(value))
|
||||
this@edit.apply()
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -59,10 +59,7 @@ class MusicSourcesDialog :
|
||||
.setNegativeButton(R.string.lbl_cancel, null)
|
||||
.setPositiveButton(R.string.lbl_save) { _, _ ->
|
||||
val newDirs = locationAdapter.locations
|
||||
if (musicSettings.musicLocations != newDirs) {
|
||||
L.d("Committing changes")
|
||||
musicSettings.musicLocations = newDirs
|
||||
}
|
||||
musicSettings.musicLocations = newDirs
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user