fix: handle if number string is corrupt or unexpected

This commit is contained in:
LisoUseInAIKyrios 2024-03-28 14:00:09 +04:00
parent 91c8f641b6
commit c4e4d7880c

View File

@ -136,7 +136,7 @@ public class SharedPrefCategory {
if (value != null) {
return Integer.valueOf(value);
}
} catch (ClassCastException ex) {
} catch (ClassCastException | NumberFormatException ex) {
try {
// Old data previously stored as primitive.
return preferences.getInt(key, _default);
@ -155,7 +155,7 @@ public class SharedPrefCategory {
if (value != null) {
return Long.valueOf(value);
}
} catch (ClassCastException ex) {
} catch (ClassCastException | NumberFormatException ex) {
try {
return preferences.getLong(key, _default);
} catch (ClassCastException ex2) {
@ -172,7 +172,7 @@ public class SharedPrefCategory {
if (value != null) {
return Float.valueOf(value);
}
} catch (ClassCastException ex) {
} catch (ClassCastException | NumberFormatException ex) {
try {
return preferences.getFloat(key, _default);
} catch (ClassCastException ex2) {