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:
parent
05e864e7b5
commit
436ef8de91
2 changed files with 5 additions and 6 deletions
|
@ -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()
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -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) {
|
||||
|
|
Loading…
Reference in a new issue