Skip to content
This repository was archived by the owner on Feb 17, 2020. It is now read-only.

Commit 2567ae8

Browse files
authored
Merge pull request #564 from squanchy-dev/tweak_level_ui_for_keynotes_in_details
Hide level in event details for keynotes
2 parents de0950c + bb630b3 commit 2567ae8

1 file changed

Lines changed: 22 additions & 17 deletions

File tree

app/src/main/java/net/squanchy/eventdetails/widget/EventDetailsLayout.kt

Lines changed: 22 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ class EventDetailsLayout @JvmOverloads constructor(
4444
fun updateWith(event: Event) {
4545
updateWhen(event.startTime, event.timeZone)
4646
updateWhere(event.place)
47-
updateLevel(event.experienceLevel)
47+
updateLevel(event.experienceLevel, event.type)
4848
updateTrack(event.track)
4949
updateDescription(event.description)
5050
}
@@ -85,23 +85,22 @@ class EventDetailsLayout @JvmOverloads constructor(
8585
return ForegroundColorSpan(color)
8686
}
8787

88-
private fun updateLevel(level: Option<ExperienceLevel>) {
89-
if (level.isDefined()) {
90-
levelGroup.isVisible = true
88+
private fun updateLevel(level: Option<ExperienceLevel>, type: Event.Type) {
89+
when {
90+
type == Event.Type.KEYNOTE -> {
91+
levelGroup.isVisible = false
92+
}
93+
level.isDefined() -> {
94+
levelGroup.isVisible = true
9195

92-
val experienceLevel = level.getOrThrow()
93-
levelValue.setText(experienceLevel.labelStringResId)
94-
val experienceColor = ContextCompat.getColor(context, experienceLevel.colorResId)
95-
tintCompoundDrawableEnd(levelValue, experienceColor)
96-
} else {
97-
levelGroup.isVisible = false
98-
}
99-
}
96+
val experienceLevel = level.getOrThrow()
97+
levelValue.setText(experienceLevel.labelStringResId)
10098

101-
private fun tintCompoundDrawableEnd(textView: TextView, @ColorInt color: Int) {
102-
val compoundDrawables = textView.compoundDrawablesRelative
103-
val endCompoundDrawable = compoundDrawables[2]
104-
endCompoundDrawable?.setTint(color)
99+
val experienceColor = ContextCompat.getColor(context, experienceLevel.colorResId)
100+
levelValue.tintCompoundDrawableEnd(experienceColor)
101+
}
102+
else -> levelGroup.isVisible = false
103+
}
105104
}
106105

107106
private fun updateTrack(trackOption: Option<Track>) {
@@ -112,13 +111,19 @@ class EventDetailsLayout @JvmOverloads constructor(
112111
trackValue.text = track.name
113112
track.accentColor?.let {
114113
val trackColor = Color.parseColor(it)
115-
tintCompoundDrawableEnd(trackValue, trackColor)
114+
trackValue.tintCompoundDrawableEnd(trackColor)
116115
}
117116
} else {
118117
trackGroup.isVisible = false
119118
}
120119
}
121120

121+
private fun TextView.tintCompoundDrawableEnd(@ColorInt color: Int) {
122+
val compoundDrawables = compoundDrawablesRelative
123+
val endCompoundDrawable = compoundDrawables[2]
124+
endCompoundDrawable?.setTint(color)
125+
}
126+
122127
private fun updateDescription(description: Option<String>) {
123128
if (description.isDefined()) {
124129
descriptionGroup.isVisible = true

0 commit comments

Comments
 (0)