aboutsummaryrefslogtreecommitdiff
path: root/kpref-activity/src
diff options
context:
space:
mode:
Diffstat (limited to 'kpref-activity/src')
-rw-r--r--kpref-activity/src/main/kotlin/ca/allanwang/kau/kpref/activity/KPrefBinder.kt24
-rw-r--r--kpref-activity/src/main/kotlin/ca/allanwang/kau/kpref/activity/items/KPrefCheckbox.kt1
-rw-r--r--kpref-activity/src/main/kotlin/ca/allanwang/kau/kpref/activity/items/KPrefSeekbar.kt16
-rw-r--r--kpref-activity/src/main/res-public/values/public.xml19
4 files changed, 16 insertions, 44 deletions
diff --git a/kpref-activity/src/main/kotlin/ca/allanwang/kau/kpref/activity/KPrefBinder.kt b/kpref-activity/src/main/kotlin/ca/allanwang/kau/kpref/activity/KPrefBinder.kt
index a9e21ff..2cdeae2 100644
--- a/kpref-activity/src/main/kotlin/ca/allanwang/kau/kpref/activity/KPrefBinder.kt
+++ b/kpref-activity/src/main/kotlin/ca/allanwang/kau/kpref/activity/KPrefBinder.kt
@@ -53,60 +53,52 @@ class GlobalOptions(core: CoreAttributeContract, activity: KPrefActivityContract
class KPrefAdapterBuilder(val globalOptions: GlobalOptions) {
@KPrefMarker
- fun header(@StringRes title: Int)
- = list.add(KPrefHeader(KPrefItemCore.CoreBuilder(globalOptions, title)))
+ fun header(@StringRes title: Int) = list.add(KPrefHeader(KPrefItemCore.CoreBuilder(globalOptions, title)))
@KPrefMarker
fun checkbox(@StringRes title: Int,
getter: (() -> Boolean),
setter: ((value: Boolean) -> Unit),
- builder: KPrefItemBase.BaseContract<Boolean>.() -> Unit = {})
- = list.add(KPrefCheckbox(KPrefItemBase.BaseBuilder(globalOptions, title, getter, setter)
+ builder: KPrefItemBase.BaseContract<Boolean>.() -> Unit = {}) = list.add(KPrefCheckbox(KPrefItemBase.BaseBuilder(globalOptions, title, getter, setter)
.apply { builder() }))
@KPrefMarker
fun colorPicker(@StringRes title: Int,
getter: (() -> Int),
setter: ((value: Int) -> Unit),
- builder: KPrefColorPicker.KPrefColorContract.() -> Unit = {})
- = list.add(KPrefColorPicker(KPrefColorPicker.KPrefColorBuilder(globalOptions, title, getter, setter)
+ builder: KPrefColorPicker.KPrefColorContract.() -> Unit = {}) = list.add(KPrefColorPicker(KPrefColorPicker.KPrefColorBuilder(globalOptions, title, getter, setter)
.apply { builder() }))
@KPrefMarker
fun <T> text(@StringRes title: Int,
getter: (() -> T),
setter: ((value: T) -> Unit),
- builder: KPrefText.KPrefTextContract<T>.() -> Unit = {})
- = list.add(KPrefText(KPrefText.KPrefTextBuilder(globalOptions, title, getter, setter)
+ builder: KPrefText.KPrefTextContract<T>.() -> Unit = {}) = list.add(KPrefText(KPrefText.KPrefTextBuilder(globalOptions, title, getter, setter)
.apply { builder() }))
@KPrefMarker
fun subItems(@StringRes title: Int,
itemBuilder: KPrefAdapterBuilder.() -> Unit,
- builder: KPrefSubItems.KPrefSubItemsContract.() -> Unit)
- = list.add(KPrefSubItems(KPrefSubItems.KPrefSubItemsBuilder(globalOptions, title, itemBuilder)
+ builder: KPrefSubItems.KPrefSubItemsContract.() -> Unit) = list.add(KPrefSubItems(KPrefSubItems.KPrefSubItemsBuilder(globalOptions, title, itemBuilder)
.apply { builder() }))
@KPrefMarker
fun plainText(@StringRes title: Int,
- builder: KPrefItemBase.BaseContract<Unit>.() -> Unit = {})
- = list.add(KPrefPlainText(KPrefPlainText.KPrefPlainTextBuilder(globalOptions, title)
+ builder: KPrefItemBase.BaseContract<Unit>.() -> Unit = {}) = list.add(KPrefPlainText(KPrefPlainText.KPrefPlainTextBuilder(globalOptions, title)
.apply { builder() }))
@KPrefMarker
fun seekbar(@StringRes title: Int,
getter: (() -> Int),
setter: ((value: Int) -> Unit),
- builder: KPrefSeekbar.KPrefSeekbarContract.() -> Unit = {})
- = list.add(KPrefSeekbar(KPrefSeekbar.KPrefSeekbarBuilder(globalOptions, title, getter, setter)
+ builder: KPrefSeekbar.KPrefSeekbarContract.() -> Unit = {}) = list.add(KPrefSeekbar(KPrefSeekbar.KPrefSeekbarBuilder(globalOptions, title, getter, setter)
.apply { builder() }))
@KPrefMarker
fun timePicker(@StringRes title: Int,
getter: (() -> Int),
setter: ((value: Int) -> Unit),
- builder: KPrefTimePicker.KPrefTimeContract.() -> Unit = {})
- = list.add(KPrefTimePicker(KPrefTimePicker.KPrefTimeBuilder(globalOptions, title, getter, setter)
+ builder: KPrefTimePicker.KPrefTimeContract.() -> Unit = {}) = list.add(KPrefTimePicker(KPrefTimePicker.KPrefTimeBuilder(globalOptions, title, getter, setter)
.apply { builder() }))
@KPrefMarker
diff --git a/kpref-activity/src/main/kotlin/ca/allanwang/kau/kpref/activity/items/KPrefCheckbox.kt b/kpref-activity/src/main/kotlin/ca/allanwang/kau/kpref/activity/items/KPrefCheckbox.kt
index 3e06f6a..f391747 100644
--- a/kpref-activity/src/main/kotlin/ca/allanwang/kau/kpref/activity/items/KPrefCheckbox.kt
+++ b/kpref-activity/src/main/kotlin/ca/allanwang/kau/kpref/activity/items/KPrefCheckbox.kt
@@ -4,7 +4,6 @@ import android.support.v7.widget.AppCompatCheckBox
import android.widget.CheckBox
import ca.allanwang.kau.kpref.activity.KClick
import ca.allanwang.kau.kpref.activity.R
-import ca.allanwang.kau.logging.KL
import ca.allanwang.kau.utils.tint
/**
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
diff --git a/kpref-activity/src/main/res-public/values/public.xml b/kpref-activity/src/main/res-public/values/public.xml
deleted file mode 100644
index b5fb383..0000000
--- a/kpref-activity/src/main/res-public/values/public.xml
+++ /dev/null
@@ -1,19 +0,0 @@
-<resources xmlns:tools='http://schemas.android.com/tools' tools:ignore='ResourceName'>
-<!-- AUTO-GENERATED FILE. DO NOT MODIFY. public.xml is generated by the generatepublicxml gradle task -->
- <public name='kau_pref_barrier' type='id' />
- <public name='kau_pref_container' type='id' />
- <public name='kau_pref_desc' type='id' />
- <public name='kau_pref_icon' type='id' />
- <public name='kau_pref_inner_content' type='id' />
- <public name='kau_pref_inner_frame' type='id' />
- <public name='kau_pref_item_checkbox' type='id' />
- <public name='kau_pref_item_color_picker' type='id' />
- <public name='kau_pref_item_header' type='id' />
- <public name='kau_pref_item_plain_text' type='id' />
- <public name='kau_pref_item_seekbar' type='id' />
- <public name='kau_pref_item_sub_item' type='id' />
- <public name='kau_pref_item_text' type='id' />
- <public name='kau_pref_lower_content' type='id' />
- <public name='kau_pref_lower_frame' type='id' />
- <public name='kau_pref_title' type='id' />
-</resources> \ No newline at end of file