From 6af0c6f7671898d0756c2e63dd17e830a2389885 Mon Sep 17 00:00:00 2001 From: Allan Wang Date: Thu, 6 Sep 2018 15:12:51 -0400 Subject: Enhancement/LazyContext (#159) * Update constraint version * Allow nullable lazy context --- buildSrc/src/main/groovy/ca/allanwang/kau/Versions.groovy | 2 +- core/src/main/kotlin/ca/allanwang/kau/kotlin/LazyContext.kt | 7 ++++--- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/buildSrc/src/main/groovy/ca/allanwang/kau/Versions.groovy b/buildSrc/src/main/groovy/ca/allanwang/kau/Versions.groovy index decb2fe..4b7149e 100644 --- a/buildSrc/src/main/groovy/ca/allanwang/kau/Versions.groovy +++ b/buildSrc/src/main/groovy/ca/allanwang/kau/Versions.groovy @@ -24,7 +24,7 @@ class Versions { static def blurry = '2.1.1' // https://dl.google.com/dl/android/maven2/com/android/support/constraint/group-index.xml - static def constraintLayout = '1.1.0' + static def constraintLayout = '1.1.3' // https://github.com/mikepenz/FastAdapter#using-maven static def fastAdapter = '3.2.5' 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 { Ani fun lazyAnimation(@AnimRes id: Int) = lazyContext { AnimationUtils.loadAnimation(it, id) } -fun lazyContext(initializer: (context: Context) -> T): LazyContext = LazyContext(initializer) +fun lazyContext(initializer: (context: Context) -> T): LazyContext = LazyContext(initializer) -class LazyContext(private val initializer: (context: Context) -> T, lock: Any? = null) { - @Volatile private var _value: Any = UNINITIALIZED +class LazyContext(private val initializer: (context: Context) -> T, lock: Any? = null) { + @Volatile + private var _value: Any? = UNINITIALIZED private val lock = lock ?: this fun invalidate() { -- cgit v1.2.3