AndroidAPS/wear/src/main/java/info/nightscout/androidaps/Aaps.kt

29 lines
1.1 KiB
Kotlin
Raw Normal View History

2021-12-10 15:27:09 +01:00
package info.nightscout.androidaps
import android.content.Intent
import android.content.SharedPreferences
import android.content.SharedPreferences.OnSharedPreferenceChangeListener
import androidx.localbroadcastmanager.content.LocalBroadcastManager
import androidx.preference.PreferenceManager
import dagger.android.AndroidInjector
import dagger.android.DaggerApplication
2022-02-09 11:13:38 +01:00
import info.nightscout.androidaps.di.DaggerWearComponent
2021-12-10 15:27:09 +01:00
class Aaps : DaggerApplication(), OnSharedPreferenceChangeListener {
override fun onCreate() {
super.onCreate()
PreferenceManager.getDefaultSharedPreferences(this).registerOnSharedPreferenceChangeListener(this)
}
override fun applicationInjector(): AndroidInjector<out DaggerApplication> =
2022-02-09 11:13:38 +01:00
DaggerWearComponent
2021-12-10 15:27:09 +01:00
.builder()
.application(this)
.build()
override fun onSharedPreferenceChanged(sharedPreferences: SharedPreferences, key: String) {
// we trigger update on Complications
LocalBroadcastManager.getInstance(this).sendBroadcast(Intent(Intent.ACTION_SEND))
}
}