Skip to content

Commit

Permalink
Modified Theme class;
Browse files Browse the repository at this point in the history
Modified new toARGB method so it now only converts hexadecimal into int
by a substring method.
  • Loading branch information
rafaisen committed Jun 19, 2019
1 parent e6cd42b commit 4716a32
Showing 1 changed file with 19 additions and 2 deletions.
21 changes: 19 additions & 2 deletions droidar/src/main/java/gui/simpleUI/Theme.java
Original file line number Diff line number Diff line change
Expand Up @@ -190,11 +190,28 @@ public static int toARGB(int alpha, int red, int green, int blue) {
* for more info:
* https://developer.android.com/reference/android/graphics/Color.html#parseColor(java.lang.String)
*
* @param color hexadecimal/names String color value - #RRGGBB/#AARRGGBB or lower case name
* @param color hexadecimal String color value - #RRGGBB/#AARRGGBB
* @return the calculated rgb/argb value
*/
public static int toARGB(String color) {
return android.graphics.Color.parseColor(color);
int result;
if (color.length() == 7) {
result = toARGB(
DEFAULT_ALPHA,
Integer.valueOf(color.substring(1, 3), 16),
Integer.valueOf(color.substring(3, 5), 16),
Integer.valueOf(color.substring(5, 7), 16)
);
} else {
result = toARGB(
Integer.valueOf(color.substring(1, 3), 16),
Integer.valueOf(color.substring(3, 5), 16),
Integer.valueOf(color.substring(5, 7), 16),
Integer.valueOf(color.substring(7, 9), 16)
);

}
return result;
}

private static int[] initGradientGray() {
Expand Down

0 comments on commit 4716a32

Please sign in to comment.