11package net.squanchy.eventdetails.widget
22
33import android.content.Context
4- import android.content.res.Resources
54import android.graphics.Color
65import android.support.annotation.AttrRes
6+ import android.support.annotation.ColorInt
77import android.support.constraint.ConstraintLayout
88import android.support.v4.content.ContextCompat
99import android.text.SpannableStringBuilder
@@ -19,8 +19,8 @@ import net.squanchy.R
1919import net.squanchy.eventdetails.domain.view.ExperienceLevel
2020import net.squanchy.schedule.domain.view.Event
2121import net.squanchy.schedule.domain.view.Place
22- import net.squanchy.support.content.res.getColorFromAttribute
2322import net.squanchy.schedule.domain.view.Track
23+ import net.squanchy.support.content.res.getColorFromAttribute
2424import net.squanchy.support.lang.getOrThrow
2525import net.squanchy.support.text.parseHtml
2626import org.joda.time.DateTimeZone
@@ -81,17 +81,10 @@ class EventDetailsLayout @JvmOverloads constructor(
8181 }
8282
8383 private fun createColorSpan (targetView : View , @AttrRes attributeResId : Int ): ForegroundColorSpan {
84- val color = getColorFromTheme( targetView.context.theme, attributeResId)
84+ val color = targetView.context.theme.getColorFromAttribute( attributeResId)
8585 return ForegroundColorSpan (color)
8686 }
8787
88- @ColorInt
89- private fun getColorFromTheme (theme : Resources .Theme , @AttrRes attributeId : Int ): Int {
90- val typedValue = TypedValue ()
91- theme.resolveAttribute(attributeId, typedValue, true )
92- return typedValue.data
93- }
94-
9588 private fun updateLevel (level : Option <ExperienceLevel >) {
9689 if (level.isDefined()) {
9790 levelGroup.isVisible = true
@@ -111,11 +104,6 @@ class EventDetailsLayout @JvmOverloads constructor(
111104 endCompoundDrawable?.setTint(color)
112105 }
113106
114- private fun createColorSpan (targetView : View , @AttrRes attributeResId : Int ): ForegroundColorSpan {
115- val color = targetView.context.theme.getColorFromAttribute(attributeResId)
116- return ForegroundColorSpan (color)
117- }
118-
119107 private fun updateTrack (trackOption : Option <Track >) {
120108 if (trackOption.isDefined()) {
121109 trackGroup.isVisible = true
0 commit comments