package com.bytedance.sdk.openadsdk.core;

import android.graphics.Rect;
import android.view.View;
import com.bytedance.sdk.openadsdk.utils.zan;

/* JADX INFO: loaded from: classes2.dex */
public class gc {
    private static boolean fm(View view, int i10) {
        float fFm = fm(view);
        return fFm > 0.0f && fFm >= ((float) i10) / 100.0f;
    }

    private static int lb(View view, int i10) {
        if (i10 == 3) {
            return zan.jnr(view.getContext().getApplicationContext()) / 2;
        }
        return 20;
    }

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

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

    private static int ro(View view, int i10) {
        if (i10 == 3) {
            return (int) (((double) zan.lb(view.getContext().getApplicationContext())) * 0.7d);
        }
        return 20;
    }

    private static int ro(View view, int i10, int i11, boolean z10) throws Throwable {
        if (view.getWindowVisibility() != 0) {
            return 4;
        }
        if (!ro(view)) {
            return 1;
        }
        if (fm(view, i11, z10)) {
            return !fm(view, i10) ? 3 : 0;
        }
        return 6;
    }

    private static boolean fm(View view, int i10, boolean z10) {
        return (i10 == 1 && z10) ? view.getWidth() > 0 && view.getHeight() > 0 : view.getWidth() >= ro(view, i10) && view.getHeight() >= lb(view, i10);
    }

    public static boolean fm(View view, int i10, int i11, boolean z10) {
        if (i11 == 1) {
            while (view != null) {
                try {
                    if (view.getVisibility() != 0) {
                        return false;
                    }
                    if ((view instanceof com.bytedance.sdk.openadsdk.core.vt.sds) || (view instanceof com.bytedance.sdk.openadsdk.core.yz.yz)) {
                        break;
                    }
                    view = (View) view.getParent();
                } catch (Throwable unused) {
                }
            }
            if (z10) {
                i10 = 0;
            }
        }
        return ro(view, i10, i11, z10) == 0;
    }
}
