mirror of
https://github.com/revanced/revanced-integrations.git
synced 2025-01-20 16:57:32 +01:00
fix: app crashes on first start (#111)
This commit is contained in:
parent
28f1cd6529
commit
0f5e89c5e3
@ -26,17 +26,29 @@ public class SharedPrefHelper {
|
||||
|
||||
public static Long getLong(Context context, SharedPrefNames prefName, String key, Long _default) {
|
||||
SharedPreferences sharedPreferences = getPreferences(context, prefName);
|
||||
return Long.valueOf(sharedPreferences.getString(key, _default + ""));
|
||||
try {
|
||||
return Long.valueOf(sharedPreferences.getString(key, _default + ""));
|
||||
} catch (ClassCastException ex) {
|
||||
return sharedPreferences.getLong(key, _default);
|
||||
}
|
||||
}
|
||||
|
||||
public static Float getFloat(Context context, SharedPrefNames prefName, String key, Float _default) {
|
||||
SharedPreferences sharedPreferences = getPreferences(context, prefName);
|
||||
return Float.valueOf(sharedPreferences.getString(key, _default + ""));
|
||||
try {
|
||||
return Float.valueOf(sharedPreferences.getString(key, _default + ""));
|
||||
} catch (ClassCastException ex) {
|
||||
return sharedPreferences.getFloat(key, _default);
|
||||
}
|
||||
}
|
||||
|
||||
public static Integer getInt(Context context, SharedPrefNames prefName, String key, Integer _default) {
|
||||
SharedPreferences sharedPreferences = getPreferences(context, prefName);
|
||||
return Integer.valueOf(sharedPreferences.getString(key, _default + ""));
|
||||
try {
|
||||
return Integer.valueOf(sharedPreferences.getString(key, _default + ""));
|
||||
} catch (ClassCastException ex) {
|
||||
return sharedPreferences.getInt(key, _default);
|
||||
}
|
||||
}
|
||||
|
||||
public static SharedPreferences getPreferences(Context context, SharedPrefNames name) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user