Created
December 8, 2018 13:03
-
-
Save tateisu/c1410a929f1db117e95d20942a7dfb17 to your computer and use it in GitHub Desktop.
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
enum class Type( | |
val num : Int, | |
val imageUrl : String, | |
val imageWidth : Int, | |
val colorText:Int, | |
val colorBg : IntArray | |
) { | |
GnuSocial( | |
0, | |
"https://cdn.weep.me/img/gnus.png", | |
16, | |
color("#fff"), | |
intArrayOf(color("#000"),color("#a23")) | |
), | |
MastodonJapan( | |
1, | |
"https://cdn.weep.me/img/mstdn.png", | |
16, | |
color("#fff"), | |
intArrayOf(color("#000"),color("#27c")) | |
), | |
MastodonAbroad( | |
2, | |
"https://cdn.weep.me/img/mstdn.png", | |
16, | |
color("#fff"), | |
intArrayOf(color("#000"),color("#49c")) | |
), | |
Pleroma( | |
3, | |
"https://cdn.weep.me/img/plrm.png", | |
16, | |
color("#da5"), | |
intArrayOf(color("#000"),color("#123")) | |
), | |
Misskey( | |
4, | |
"https://cdn.weep.me/img/msky2.png", | |
36, | |
color("#fff"), | |
intArrayOf(color("#000"),color("#29b")) | |
), | |
PeerTube( | |
5, | |
"https://cdn.weep.me/img/peertube2.png", | |
16, | |
color("#000"), | |
intArrayOf(color("#000"),color("#fff"),color("#fff"),color("#fff")) | |
), | |
// ロシアの大手マイクロブログ | |
Juick( | |
6, | |
"https://cdn.weep.me/img/juick2.png", | |
16, | |
color("#fff"), | |
intArrayOf(color("#000"),color("#000")) | |
) | |
; | |
fun parseColorText(v : String) : Int = | |
parseColor(v) ?: colorText | |
fun parseColorBg(v : String) : IntArray { | |
val ia = v.split(',') | |
.filter{ it.isNotBlank() } | |
.map { color(it) } | |
.toIntArray() | |
return when { | |
ia.isNotEmpty() -> ia | |
else -> colorBg | |
} | |
} | |
fun parseImageUrl(s : String) : String = | |
if(s.isNotEmpty()) s else imageUrl | |
fun parseImageWidth(s : String) : Int = try{ | |
s.toInt() | |
}catch(ex:Throwable){ | |
imageWidth | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment