Skip to content

Instantly share code, notes, and snippets.

@BuiVanNam
Last active October 7, 2020 09:19
Show Gist options
  • Save BuiVanNam/1680f903a02acc16ba1b6e8514c043bb to your computer and use it in GitHub Desktop.
Save BuiVanNam/1680f903a02acc16ba1b6e8514c043bb to your computer and use it in GitHub Desktop.
Darktheme
/**
* Created by nambv on 10/5/2020
*/
class ThemeApplication : Application() {
override fun onCreate() {
super.onCreate()
setupTheme()
}
private fun setupTheme() {
when (PreferenceUtils.getCurrentTheme(this)) {
PreferenceUtils.THEME_LIGHT -> AppCompatDelegate.setDefaultNightMode(AppCompatDelegate.MODE_NIGHT_NO)
PreferenceUtils.THEME_DARK -> AppCompatDelegate.setDefaultNightMode(AppCompatDelegate.MODE_NIGHT_YES)
PreferenceUtils.THEME_SYSTEM -> AppCompatDelegate.setDefaultNightMode(AppCompatDelegate.MODE_NIGHT_FOLLOW_SYSTEM)
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment