forked from FreeTubeApp/FreeTube
-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Move all remaining methods on javascript interface into regions
(a little more organised)
- Loading branch information
1 parent
c38831a
commit cd8f78b
Showing
2 changed files
with
149 additions
and
115 deletions.
There are no files selected for viewing
24 changes: 24 additions & 0 deletions
24
android/app/src/main/java/io/freetubeapp/freetube/helpers/String.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
package io.freetubeapp.freetube.helpers | ||
|
||
import android.graphics.Color | ||
|
||
fun String.hexToColour() : Int { | ||
return if (length === 7) { | ||
Color.rgb( | ||
Integer.valueOf(substring(1, 3), 16), | ||
Integer.valueOf(substring(3, 5), 16), | ||
Integer.valueOf(substring(5, 7), 16) | ||
) | ||
} else if (length === 4) { | ||
val r = substring(1, 2) | ||
val g = substring(2, 3) | ||
val b = substring(3, 4) | ||
Color.rgb( | ||
Integer.valueOf("$r$r", 16), | ||
Integer.valueOf("$g$g", 16), | ||
Integer.valueOf("$b$b", 16) | ||
) | ||
} else { | ||
Color.TRANSPARENT | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters