mirror of
https://github.com/playmusicexporter/playmusicexporter
synced 2024-05-14 14:46:42 +00:00
Fix app settings
This commit is contained in:
parent
c04b5cbce6
commit
a088fd22d0
|
@ -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;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue