I need to set default value for this method, because I have crash when no data is forwarded to method, but method is called.
public int getTagColorFromColorStr(String colorStr) {
int color = Color.WHITE;
if (colorStr != null && colorStr.length() > 0) {
String[] parts = colorStr.split(AppConstant.TAG_COLOR_STR_SEPEATOR);
double red = Double.parseDouble(parts[0]) * 255;
double green = Double.parseDouble(parts[1]) * 255;
double blue = Double.parseDouble(parts[2]) * 255;
double alpha = Double.parseDouble(parts[3]);
// AppDebugLog.println("double color in getTagColorFromColorStr : "
// + red + " : " + green + " : " + blue
// + " : " + alpha);
color = Color.rgb((int) red, (int) green, (int) blue);
}
Stack trace of the crash says:
11-18 14:45:57.767 28001-28001/com.mps.itickle E/AndroidRuntime: java.lang.NumberFormatException: Invalid double: "#FFFFFF"
Value that is provided to method when it works looks like this:
colorStr: "0.0,0.0,0.0,1.0"
Thanks on answers!