s3db: use non-exception version of parseColor

This commit is contained in:
Hannes Janetzek 2014-03-23 02:40:55 +01:00
parent fd941858dd
commit aa4a1de6f7
2 changed files with 17 additions and 5 deletions

View File

@ -223,4 +223,19 @@ public class Color {
}
throw new IllegalArgumentException("Unknown color");
}
public static int parseColor(String colorString, int fallBackColor) {
if (colorString.charAt(0) == '#') {
// Use a long to avoid rollovers on #ffXXXXXX
long color = Long.parseLong(colorString.substring(1), 16);
if (colorString.length() == 7) {
// Set the alpha value
color |= 0x00000000ff000000;
} else if (colorString.length() != 9) {
return fallBackColor;
}
return (int) color;
}
return fallBackColor;
}
}

View File

@ -55,11 +55,8 @@ public class S3DBLayer extends TileLayer {
static int getColor(String color, boolean roof) {
try {
return Color.parseColor(color);
} catch (Exception e) {
}
if (color.charAt(0) == '#')
return Color.parseColor(color, Color.CYAN);
if (roof) {
if ("brown" == color)