Commit 675af6f7 authored by Eugene Shapovalov's avatar Eugene Shapovalov 💬

Resolve discussion comments.

parent d244ebd9
......@@ -4,6 +4,6 @@ package ru.terrakok.gitlabclient.entity
* Created by Eugene Shapovalov (@CraggyHaggy) on 04.01.19.
*/
data class Color(
val colorString: String,
val colorInt: Int
val name: String,
val value: Int
)
\ No newline at end of file
......@@ -8,8 +8,6 @@ import com.google.gson.annotations.SerializedName
data class Label(
@SerializedName("id") val id: Long,
@SerializedName("name") val name: String,
// The color of the label given in 6-digit hex notation with leading ‘#’ sign (e.g. #FFAABB)
// or one of the CSS color names. So according to CSS color names it can be named differently on Android.
@SerializedName("color") val color: Color,
@SerializedName("description") val description: String?,
@SerializedName("open_issues_count") val openIssuesCount: Int,
......
......@@ -16,6 +16,8 @@ class ColorDeserializer : JsonDeserializer<Color> {
typeOfT: Type,
context: JsonDeserializationContext
): Color {
// The color of the label given in 6-digit hex notation with leading ‘#’ sign (e.g. #FFAABB)
// or one of the CSS color names. So according to CSS color names it can be named differently on Android.
val colorString = json.asJsonPrimitive.asString
val colorInt = try {
android.graphics.Color.parseColor(colorString)
......
......@@ -57,11 +57,11 @@ class ProjectLabelAdapterDelegate : AdapterDelegate<MutableList<Any>>() {
private fun setLabelColor(color: Color) = with(itemView.labelTitleTextView) {
val textColor = when {
isColorDark(color.colorInt) -> ContextCompat.getColor(context, R.color.white)
isColorDark(color.value) -> ContextCompat.getColor(context, R.color.white)
else -> ContextCompat.getColor(context, R.color.primary_text)
}
setBackgroundTintByColor(color.colorInt)
setBackgroundTintByColor(color.value)
setTextColor(textColor)
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment