From af8f9685112695f031d93fcb2da8a6e0a3b70c4a Mon Sep 17 00:00:00 2001 From: Allan Wang Date: Wed, 22 May 2019 17:58:48 -0700 Subject: Remove kpref action context for getter --- .../main/kotlin/ca/allanwang/kau/kpref/activity/KPrefBinder.kt | 10 +++++----- .../ca/allanwang/kau/kpref/activity/items/KPrefColorPicker.kt | 2 +- .../ca/allanwang/kau/kpref/activity/items/KPrefItemBase.kt | 6 +++--- .../ca/allanwang/kau/kpref/activity/items/KPrefSeekbar.kt | 2 +- .../kotlin/ca/allanwang/kau/kpref/activity/items/KPrefText.kt | 4 ++-- .../ca/allanwang/kau/kpref/activity/items/KPrefTimePicker.kt | 2 +- 6 files changed, 13 insertions(+), 13 deletions(-) (limited to 'kpref-activity') 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 ec3c69f..764831e 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 @@ -82,7 +82,7 @@ class KPrefAdapterBuilder(val globalOptions: GlobalOptions) { @KPrefMarker fun checkbox( @StringRes title: Int, - getter: KPrefItemActions.() -> Boolean, + getter: () -> Boolean, setter: KPrefItemActions.(value: Boolean) -> Unit, builder: KPrefItemBase.BaseContract.() -> Unit = {} ) = list.add( @@ -93,7 +93,7 @@ class KPrefAdapterBuilder(val globalOptions: GlobalOptions) { @KPrefMarker fun colorPicker( @StringRes title: Int, - getter: KPrefItemActions.() -> Int, + getter: () -> Int, setter: KPrefItemActions.(value: Int) -> Unit, builder: KPrefColorPicker.KPrefColorContract.() -> Unit = {} ) = list.add( @@ -104,7 +104,7 @@ class KPrefAdapterBuilder(val globalOptions: GlobalOptions) { @KPrefMarker fun text( @StringRes title: Int, - getter: KPrefItemActions.() -> T, + getter: () -> T, setter: KPrefItemActions.(value: T) -> Unit, builder: KPrefText.KPrefTextContract.() -> Unit = {} ) = list.add( @@ -134,7 +134,7 @@ class KPrefAdapterBuilder(val globalOptions: GlobalOptions) { @KPrefMarker fun seekbar( @StringRes title: Int, - getter: KPrefItemActions.() -> Int, + getter: () -> Int, setter: KPrefItemActions.(value: Int) -> Unit, builder: KPrefSeekbar.KPrefSeekbarContract.() -> Unit = {} ) = list.add( @@ -145,7 +145,7 @@ class KPrefAdapterBuilder(val globalOptions: GlobalOptions) { @KPrefMarker fun timePicker( @StringRes title: Int, - getter: KPrefItemActions.() -> Int, + getter: () -> Int, setter: KPrefItemActions.(value: Int) -> Unit, builder: KPrefTimePicker.KPrefTimeContract.() -> Unit = {} ) = list.add( diff --git a/kpref-activity/src/main/kotlin/ca/allanwang/kau/kpref/activity/items/KPrefColorPicker.kt b/kpref-activity/src/main/kotlin/ca/allanwang/kau/kpref/activity/items/KPrefColorPicker.kt index 07a6bbf..0b53797 100644 --- a/kpref-activity/src/main/kotlin/ca/allanwang/kau/kpref/activity/items/KPrefColorPicker.kt +++ b/kpref-activity/src/main/kotlin/ca/allanwang/kau/kpref/activity/items/KPrefColorPicker.kt @@ -72,7 +72,7 @@ open class KPrefColorPicker(open val builder: KPrefColorContract) : KPrefItemBas class KPrefColorBuilder( globalOptions: GlobalOptions, titleId: Int, - getter: KPrefItemActions.() -> Int, + getter: () -> Int, setter: KPrefItemActions.(value: Int) -> Unit ) : KPrefColorContract, BaseContract by BaseBuilder(globalOptions, titleId, getter, setter), ColorContract by ColorBuilder() { diff --git a/kpref-activity/src/main/kotlin/ca/allanwang/kau/kpref/activity/items/KPrefItemBase.kt b/kpref-activity/src/main/kotlin/ca/allanwang/kau/kpref/activity/items/KPrefItemBase.kt index a445de5..c597b63 100644 --- a/kpref-activity/src/main/kotlin/ca/allanwang/kau/kpref/activity/items/KPrefItemBase.kt +++ b/kpref-activity/src/main/kotlin/ca/allanwang/kau/kpref/activity/items/KPrefItemBase.kt @@ -31,7 +31,7 @@ import ca.allanwang.kau.utils.resolveDrawable abstract class KPrefItemBase(protected val base: BaseContract) : KPrefItemCore(base) { open var pref: T - get() = base.getter(this) + get() = base.getter() set(value) { base.setter(this, value) } @@ -93,7 +93,7 @@ abstract class KPrefItemBase(protected val base: BaseContract) : KPrefItem var enabler: () -> Boolean var onClick: (KClick.() -> Unit)? var onDisabledClick: (KClick.() -> Unit)? - val getter: KPrefItemActions.() -> T + val getter: () -> T val setter: KPrefItemActions.(value: T) -> Unit } @@ -103,7 +103,7 @@ abstract class KPrefItemBase(protected val base: BaseContract) : KPrefItem class BaseBuilder( globalOptions: GlobalOptions, titleId: Int, - override val getter: KPrefItemActions.() -> T, + override val getter: () -> T, override val setter: KPrefItemActions.(value: T) -> Unit ) : CoreContract by CoreBuilder(globalOptions, titleId), BaseContract { override var enabler: () -> Boolean = { true } 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 d49fe16..a582ec4 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 @@ -85,7 +85,7 @@ open class KPrefSeekbar(val builder: KPrefSeekbarContract) : KPrefItemBase( class KPrefSeekbarBuilder( globalOptions: GlobalOptions, titleId: Int, - getter: KPrefItemActions.() -> Int, + getter: () -> Int, setter: KPrefItemActions.(value: Int) -> Unit ) : KPrefSeekbarContract, BaseContract by BaseBuilder(globalOptions, titleId, getter, setter) { diff --git a/kpref-activity/src/main/kotlin/ca/allanwang/kau/kpref/activity/items/KPrefText.kt b/kpref-activity/src/main/kotlin/ca/allanwang/kau/kpref/activity/items/KPrefText.kt index 5f6eefa..76c9e20 100644 --- a/kpref-activity/src/main/kotlin/ca/allanwang/kau/kpref/activity/items/KPrefText.kt +++ b/kpref-activity/src/main/kotlin/ca/allanwang/kau/kpref/activity/items/KPrefText.kt @@ -36,7 +36,7 @@ open class KPrefText(open val builder: KPrefTextContract) : KPrefItemBase< * Automatically reload on set */ override var pref: T - get() = base.getter(this) + get() = base.getter() set(value) { base.setter(this, value) builder.reloadSelf() @@ -66,7 +66,7 @@ open class KPrefText(open val builder: KPrefTextContract) : KPrefItemBase< class KPrefTextBuilder( globalOptions: GlobalOptions, titleId: Int, - getter: KPrefItemActions.() -> T, + getter: () -> T, setter: KPrefItemActions.(value: T) -> Unit ) : KPrefTextContract, BaseContract by BaseBuilder(globalOptions, titleId, getter, setter) { override var textGetter: (T) -> String? = { it?.toString() } diff --git a/kpref-activity/src/main/kotlin/ca/allanwang/kau/kpref/activity/items/KPrefTimePicker.kt b/kpref-activity/src/main/kotlin/ca/allanwang/kau/kpref/activity/items/KPrefTimePicker.kt index f2824a7..f50397c 100644 --- a/kpref-activity/src/main/kotlin/ca/allanwang/kau/kpref/activity/items/KPrefTimePicker.kt +++ b/kpref-activity/src/main/kotlin/ca/allanwang/kau/kpref/activity/items/KPrefTimePicker.kt @@ -48,7 +48,7 @@ open class KPrefTimePicker(override val builder: KPrefTimeContract) : KPrefText< class KPrefTimeBuilder( globalOptions: GlobalOptions, titleId: Int, - getter: KPrefItemActions.() -> Int, + getter: () -> Int, setter: KPrefItemActions.(value: Int) -> Unit ) : KPrefTimeContract, BaseContract by BaseBuilder(globalOptions, titleId, getter, setter) { -- cgit v1.2.3