package p032k0;

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;
import p023h0.C0829h1;
import p023h0.C0936r;

/* renamed from: k0.z */
/* loaded from: classes.dex */
public final class C1346z {

    /* renamed from: a */
    public static Method f3005a;

    /* renamed from: b */
    public static boolean f3006b;

    /* renamed from: c */
    public static Field f3007c;

    /* renamed from: d */
    public static boolean f3008d;

    /* renamed from: k0.z$a */
    /* loaded from: classes.dex */
    public static class C1347a {
        /* renamed from: a */
        public static void m1582a(PopupWindow popupWindow, View view, int i, int i2, int i3) {
            popupWindow.showAsDropDown(view, i, i2, i3);
        }
    }

    /* renamed from: k0.z$b */
    /* loaded from: classes.dex */
    public static class C1348b {
        /* renamed from: a */
        public static boolean m1581a(PopupWindow popupWindow) {
            boolean overlapAnchor;
            overlapAnchor = popupWindow.getOverlapAnchor();
            return overlapAnchor;
        }

        /* renamed from: b */
        public static int m1580b(PopupWindow popupWindow) {
            int windowLayoutType;
            windowLayoutType = popupWindow.getWindowLayoutType();
            return windowLayoutType;
        }

        /* renamed from: c */
        public static void m1579c(PopupWindow popupWindow, boolean z) {
            popupWindow.setOverlapAnchor(z);
        }

        /* renamed from: d */
        public static void m1578d(PopupWindow popupWindow, int i) {
            popupWindow.setWindowLayoutType(i);
        }
    }

    /* renamed from: a */
    public static void m1585a(PopupWindow popupWindow, boolean z) {
        int i = Build.VERSION.SDK_INT;
        if (i >= 23) {
            C1348b.m1579c(popupWindow, z);
        } else if (i >= 21) {
            if (!f3008d) {
                try {
                    Field declaredField = PopupWindow.class.getDeclaredField("mOverlapAnchor");
                    f3007c = declaredField;
                    declaredField.setAccessible(true);
                } catch (NoSuchFieldException e) {
                    Log.i("PopupWindowCompatApi21", "Could not fetch mOverlapAnchor field from PopupWindow", e);
                }
                f3008d = true;
            }
            Field field = f3007c;
            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);
                }
            }
        }
    }

    /* renamed from: b */
    public static void m1584b(PopupWindow popupWindow, int i) {
        if (Build.VERSION.SDK_INT >= 23) {
            C1348b.m1578d(popupWindow, i);
            return;
        }
        if (!f3006b) {
            try {
                Method declaredMethod = PopupWindow.class.getDeclaredMethod("setWindowLayoutType", Integer.TYPE);
                f3005a = declaredMethod;
                declaredMethod.setAccessible(true);
            } catch (Exception unused) {
            }
            f3006b = true;
        }
        Method method = f3005a;
        if (method != null) {
            try {
                method.invoke(popupWindow, Integer.valueOf(i));
            } catch (Exception unused2) {
            }
        }
    }

    /* renamed from: c */
    public static void m1583c(PopupWindow popupWindow, View view, int i, int i2, int i3) {
        if (Build.VERSION.SDK_INT >= 19) {
            C1347a.m1582a(popupWindow, view, i, i2, i3);
            return;
        }
        if ((C0936r.m2528a(i3, C0829h1.m2816r(view)) & 7) == 5) {
            i -= popupWindow.getWidth() - view.getWidth();
        }
        popupWindow.showAsDropDown(view, i, i2);
    }
}