diff options
author | Allan Wang <me@allanwang.ca> | 2017-06-14 15:42:21 -0700 |
---|---|---|
committer | Allan Wang <me@allanwang.ca> | 2017-06-14 15:42:21 -0700 |
commit | 7edb081d0e808982ba0d5c5d2a0021aa1befcd8c (patch) | |
tree | fa2e9b638735874392a40094c8abcc472401cc18 | |
parent | 078190b3603d3eaa50e3e3238cb9e6e124a9d970 (diff) | |
download | kau-7edb081d0e808982ba0d5c5d2a0021aa1befcd8c.tar.gz kau-7edb081d0e808982ba0d5c5d2a0021aa1befcd8c.tar.bz2 kau-7edb081d0e808982ba0d5c5d2a0021aa1befcd8c.zip |
Add pref to click options
-rw-r--r-- | library/src/main/kotlin/ca/allanwang/kau/kpref/items/KPrefItemBase.kt | 10 | ||||
-rw-r--r-- | sample/src/main/kotlin/ca/allanwang/kau/sample/MainActivity.kt | 2 |
2 files changed, 6 insertions, 6 deletions
diff --git a/library/src/main/kotlin/ca/allanwang/kau/kpref/items/KPrefItemBase.kt b/library/src/main/kotlin/ca/allanwang/kau/kpref/items/KPrefItemBase.kt index 4c12961..3300f37 100644 --- a/library/src/main/kotlin/ca/allanwang/kau/kpref/items/KPrefItemBase.kt +++ b/library/src/main/kotlin/ca/allanwang/kau/kpref/items/KPrefItemBase.kt @@ -33,7 +33,7 @@ abstract class KPrefItemBase<T>(builder: KPrefAdapterBuilder, itemBase = Builder<T>() itemBase.itemBuilder() if (itemBase.onClick == null) itemBase.onClick = { - itemView, innerContent -> + itemView, innerContent, _ -> defaultOnClick(itemView, innerContent) } } @@ -53,8 +53,8 @@ abstract class KPrefItemBase<T>(builder: KPrefAdapterBuilder, } override final fun onClick(itemView: View, innerContent: View?): Boolean { - return if (enabled) itemBase.onClick?.invoke(itemView, innerContent) ?: false - else itemBase.onDisabledClick?.invoke(itemView, innerContent) ?: false + return if (enabled) itemBase.onClick?.invoke(itemView, innerContent, this) ?: false + else itemBase.onDisabledClick?.invoke(itemView, innerContent, this) ?: false } override fun unbindView(holder: ViewHolder) { @@ -70,8 +70,8 @@ abstract class KPrefItemBase<T>(builder: KPrefAdapterBuilder, open class Builder<T> { var enabler: () -> Boolean = { true } - var onClick: ((itemView: View, innerContent: View?) -> Boolean)? = null - var onDisabledClick: ((itemView: View, innerContent: View?) -> Boolean)? = null + var onClick: ((itemView: View, innerContent: View?, item: KPrefItemBase<T>) -> Boolean)? = null + var onDisabledClick: ((itemView: View, innerContent: View?, item: KPrefItemBase<T>) -> Boolean)? = null var getter: (() -> T)? = null var setter: ((value: T) -> Unit)? = null } diff --git a/sample/src/main/kotlin/ca/allanwang/kau/sample/MainActivity.kt b/sample/src/main/kotlin/ca/allanwang/kau/sample/MainActivity.kt index bf324a0..4efd9f1 100644 --- a/sample/src/main/kotlin/ca/allanwang/kau/sample/MainActivity.kt +++ b/sample/src/main/kotlin/ca/allanwang/kau/sample/MainActivity.kt @@ -40,7 +40,7 @@ class MainActivity : KPrefActivity() { getter = { KPrefSample.check3 } setter = { KPrefSample.check3 = it } onDisabledClick = { - itemView, innerContent -> + itemView, _, _ -> itemView.context.toast("I am still disabled") true } |