Only use launchWhenCreated when the context isn't in nightmode already

This commit is contained in:
Jays2Kings 2021-07-10 13:34:20 -04:00
parent a3f210dbf0
commit 29eec83389

View File

@ -67,10 +67,14 @@ fun AppCompatActivity.setThemeAndNight(preferences: PreferencesHelper) {
if (ThemeUtil.isColoredTheme(theme)) {
setTheme(R.style.ThemeOverlay_Tachiyomi_AllBlue)
}
if (!isInNightMode()) {
lifecycle.coroutineScope.launchWhenCreated {
AppCompatDelegate.setDefaultNightMode(preferences.nightMode().get())
}
return
}
}
lifecycle.coroutineScope.launchWhenCreated {
AppCompatDelegate.setDefaultNightMode(preferences.nightMode().get())
}
AppCompatDelegate.setDefaultNightMode(preferences.nightMode().get())
}
fun Context.getPrefTheme(preferences: PreferencesHelper): Themes {