mirror of
https://github.com/wheremyfoodat/Panda3DS.git
synced 2025-04-07 22:55:40 +12:00
Update GlobalConfig.java
This commit is contained in:
parent
cc44801acd
commit
9fd94f0b17
1 changed files with 5 additions and 6 deletions
|
@ -32,18 +32,17 @@ public class GlobalConfig {
|
||||||
return (T) value;
|
return (T) value;
|
||||||
}
|
}
|
||||||
|
|
||||||
//Need synchronized why SharedPreferences don't support aysnc write
|
|
||||||
public static synchronized <T extends Serializable> void set(Key<T> key, T value) {
|
public static synchronized <T extends Serializable> void set(Key<T> key, T value) {
|
||||||
if (value instanceof String) {
|
if (value instanceof String) {
|
||||||
data.edit().putString(key.name, (String) value).apply();
|
data.edit().putString(key.name, (String) value).apply();
|
||||||
} else if (value instanceof Integer) {
|
} else if (value instanceof Integer) {
|
||||||
data.edit().putInt(key.name, (Integer) value).apply();
|
data.edit().putInt(key.name, (int) value).apply();
|
||||||
} else if (value instanceof Boolean) {
|
} else if (value instanceof Boolean) {
|
||||||
data.edit().putBoolean(key.name, (Boolean) value).apply();
|
data.edit().putBoolean(key.name, (boolean) value).apply();
|
||||||
} else if (value instanceof Long) {
|
} else if (value instanceof Long) {
|
||||||
data.edit().putLong(key.name, (Long) value).apply();
|
data.edit().putLong(key.name, (long) value).apply();
|
||||||
} else if (value instanceof Float) {
|
} else if (value instanceof Float) {
|
||||||
data.edit().putFloat(key.name, (Float) value).apply();
|
data.edit().putFloat(key.name, (float) value).apply();
|
||||||
} else {
|
} else {
|
||||||
throw new IllegalArgumentException("Invalid global config value instance");
|
throw new IllegalArgumentException("Invalid global config value instance");
|
||||||
}
|
}
|
||||||
|
@ -58,4 +57,4 @@ public class GlobalConfig {
|
||||||
this.defaultValue = defaultValue;
|
this.defaultValue = defaultValue;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue