mirror of
https://github.com/Aviortheking/Neo-Store.git
synced 2025-06-08 08:49:55 +00:00
Fix: Apply theme on MainActivity when changed
This commit is contained in:
parent
2d0fe2fe61
commit
039db23a64
@ -31,6 +31,7 @@ import com.looker.droidify.ui.viewmodels.MainActivityViewModelX
|
||||
import com.looker.droidify.utility.extension.android.Android
|
||||
import com.looker.droidify.utility.extension.text.nullIfEmpty
|
||||
import kotlinx.coroutines.launch
|
||||
import kotlin.properties.Delegates
|
||||
|
||||
class MainActivityX : AppCompatActivity() {
|
||||
companion object {
|
||||
@ -65,8 +66,11 @@ class MainActivityX : AppCompatActivity() {
|
||||
val db
|
||||
get() = (application as MainApplication).db
|
||||
|
||||
var currentTheme by Delegates.notNull<Int>()
|
||||
|
||||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
setTheme(Preferences[Preferences.Key.Theme].getResId(resources.configuration))
|
||||
currentTheme = Preferences[Preferences.Key.Theme].getResId(resources.configuration)
|
||||
setTheme(currentTheme)
|
||||
super.onCreate(savedInstanceState)
|
||||
|
||||
binding = ActivityMainXBinding.inflate(layoutInflater)
|
||||
@ -107,6 +111,12 @@ class MainActivityX : AppCompatActivity() {
|
||||
syncConnection.bind(this)
|
||||
}
|
||||
|
||||
override fun onResume() {
|
||||
super.onResume()
|
||||
if (currentTheme != Preferences[Preferences.Key.Theme].getResId(resources.configuration))
|
||||
recreate()
|
||||
}
|
||||
|
||||
override fun onSupportNavigateUp(): Boolean {
|
||||
return navController.navigateUp(appBarConfiguration)
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user