package com.convenient.android.common.extension

import android.view.LayoutInflater
import android.view.ViewGroup
import androidx.viewbinding.ViewBinding
import com.convenient.android.common.base.view.BaseActivity

fun <VB : ViewBinding> BaseActivity.activityBinding(inflate: (LayoutInflater) -> VB) = lazy {
    inflate(layoutInflater).also {
        setContentView(it.root)
    }
}

fun <VB : ViewBinding> ViewGroup.viewGroupBinding(inflate: (LayoutInflater, ViewGroup?, Boolean) -> VB, attachToParent: Boolean = true) = lazy {
    inflate(LayoutInflater.from(context), if (attachToParent) this else null, attachToParent)
}