diff options
author | Allan Wang <me@allanwang.ca> | 2017-06-16 23:35:22 -0700 |
---|---|---|
committer | Allan Wang <me@allanwang.ca> | 2017-06-16 23:35:22 -0700 |
commit | e6c13788e94d10832116fc08e4c71d5f0d38511b (patch) | |
tree | c1048b24f7ddc02016013819ffe80f0b71b72c63 /library/src/main/kotlin/ca/allanwang/kau/kpref/KPrefDelegate.kt | |
parent | fbbea20e78f196ffccda5a3a844a265772c68ea4 (diff) | |
download | kau-e6c13788e94d10832116fc08e4c71d5f0d38511b.tar.gz kau-e6c13788e94d10832116fc08e4c71d5f0d38511b.tar.bz2 kau-e6c13788e94d10832116fc08e4c71d5f0d38511b.zip |
Embed color attributes and clean up sample
Diffstat (limited to 'library/src/main/kotlin/ca/allanwang/kau/kpref/KPrefDelegate.kt')
-rw-r--r-- | library/src/main/kotlin/ca/allanwang/kau/kpref/KPrefDelegate.kt | 5 |
1 files changed, 5 insertions, 0 deletions
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 8665d80..fb42e65 100644 --- a/library/src/main/kotlin/ca/allanwang/kau/kpref/KPrefDelegate.kt +++ b/library/src/main/kotlin/ca/allanwang/kau/kpref/KPrefDelegate.kt @@ -15,6 +15,11 @@ fun KPref.kpref(key: String, fallback: String, postSetter: (value: String) -> Un class StringSet(set: Collection<String>) : LinkedHashSet<String>(set) +/** + * Implementation of a kpref data item + * Contains a unique key for the shared preference as well as a nonnull fallback item + * Also contains an optional mutable postSetter that will be called every time a new value is given + */ class KPrefDelegate<T : Any> internal constructor(private val key: String, private val fallback: T, private val pref: KPref, var postSetter: (value: T) -> Unit = {}, lock: Any? = null) : Lazy<T>, java.io.Serializable { @Volatile private var _value: Any = UNINITIALIZED |