From 29eec83389884aa17c8996e5f1d7c37d22198074 Mon Sep 17 00:00:00 2001 From: Jays2Kings Date: Sat, 10 Jul 2021 13:34:20 -0400 Subject: [PATCH] Only use launchWhenCreated when the context isn't in nightmode already --- .../java/eu/kanade/tachiyomi/util/system/ThemeUtil.kt | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/app/src/main/java/eu/kanade/tachiyomi/util/system/ThemeUtil.kt b/app/src/main/java/eu/kanade/tachiyomi/util/system/ThemeUtil.kt index 4eaf58344d..40851203f3 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/util/system/ThemeUtil.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/util/system/ThemeUtil.kt @@ -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 {