15 lines
475 B
Kotlin
15 lines
475 B
Kotlin
|
package com.keylesspalace.tusky.util
|
||
|
|
||
|
import android.view.LayoutInflater
|
||
|
import androidx.appcompat.app.AppCompatActivity
|
||
|
import androidx.viewbinding.ViewBinding
|
||
|
|
||
|
/**
|
||
|
* https://medium.com/@Zhuinden/simple-one-liner-viewbinding-in-fragments-and-activities-with-kotlin-961430c6c07c
|
||
|
*/
|
||
|
|
||
|
inline fun <T : ViewBinding> AppCompatActivity.viewBinding(
|
||
|
crossinline bindingInflater: (LayoutInflater) -> T
|
||
|
) = lazy(LazyThreadSafetyMode.NONE) {
|
||
|
bindingInflater(layoutInflater)
|
||
|
}
|