Skip to content

Instantly share code, notes, and snippets.

@tateisu
Created December 8, 2018 13:03
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tateisu/c1410a929f1db117e95d20942a7dfb17 to your computer and use it in GitHub Desktop.
Save tateisu/c1410a929f1db117e95d20942a7dfb17 to your computer and use it in GitHub Desktop.
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