Skip to content

Commit 748d835

Browse files
Merge pull request #32 from Omega-R/develop
Add HexColor
2 parents cde76a5 + 673a1e2 commit 748d835

File tree

1 file changed

+7
-1
lines changed
  • omegatypes/src/main/java/com/omega_r/libs/omegatypes

1 file changed

+7
-1
lines changed

omegatypes/src/main/java/com/omega_r/libs/omegatypes/Color.kt

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ abstract class Color : Serializable {
7373
fun fromArgb(alpha: Int, red: Int, green: Int, blue: Int): Color = IntColor(GraphicColor.argb(alpha, red, green, blue))
7474

7575
@JvmStatic
76-
fun fromString(colorString: String): Color = IntColor(GraphicColor.parseColor(colorString))
76+
fun fromString(colorString: String): Color = HexStringColor(colorString)
7777

7878
@JvmStatic
7979
fun fromColorList(colorStateList: ColorStateList): Color = ColorStateListColor(colorStateList)
@@ -84,6 +84,12 @@ abstract class Color : Serializable {
8484
override fun getColorInt(context: Context) = colorInt
8585
}
8686

87+
class HexStringColor(val hexString: String) : Color() {
88+
private val colorInt: Int = GraphicColor.parseColor(hexString)
89+
90+
override fun getColorInt(context: Context) = colorInt
91+
}
92+
8793
class ResourceColor(private val colorRes: Int) : Color() {
8894

8995
override fun getColorInt(context: Context): Int {

0 commit comments

Comments
 (0)