Skip to content

Commit

Permalink
Remove colorSchemeLoaderJob in favor of blocked loading
Browse files Browse the repository at this point in the history
  • Loading branch information
abb128 committed Jul 24, 2024
1 parent e0bd7b2 commit dd8d009
Showing 1 changed file with 4 additions and 12 deletions.
16 changes: 4 additions & 12 deletions java/src/org/futo/inputmethod/latin/LatinIME.kt
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,6 @@ class LatinIME : InputMethodService(), LifecycleOwner, ViewModelStoreOwner, Save

private var activeThemeOption: ThemeOption? = null
private var activeColorScheme = DarkColorScheme
private var colorSchemeLoaderJob: Job? = null
private var pendingRecreateKeyboard: Boolean = false

val themeOption get() = activeThemeOption
Expand Down Expand Up @@ -182,17 +181,10 @@ class LatinIME : InputMethodService(), LifecycleOwner, ViewModelStoreOwner, Save
}

override fun getDrawableProvider(): DynamicThemeProvider {
if (drawableProvider == null) {
if (colorSchemeLoaderJob != null && !colorSchemeLoaderJob!!.isCompleted) {
// Must have completed by now!
runBlocking {
colorSchemeLoaderJob!!.join()
}
}
drawableProvider = BasicThemeProvider(this, activeColorScheme)
return drawableProvider ?: BasicThemeProvider(this, activeColorScheme).let {
drawableProvider = it
it
}

return drawableProvider!!
}

private fun updateColorsIfDynamicChanged() {
Expand Down Expand Up @@ -289,7 +281,7 @@ class LatinIME : InputMethodService(), LifecycleOwner, ViewModelStoreOwner, Save
suggestionBlacklist
)

colorSchemeLoaderJob = deferGetSetting(THEME_KEY) {
getSettingBlocking(THEME_KEY).let {
val themeOptionFromSettings = ThemeOptions[it]
val themeOption = when {
themeOptionFromSettings == null -> VoiceInputTheme
Expand Down

0 comments on commit dd8d009

Please sign in to comment.