Make the Android settings parser a bit more robust

It would fail on lines line "Value =" - IE a value set to emptystring.

This would cause the app to crash when trying to open the corresponding
settings window.
This commit is contained in:
Jonathan Hamilton 2017-08-23 08:36:33 -07:00
parent 935c1da357
commit 5a361fd6b3
1 changed files with 11 additions and 2 deletions

View File

@ -274,10 +274,13 @@ public final class SettingsFile
current = sectionFromLine(line);
sections.put(current.getName(), current);
}
else if ((current != null) && line.contains("="))
else if ((current != null))
{
Setting setting = settingFromLine(current, line, fileName);
current.putSetting(setting);
if (setting != null)
{
current.putSetting(setting);
}
}
}
}
@ -381,6 +384,12 @@ public final class SettingsFile
{
String[] splitLine = line.split("=");
if (splitLine.length != 2)
{
Log.warning("Skipping invalid config line \"" + line + "\"");
return null;
}
String key = splitLine[0].trim();
String value = splitLine[1].trim();