From 594e0354c80f24e1b80b8071e55cfec1d86e44ad Mon Sep 17 00:00:00 2001 From: Allan Wang Date: Thu, 15 Jun 2017 13:05:31 -0700 Subject: Add remaining post setter callbacks --- .../main/kotlin/ca/allanwang/kau/kpref/KPrefDelegate.kt | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) (limited to 'library/src/main') diff --git a/library/src/main/kotlin/ca/allanwang/kau/kpref/KPrefDelegate.kt b/library/src/main/kotlin/ca/allanwang/kau/kpref/KPrefDelegate.kt index fe67ecc..8665d80 100644 --- a/library/src/main/kotlin/ca/allanwang/kau/kpref/KPrefDelegate.kt +++ b/library/src/main/kotlin/ca/allanwang/kau/kpref/KPrefDelegate.kt @@ -5,17 +5,17 @@ package ca.allanwang.kau.kpref */ private object UNINITIALIZED -fun KPref.kpref(key: String, fallback: Boolean): KPrefDelegate = KPrefDelegate(key, fallback, this) -fun KPref.kpref(key: String, fallback: Double): KPrefDelegate = KPrefDelegate(key, fallback.toFloat(), this) -fun KPref.kpref(key: String, fallback: Float): KPrefDelegate = KPrefDelegate(key, fallback, this) -fun KPref.kpref(key: String, fallback: Int): KPrefDelegate = KPrefDelegate(key, fallback, this) -fun KPref.kpref(key: String, fallback: Long): KPrefDelegate = KPrefDelegate(key, fallback, this) -fun KPref.kpref(key: String, fallback: Set): KPrefDelegate = KPrefDelegate(key, StringSet(fallback), this) -fun KPref.kpref(key: String, fallback: String): KPrefDelegate = KPrefDelegate(key, fallback, this) +fun KPref.kpref(key: String, fallback: Boolean, postSetter: (value: Boolean) -> Unit = {}): KPrefDelegate = KPrefDelegate(key, fallback, this, postSetter) +fun KPref.kpref(key: String, fallback: Double, postSetter: (value: Float) -> Unit = {}): KPrefDelegate = KPrefDelegate(key, fallback.toFloat(), this, postSetter) +fun KPref.kpref(key: String, fallback: Float, postSetter: (value: Float) -> Unit = {}): KPrefDelegate = KPrefDelegate(key, fallback, this, postSetter) +fun KPref.kpref(key: String, fallback: Int, postSetter: (value: Int) -> Unit = {}): KPrefDelegate = KPrefDelegate(key, fallback, this, postSetter) +fun KPref.kpref(key: String, fallback: Long, postSetter: (value: Long) -> Unit = {}): KPrefDelegate = KPrefDelegate(key, fallback, this, postSetter) +fun KPref.kpref(key: String, fallback: Set, postSetter: (value: Set) -> Unit = {}): KPrefDelegate = KPrefDelegate(key, StringSet(fallback), this, postSetter) +fun KPref.kpref(key: String, fallback: String, postSetter: (value: String) -> Unit = {}): KPrefDelegate = KPrefDelegate(key, fallback, this, postSetter) class StringSet(set: Collection) : LinkedHashSet(set) -class KPrefDelegate internal constructor(private val key: String, private val fallback: T, private val pref: KPref, lock: Any? = null, var postSetter: (value: T) -> Unit = {}) : Lazy, java.io.Serializable { +class KPrefDelegate internal constructor(private val key: String, private val fallback: T, private val pref: KPref, var postSetter: (value: T) -> Unit = {}, lock: Any? = null) : Lazy, java.io.Serializable { @Volatile private var _value: Any = UNINITIALIZED private val lock = lock ?: this -- cgit v1.2.3