Catch possible exceptions when settings change.
This commit is contained in:
parent
26f9216a8a
commit
3daf7cd247
1 changed files with 10 additions and 4 deletions
|
@ -8,6 +8,7 @@ import java.util.LinkedHashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
|
import net.osmand.LogUtil;
|
||||||
import net.osmand.Version;
|
import net.osmand.Version;
|
||||||
import net.osmand.access.AccessibleToast;
|
import net.osmand.access.AccessibleToast;
|
||||||
import net.osmand.access.RelativeDirectionStyle;
|
import net.osmand.access.RelativeDirectionStyle;
|
||||||
|
@ -381,11 +382,16 @@ public class OsmandSettings {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected E getValue(SharedPreferences prefs, E defaultValue) {
|
protected E getValue(SharedPreferences prefs, E defaultValue) {
|
||||||
int i = prefs.getInt(getId(), -1);
|
try {
|
||||||
if(i < 0 || i >= values.length){
|
int i = prefs.getInt(getId(), -1);
|
||||||
return defaultValue;
|
if(i < 0 || i >= values.length){
|
||||||
|
return defaultValue;
|
||||||
|
}
|
||||||
|
return values[i];
|
||||||
|
} catch (Exception e) {
|
||||||
|
android.util.Log.e(LogUtil.TAG, "Error getting value for: " + this.getId(), e);
|
||||||
|
return defaultValue;
|
||||||
}
|
}
|
||||||
return values[i];
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
Loading…
Reference in a new issue