Last active
October 7, 2020 09:19
-
-
Save BuiVanNam/1680f903a02acc16ba1b6e8514c043bb to your computer and use it in GitHub Desktop.
Darktheme
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* 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