@SuppressWarnings("UseJBColor") @Nullable public static Color parseColor(@Nullable String s){
  s=StringUtil.trim(s);
  if (StringUtil.isEmpty(s)) {
    return null;
  }
  if (s.charAt(0) == '#') {
    long longColor;
    try {
      longColor=Long.parseLong(s.substring(1),16);
    }
 catch (    NumberFormatException e) {
      return null;
    }
    if (s.length() == 4 || s.length() == 5) {
      long a=s.length() == 4 ? 0xff : extend((longColor & 0xf000) >> 12);
      long r=extend((longColor & 0xf00) >> 8);
      long g=extend((longColor & 0x0f0) >> 4);
      long b=extend((longColor & 0x00f));
      longColor=(a << 24) | (r << 16) | (g << 8)| b;
      return new Color((int)longColor,true);
    }
    if (s.length() == 7) {
      longColor|=0x00000000ff000000;
    }
 else     if (s.length() != 9) {
      return null;
    }
    return new Color((int)longColor,true);
  }
  return null;
}

@ SuppressWarnings ( "UseJBColor" ) @ Nullable public static Color parseColor ( @ Nullable String s ) { s = StringUtil . trim ( s ) ; if ( StringUtil . isEmpty ( s ) ) { return null ; } if ( s . charAt ( 0 ) == '#' ) { long longColor ; try { longColor = Long . parseLong ( s . substring ( 1 ) , 16 ) ; } catch ( NumberFormatException e ) { return null ; } if ( s . length ( ) == 4 || s . length ( ) == 5 ) { long a = s . length ( ) == 4 ? 0xff : extend ( ( longColor & 0xf000 ) > > 12 ) ; long r = extend ( ( longColor & 0xf00 ) > > 8 ) ; long g = extend ( ( longColor & 0x0f0 ) > > 4 ) ; long b = extend ( ( longColor & 0x00f ) ) ; longColor = ( a << 24 ) | ( r << 16 ) | ( g << 8 ) | b ; return new Color ( ( int ) longColor , true ) ; } if ( s . length ( ) == 7 ) { longColor |= 0x00000000ff000000 ; } else if ( s . length ( ) != 9 ) { return null ; } return new Color ( ( int ) longColor , true ) ; } return null ; }
converts the supported color formats ( # rgb , # argb , # rrggbb , # aarrggbb to a color http : / / developer . android . com / guide / topics / resources / more - resources . html # color
