mirror of
https://github.com/wheremyfoodat/Panda3DS.git
synced 2025-04-08 07:05:40 +12:00
paris changes
This commit is contained in:
parent
71109d701d
commit
cc44801acd
3 changed files with 14 additions and 20 deletions
|
@ -39,5 +39,4 @@ dependencies {
|
||||||
implementation("androidx.appcompat:appcompat:1.6.1")
|
implementation("androidx.appcompat:appcompat:1.6.1")
|
||||||
implementation("com.google.android.material:material:1.8.0")
|
implementation("com.google.android.material:material:1.8.0")
|
||||||
implementation("androidx.constraintlayout:constraintlayout:2.1.4")
|
implementation("androidx.constraintlayout:constraintlayout:2.1.4")
|
||||||
implementation("com.google.code.gson:gson:2.10.1")
|
|
||||||
}
|
}
|
|
@ -16,24 +16,24 @@ public class GlobalConfig {
|
||||||
.getSharedPreferences(Constants.PREF_GLOBAL_CONFIG, Context.MODE_PRIVATE);
|
.getSharedPreferences(Constants.PREF_GLOBAL_CONFIG, Context.MODE_PRIVATE);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static <T extends Serializable> T get(Key<T> key) {
|
public static <T extends Serializable> T get(Key<T> key) {
|
||||||
Serializable value;
|
Serializable value;
|
||||||
if (key.defValue instanceof String) {
|
if (key.defaultValue instanceof String) {
|
||||||
value = data.getString(key.name, (String) key.defValue);
|
value = data.getString(key.name, (String) key.defaultValue);
|
||||||
} else if (key.defValue instanceof Integer) {
|
} else if (key.defaultValue instanceof Integer) {
|
||||||
value = data.getInt(key.name, (int) key.defValue);
|
value = data.getInt(key.name, (int) key.defaultValue);
|
||||||
} else if (key.defValue instanceof Boolean) {
|
} else if (key.defaultValue instanceof Boolean) {
|
||||||
value = data.getBoolean(key.name, (Boolean) key.defValue);
|
value = data.getBoolean(key.name, (boolean) key.defaultValue);
|
||||||
} else if (key.defValue instanceof Long) {
|
} else if (key.defaultValue instanceof Long) {
|
||||||
value = data.getLong(key.name, (Long) key.defValue);
|
value = data.getLong(key.name, (long) key.defaultValue);
|
||||||
} else {
|
} else {
|
||||||
value = data.getFloat(key.name, ((Number) key.defValue).floatValue());
|
value = data.getFloat(key.name, (float) key.defaultValue);
|
||||||
}
|
}
|
||||||
return (T) value;
|
return (T) value;
|
||||||
}
|
}
|
||||||
|
|
||||||
//Need synchronized why SharedPreferences don't support aysnc write
|
//Need synchronized why SharedPreferences don't support aysnc write
|
||||||
private 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) {
|
||||||
|
@ -51,11 +51,11 @@ public class GlobalConfig {
|
||||||
|
|
||||||
private static class Key<T extends Serializable> {
|
private static class Key<T extends Serializable> {
|
||||||
private final String name;
|
private final String name;
|
||||||
private final T defValue;
|
private final T defaultValue;
|
||||||
|
|
||||||
private Key(String name, T defValue) {
|
private Key(String name, T defaultValue) {
|
||||||
this.name = name;
|
this.name = name;
|
||||||
this.defValue = defValue;
|
this.defaultValue = defaultValue;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -1,5 +0,0 @@
|
||||||
package com.panda3ds.pandroid.lang;
|
|
||||||
|
|
||||||
public interface Function<T> {
|
|
||||||
void run(T val);
|
|
||||||
}
|
|
Loading…
Add table
Reference in a new issue