Skip to content

Commit

Permalink
fix: app crashes on first start (ReVanced#111)
Browse files Browse the repository at this point in the history
  • Loading branch information
TheJeterLP authored Jul 31, 2022
1 parent 28f1cd6 commit 0f5e89c
Showing 1 changed file with 15 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -26,17 +26,29 @@ public static Boolean getBoolean(Context context, SharedPrefNames prefName, Stri

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) {
Expand Down

0 comments on commit 0f5e89c

Please sign in to comment.