aboutsummaryrefslogtreecommitdiff
path: root/kpref-activity/src/main/kotlin/ca
diff options
context:
space:
mode:
authorAllan Wang <me@allanwang.ca>2018-10-18 00:30:47 -0400
committerGitHub <noreply@github.com>2018-10-18 00:30:47 -0400
commit9dd6249d634c8b70d152907a4cda80da1626cddc (patch)
tree00d3af183fe9e7b050afcc91a9cac5bad254722f /kpref-activity/src/main/kotlin/ca
parent2ed21b32c9e77da5f957cfbf9d73a0a563b8511c (diff)
downloadkau-9dd6249d634c8b70d152907a4cda80da1626cddc.tar.gz
kau-9dd6249d634c8b70d152907a4cda80da1626cddc.tar.bz2
kau-9dd6249d634c8b70d152907a4cda80da1626cddc.zip
Fix/kprefseekbar builder (#174)
* Convert seekbar fields to getters * Make getters inline * Add spacing in readme, resolves #173 * Placeholder commit
Diffstat (limited to 'kpref-activity/src/main/kotlin/ca')
-rw-r--r--kpref-activity/src/main/kotlin/ca/allanwang/kau/kpref/activity/items/KPrefSeekbar.kt16
1 files changed, 8 insertions, 8 deletions
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 78f4f80..ce61e8f 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
@@ -15,14 +15,9 @@ import ca.allanwang.kau.utils.tint
*/
open class KPrefSeekbar(val builder: KPrefSeekbarContract) : KPrefItemBase<Int>(builder) {
- protected val min = builder.min
- protected val max = builder.max
- protected val increment = builder.increments
-
- init {
- if (increment <= 0)
- throw IllegalArgumentException("Seekbar must increment by at least 1")
- }
+ protected inline val min get() = builder.min
+ protected inline val max get() = builder.max
+ protected inline val increment get() = builder.increments
override fun KClick<Int>.defaultOnClick() = Unit
@@ -83,6 +78,11 @@ open class KPrefSeekbar(val builder: KPrefSeekbarContract) : KPrefItemBase<Int>(
override var max: Int = 100
override var increments: Int = 1
+ set(value) {
+ if (value <= 0)
+ throw IllegalArgumentException("Seekbar must increment by at least 1")
+ field = value
+ }
override var toText: (Int) -> String = Int::toString