package com.bytedance.sdk.openadsdk.core;

import android.graphics.Rect;
import android.view.View;
import com.bytedance.sdk.openadsdk.utils.GS;
/* loaded from: classes2.dex */
public class pq {
    private static boolean YFl(View view, int i) {
        float YFl = YFl(view);
        return YFl > 0.0f && YFl >= ((float) i) / 100.0f;
    }

    public static float YFl(View view) {
        if (view != null) {
            try {
                if (view.getVisibility() == 0 && view.getParent() != null) {
                    Rect rect = new Rect();
                    if (view.getGlobalVisibleRect(rect)) {
                        long height = rect.height() * rect.width();
                        long height2 = view.getHeight() * view.getWidth();
                        if (height2 <= 0) {
                            return -1.0f;
                        }
                        return ((float) height) / ((float) height2);
                    }
                    return -1.0f;
                }
            } catch (Throwable unused) {
            }
        }
        return -1.0f;
    }

    private static boolean Sg(View view) {
        return view != null && view.isShown();
    }

    private static boolean Sg(View view, int i) {
        return view.getWidth() >= tN(view, i) && view.getHeight() >= AlY(view, i);
    }

    private static int tN(View view, int i) {
        if (i == 3) {
            return (int) (GS.tN(view.getContext().getApplicationContext()) * 0.7d);
        }
        return 20;
    }

    private static int AlY(View view, int i) {
        if (i == 3) {
            return GS.AlY(view.getContext().getApplicationContext()) / 2;
        }
        return 20;
    }

    private static int Sg(View view, int i, int i2) throws Throwable {
        if (view.getWindowVisibility() != 0) {
            return 4;
        }
        if (Sg(view)) {
            if (Sg(view, i2)) {
                return !YFl(view, i) ? 3 : 0;
            }
            return 6;
        }
        return 1;
    }

    public static boolean YFl(View view, int i, int i2) {
        if (i2 == 1) {
            while (view != null) {
                try {
                    if (view.getVisibility() == 0) {
                        if ((view instanceof com.bytedance.sdk.openadsdk.core.qsH.qO) || (view instanceof com.bytedance.sdk.openadsdk.core.tN.tN)) {
                            break;
                        }
                        view = (View) view.getParent();
                    } else {
                        return false;
                    }
                } catch (Throwable unused) {
                }
            }
        }
        return Sg(view, i, i2) == 0;
    }
}
