package X6FRs_4.IMuAHx_6.WwEq_13;

import X6FRs_4.IMuAHx_6.EuDEkJe_12.ZzDuCHW_20;
import android.os.Build;
import android.util.Log;
import android.view.View;
import android.widget.PopupWindow;
import java.lang.reflect.Field;
import java.lang.reflect.Method;
/* compiled from: PopupWindowCompat.java */
/* loaded from: classes.dex */
public final class FSaI4_7 {
    public static Field KQgRr5e_0;

    /* renamed from: KQgRr5e_0  reason: collision with other field name */
    public static Method f487KQgRr5e_0;

    /* renamed from: KQgRr5e_0  reason: collision with other field name */
    public static boolean f488KQgRr5e_0;
    public static boolean QxJ9d_1;

    public static void KQgRr5e_0(PopupWindow popupWindow, View view, int i, int i2, int i3) {
        if (Build.VERSION.SDK_INT >= 19) {
            popupWindow.showAsDropDown(view, i, i2, i3);
            return;
        }
        if ((X6FRs_4.IMuAHx_6.EuDEkJe_12.PGPF6hQ_2.KQgRr5e_0(i3, ZzDuCHW_20.Mqv2r_3(view)) & 7) == 5) {
            i -= popupWindow.getWidth() - view.getWidth();
        }
        popupWindow.showAsDropDown(view, i, i2);
    }

    public static void KQgRr5e_0(PopupWindow popupWindow, boolean z) {
        int i = Build.VERSION.SDK_INT;
        if (i >= 23) {
            popupWindow.setOverlapAnchor(z);
        } else if (i >= 21) {
            if (!QxJ9d_1) {
                try {
                    Field declaredField = PopupWindow.class.getDeclaredField("mOverlapAnchor");
                    KQgRr5e_0 = declaredField;
                    declaredField.setAccessible(true);
                } catch (NoSuchFieldException e) {
                    Log.i("PopupWindowCompatApi21", "Could not fetch mOverlapAnchor field from PopupWindow", e);
                }
                QxJ9d_1 = true;
            }
            Field field = KQgRr5e_0;
            if (field != null) {
                try {
                    field.set(popupWindow, Boolean.valueOf(z));
                } catch (IllegalAccessException e2) {
                    Log.i("PopupWindowCompatApi21", "Could not set overlap anchor field in PopupWindow", e2);
                }
            }
        }
    }

    public static void KQgRr5e_0(PopupWindow popupWindow, int i) {
        if (Build.VERSION.SDK_INT >= 23) {
            popupWindow.setWindowLayoutType(i);
            return;
        }
        if (!f488KQgRr5e_0) {
            try {
                Method declaredMethod = PopupWindow.class.getDeclaredMethod("setWindowLayoutType", Integer.TYPE);
                f487KQgRr5e_0 = declaredMethod;
                declaredMethod.setAccessible(true);
            } catch (Exception unused) {
            }
            f488KQgRr5e_0 = true;
        }
        Method method = f487KQgRr5e_0;
        if (method != null) {
            try {
                method.invoke(popupWindow, Integer.valueOf(i));
            } catch (Exception unused2) {
            }
        }
    }
}
