Use when statement instead of if. Change var to val.
All checks were successful
continuous-integration/drone/push Build is passing
All checks were successful
continuous-integration/drone/push Build is passing
This commit is contained in:
@@ -36,21 +36,17 @@ abstract class BaseActivity : AppCompatActivity(),
|
||||
}
|
||||
|
||||
override fun onSharedPreferenceChanged(sharedPreferences: SharedPreferences, key: String?) {
|
||||
if (key == "language") {
|
||||
setLanguage(sharedPreferences.getString("language", null))
|
||||
}
|
||||
if (key == "screen_on") {
|
||||
keepScreenOn(sharedPreferences.getBoolean("screen_on", false))
|
||||
}
|
||||
if (key == "theme") {
|
||||
updateTheme(sharedPreferences.getString("theme", null))
|
||||
when(key) {
|
||||
"language" -> setLanguage(sharedPreferences.getString(key, null))
|
||||
"screen_on" -> keepScreenOn(sharedPreferences.getBoolean(key, false))
|
||||
"theme" -> updateTheme(sharedPreferences.getString(key, null))
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private fun updateTheme(theme: String?) {
|
||||
|
||||
var themeValue = when (theme) {
|
||||
val themeValue = when (theme) {
|
||||
"light" -> AppCompatDelegate.MODE_NIGHT_NO
|
||||
"dark" -> AppCompatDelegate.MODE_NIGHT_YES
|
||||
"default" -> AppCompatDelegate.MODE_NIGHT_FOLLOW_SYSTEM
|
||||
|
||||
Reference in New Issue
Block a user