mirror of
https://github.com/SchildiChat/SchildiChat-android.git
synced 2024-12-25 02:18:31 +03:00
Add subscribeToChanges/unsubscribeToChanges to VectorPreferences
This commit is contained in:
parent
9614d55612
commit
e53801957c
1 changed files with 14 additions and 0 deletions
|
@ -240,6 +240,20 @@ class VectorPreferences @Inject constructor(private val context: Context) {
|
|||
|
||||
private val defaultPrefs = DefaultSharedPreferences.getInstance(context)
|
||||
|
||||
/**
|
||||
* Allow subscribing and unsubscribing to configuration changes. This is
|
||||
* particularly useful when you need to be notified of a configuration change
|
||||
* in a background service, e.g. for the P2P demos.
|
||||
*/
|
||||
|
||||
public fun subscribeToChanges(listener: SharedPreferences.OnSharedPreferenceChangeListener) {
|
||||
defaultPrefs.registerOnSharedPreferenceChangeListener(listener)
|
||||
}
|
||||
|
||||
public fun unsubscribeToChanges(listener: SharedPreferences.OnSharedPreferenceChangeListener) {
|
||||
defaultPrefs.unregisterOnSharedPreferenceChangeListener(listener)
|
||||
}
|
||||
|
||||
/**
|
||||
* Clear the preferences.
|
||||
*/
|
||||
|
|
Loading…
Reference in a new issue