package com.adealink.weparty.commonui.ext

import androidx.fragment.app.Fragment
import androidx.lifecycle.LifecycleOwner
import com.adealink.frame.ext.isViewBindingValid
import com.adealink.weparty.commonui.BaseActivity

fun LifecycleOwner.isUiValid(): Boolean {
    return when (this) {
        is Fragment -> {
            return isViewBindingValid()
        }

        is BaseActivity -> {
            return !isFinishing && !isDestroyed && application != null
        }

        else -> {
            false
        }
    }
}