diff options
Diffstat (limited to 'library/src/main/kotlin/ca/allanwang/kau/utils/Kotterknife.kt')
-rw-r--r-- | library/src/main/kotlin/ca/allanwang/kau/utils/Kotterknife.kt | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/library/src/main/kotlin/ca/allanwang/kau/utils/Kotterknife.kt b/library/src/main/kotlin/ca/allanwang/kau/utils/Kotterknife.kt index a8ddd2a..fca5677 100644 --- a/library/src/main/kotlin/ca/allanwang/kau/utils/Kotterknife.kt +++ b/library/src/main/kotlin/ca/allanwang/kau/utils/Kotterknife.kt @@ -108,11 +108,11 @@ private fun viewNotFound(id:Int, desc: KProperty<*>): Nothing = @Suppress("UNCHECKED_CAST") private fun <T, V : View> required(id: Int, finder: T.(Int) -> View?) - = Lazy { t: T, desc -> t.finder(id) as V? ?: viewNotFound(id, desc) } + = Lazy { t: T, desc -> (t.finder(id) as V?)?.apply { } ?: viewNotFound(id, desc) } @Suppress("UNCHECKED_CAST") private fun <T, V : View> optional(id: Int, finder: T.(Int) -> View?) - = Lazy { t: T, desc -> t.finder(id) as V? } + = Lazy { t: T, _ -> t.finder(id) as V? } @Suppress("UNCHECKED_CAST") private fun <T, V : View> required(ids: IntArray, finder: T.(Int) -> View?) @@ -120,7 +120,7 @@ private fun <T, V : View> required(ids: IntArray, finder: T.(Int) -> View?) @Suppress("UNCHECKED_CAST") private fun <T, V : View> optional(ids: IntArray, finder: T.(Int) -> View?) - = Lazy { t: T, desc -> ids.map { t.finder(it) as V? }.filterNotNull() } + = Lazy { t: T, _ -> ids.map { t.finder(it) as V? }.filterNotNull() } // Like Kotlin's lazy delegate but the initializer gets the target and metadata passed to it private class Lazy<T, V>(private val initializer: (T, KProperty<*>) -> V) : ReadOnlyProperty<T, V> { |