|
|
|
@ -6,8 +6,16 @@ import android.view.LayoutInflater |
|
|
|
|
import androidx.core.app.ComponentActivity |
|
|
|
|
import androidx.viewbinding.ViewBinding |
|
|
|
|
|
|
|
|
|
inline fun <T : ViewBinding> ComponentActivity.viewBinding(crossinline bindingInflater: (LayoutInflater) -> T) = |
|
|
|
|
lazy(LazyThreadSafetyMode.SYNCHRONIZED) { |
|
|
|
|
val invoke = bindingInflater.invoke(layoutInflater) |
|
|
|
|
invoke |
|
|
|
|
/** |
|
|
|
|
* |
|
|
|
|
*/ |
|
|
|
|
inline fun <T : ViewBinding> ComponentActivity.viewBinding( |
|
|
|
|
crossinline bindingInflater: (LayoutInflater) -> T, |
|
|
|
|
setContentView: Boolean = false |
|
|
|
|
) = lazy(LazyThreadSafetyMode.SYNCHRONIZED) { |
|
|
|
|
val binding = bindingInflater.invoke(layoutInflater) |
|
|
|
|
if (setContentView) { |
|
|
|
|
setContentView(binding.root) |
|
|
|
|
} |
|
|
|
|
binding |
|
|
|
|
} |
|
|
|
|