@Test public void it_formats_the_color_code_correctly_with_or_without_hash_prefix() { String result = mHtmlHelper.colorSubstring("This is a test string", "FFFFFF", 0, 4); assertEquals("<font color=\"#FFFFFF\">This</font> is a test string", result); result = mHtmlHelper.colorSubstring("This is a test string", "#FFFFFF", 0, 4); assertEquals("<font color=\"#FFFFFF\">This</font> is a test string", result); }
public String colorSubstring(String str, String color, int start, int end) { if (str == null || str.isEmpty()) { return ""; } color = formatColorHexCode(color); try { return str.substring(0, start) + wrapInColorTags(str.substring(start, end), color) + str.substring(end); } catch (StringIndexOutOfBoundsException e) { return ""; } }
HtmlHelper { public String colorSubstring(String str, String color, int start, int end) { if (str == null || str.isEmpty()) { return ""; } color = formatColorHexCode(color); try { return str.substring(0, start) + wrapInColorTags(str.substring(start, end), color) + str.substring(end); } catch (StringIndexOutOfBoundsException e) { return ""; } } }
HtmlHelper { public String colorSubstring(String str, String color, int start, int end) { if (str == null || str.isEmpty()) { return ""; } color = formatColorHexCode(color); try { return str.substring(0, start) + wrapInColorTags(str.substring(start, end), color) + str.substring(end); } catch (StringIndexOutOfBoundsException e) { return ""; } }  }
HtmlHelper { public String colorSubstring(String str, String color, int start, int end) { if (str == null || str.isEmpty()) { return ""; } color = formatColorHexCode(color); try { return str.substring(0, start) + wrapInColorTags(str.substring(start, end), color) + str.substring(end); } catch (StringIndexOutOfBoundsException e) { return ""; } }  String colorSubstring(String str, String color, int start, int end); }
HtmlHelper { public String colorSubstring(String str, String color, int start, int end) { if (str == null || str.isEmpty()) { return ""; } color = formatColorHexCode(color); try { return str.substring(0, start) + wrapInColorTags(str.substring(start, end), color) + str.substring(end); } catch (StringIndexOutOfBoundsException e) { return ""; } }  String colorSubstring(String str, String color, int start, int end);  }