Skip to content

Commit

Permalink
presets: Fix prop type check when applying props
Browse files Browse the repository at this point in the history
  • Loading branch information
ponces committed May 29, 2023
1 parent 968684e commit 1a3826c
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions app/src/main/java/me/phh/treble/app/PresetDownloader.kt
Expand Up @@ -127,16 +127,19 @@ class PresetDownloader {
val value = prefs.get(key)
Log.d("PHH-Presets", " => $value")
Log.d("PHH-Presets", "$key has type ${value.javaClass}")
when (value.javaClass) {
Int::class.java -> spEdit.putInt(key, value as Int)
Boolean::class.java -> spEdit.putBoolean(key, value as Boolean)
String::class.java -> {
when (value) {
is Int -> spEdit.putInt(key, value as Int)
is Boolean -> spEdit.putBoolean(key, value as Boolean)
is String -> {
if(value == "true" || value == "false") {
spEdit.putBoolean(key, value == "true")
} else {
spEdit.putString(key, value as String)
}
}
else -> {
Log.d("PHH-Presets", "Unknown key type. Ignoring...")
}
}
}
}
Expand Down

0 comments on commit 1a3826c

Please sign in to comment.