package app.furmeet.events.system.helper

import android.content.res.Resources
import android.graphics.Rect
import android.view.View

object ViewVisibilityDiscriminer {
    fun isViewVisible(view: View): Boolean {
        if (!view.isShown) {
            return false
        }
        val actualPosition = Rect()
        view.getGlobalVisibleRect(actualPosition)
        val dm = Resources.getSystem().displayMetrics
        val screen = Rect(0, 0, dm.widthPixels, dm.heightPixels)
        return actualPosition.intersect(screen)
    }
}