aboutsummaryrefslogtreecommitdiff
path: root/core/src
diff options
context:
space:
mode:
authorAllan Wang <me@allanwang.ca>2018-09-06 15:12:51 -0400
committerGitHub <noreply@github.com>2018-09-06 15:12:51 -0400
commit6af0c6f7671898d0756c2e63dd17e830a2389885 (patch)
tree2b46565b6ac4efa6a03ecbccd10b13d9ab011a75 /core/src
parentdca58435ac0ca941a488c117363e2920e083dfa9 (diff)
downloadkau-6af0c6f7671898d0756c2e63dd17e830a2389885.tar.gz
kau-6af0c6f7671898d0756c2e63dd17e830a2389885.tar.bz2
kau-6af0c6f7671898d0756c2e63dd17e830a2389885.zip
Enhancement/LazyContext (#159)
* Update constraint version * Allow nullable lazy context
Diffstat (limited to 'core/src')
-rw-r--r--core/src/main/kotlin/ca/allanwang/kau/kotlin/LazyContext.kt7
1 files changed, 4 insertions, 3 deletions
diff --git a/core/src/main/kotlin/ca/allanwang/kau/kotlin/LazyContext.kt b/core/src/main/kotlin/ca/allanwang/kau/kotlin/LazyContext.kt
index ab531bd..0a45b65 100644
--- a/core/src/main/kotlin/ca/allanwang/kau/kotlin/LazyContext.kt
+++ b/core/src/main/kotlin/ca/allanwang/kau/kotlin/LazyContext.kt
@@ -18,10 +18,11 @@ fun lazyInterpolator(@InterpolatorRes id: Int) = lazyContext<Interpolator> { Ani
fun lazyAnimation(@AnimRes id: Int) = lazyContext<Animation> { AnimationUtils.loadAnimation(it, id) }
-fun <T : Any> lazyContext(initializer: (context: Context) -> T): LazyContext<T> = LazyContext(initializer)
+fun <T> lazyContext(initializer: (context: Context) -> T): LazyContext<T> = LazyContext(initializer)
-class LazyContext<out T : Any>(private val initializer: (context: Context) -> T, lock: Any? = null) {
- @Volatile private var _value: Any = UNINITIALIZED
+class LazyContext<out T>(private val initializer: (context: Context) -> T, lock: Any? = null) {
+ @Volatile
+ private var _value: Any? = UNINITIALIZED
private val lock = lock ?: this
fun invalidate() {