Making sure the UI update from language is in the Main thread.

This commit is contained in:
Vitor Pamplona 2023-10-23 11:09:47 -04:00
parent 91bfb60613
commit 9dfb4d1a1b

View File

@ -109,9 +109,11 @@ class SharedPreferencesViewModel : ViewModel() {
fun updateLanguageInTheUI() {
if (sharedPrefs.language != null) {
AppCompatDelegate.setApplicationLocales(
LocaleListCompat.forLanguageTags(sharedPrefs.language)
)
viewModelScope.launch(Dispatchers.Main) {
AppCompatDelegate.setApplicationLocales(
LocaleListCompat.forLanguageTags(sharedPrefs.language)
)
}
}
}