music: force listener trigger on location change

Otherwise it just won't actually update normally. Only for this
setting though. The others work just fine for some reason.
This commit is contained in:
Alexander Capehart 2025-03-15 17:36:34 -06:00
parent 05e864e7b5
commit 436ef8de91
No known key found for this signature in database
GPG key ID: 37DBE3621FE9AD47
2 changed files with 5 additions and 6 deletions

View file

@ -85,7 +85,10 @@ class MusicSettingsImpl @Inject constructor(@ApplicationContext private val cont
sharedPreferences.edit {
putString(
getString(R.string.set_key_music_locations), MusicLocation.toString(value))
this@edit.apply()
commit()
// Sometimes changing this setting just won't actually trigger the listener.
// Only this one. No idea why.
listener?.onMusicLocationsChanged()
}
}

View file

@ -62,17 +62,13 @@ interface Settings<Listener> {
*/
abstract class Impl<Listener>(private val context: Context) :
Settings<Listener>, SharedPreferences.OnSharedPreferenceChangeListener {
init {
L.d(this::class.simpleName)
}
protected val sharedPreferences: SharedPreferences =
PreferenceManager.getDefaultSharedPreferences(context.applicationContext)
/** @see [Context.getString] */
protected fun getString(@StringRes stringRes: Int) = context.getString(stringRes)
private var listener: Listener? = null
protected var listener: Listener? = null
override fun registerListener(listener: Listener) {
if (this.listener == null) {