From 91e4b0cd099d24cc645d5c935c9ed0c97d7fa5d8 Mon Sep 17 00:00:00 2001 From: Allan Wang Date: Sat, 27 Jan 2018 04:19:33 -0500 Subject: Disable seekbar properly when pref is disabled (#134) --- .../ca/allanwang/kau/kpref/activity/items/KPrefSeekbar.kt | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'kpref-activity') diff --git a/kpref-activity/src/main/kotlin/ca/allanwang/kau/kpref/activity/items/KPrefSeekbar.kt b/kpref-activity/src/main/kotlin/ca/allanwang/kau/kpref/activity/items/KPrefSeekbar.kt index 83bbe87..a580e83 100644 --- a/kpref-activity/src/main/kotlin/ca/allanwang/kau/kpref/activity/items/KPrefSeekbar.kt +++ b/kpref-activity/src/main/kotlin/ca/allanwang/kau/kpref/activity/items/KPrefSeekbar.kt @@ -36,14 +36,14 @@ open class KPrefSeekbar(val builder: KPrefSeekbarContract) : KPrefItemBase( override fun onStartTrackingTouch(sb: SeekBar) {} override fun onStopTrackingTouch(sb: SeekBar) { - val trueProgress = sb.progress.fromProgress - pref = trueProgress + pref = sb.progress.fromProgress } }) } withAccentColor(seekbar::tint) text.text = builder.toText(seekbar.progress.fromProgress) //set initial text in case no change occurs seekbar.progress = pref.toProgress + seekbar.isEnabled = builder.enabler() } /** @@ -76,15 +76,15 @@ open class KPrefSeekbar(val builder: KPrefSeekbarContract) : KPrefItemBase( override var increments: Int = 1 - override var toText: (Int) -> String = { it.toString() } + override var toText: (Int) -> String = Int::toString override var textViewConfigs: TextView.() -> Unit = {} } - val Int.toProgress: Int + protected inline val Int.toProgress: Int get() = this - builder.min - val Int.fromProgress: Int + protected inline val Int.fromProgress: Int get() = this + builder.min override fun getType(): Int = R.id.kau_item_pref_seekbar -- cgit v1.2.3