Fix app settings

This commit is contained in:
David Schulte 2015-05-03 20:25:11 +02:00
parent c04b5cbce6
commit a088fd22d0

View file

@ -115,12 +115,14 @@ public class AppSettings {
public <E extends Enum<E>> E getEnum(String key, E defValue) {
String value = mSharedPreferences.getString(key, defValue.name());
// Checks all enum values
for (E constant : ((Class<E>)defValue.getClass()).getEnumConstants()) {
if (value.equals(constant.name()))
return constant;
// Null check
if (value != null) {
// Checks all enum values
for (E constant : defValue.getDeclaringClass().getEnumConstants()) {
if (value.equals(constant.name()))
return constant;
}
}
// Return default
return defValue;
}