v0.3.1: made preferences resistant to class cast exceptions, now simply return default values instead of crashing.
This commit is contained in:
parent
7173c2cc47
commit
788937fbc1
|
@ -52,15 +52,27 @@ enum Preferences {
|
|||
}
|
||||
|
||||
int getInt( String key, int defValue ) {
|
||||
return get().getInt( key, defValue );
|
||||
try {
|
||||
return get().getInt( key, defValue );
|
||||
} catch (ClassCastException e) {
|
||||
return defValue;
|
||||
}
|
||||
}
|
||||
|
||||
boolean getBoolean( String key, boolean defValue ) {
|
||||
return get().getBoolean( key, defValue );
|
||||
try {
|
||||
return get().getBoolean(key, defValue);
|
||||
} catch (ClassCastException e) {
|
||||
return defValue;
|
||||
}
|
||||
}
|
||||
|
||||
String getString( String key, String defValue ) {
|
||||
return get().getString( key, defValue );
|
||||
try {
|
||||
return get().getString( key, defValue );
|
||||
} catch (ClassCastException e) {
|
||||
return defValue;
|
||||
}
|
||||
}
|
||||
|
||||
void put( String key, int value ) {
|
||||
|
|
Loading…
Reference in New Issue
Block a user