package defpackage;

import android.content.Context;
import android.content.res.TypedArray;
import android.graphics.Rect;
import android.graphics.drawable.Drawable;
import android.os.Build;
import android.os.Handler;
import android.util.AttributeSet;
import android.view.View;
import android.widget.AdapterView;
import android.widget.ListAdapter;
import android.widget.PopupWindow;
import java.lang.reflect.Method;

/* JADX INFO: renamed from: ᵢᵢ, reason: contains not printable characters */
/* JADX INFO: loaded from: classes3.dex */
public class C3295 implements InterfaceC3957 {

    /* JADX INFO: renamed from: ˀᵗ, reason: contains not printable characters */
    public static final Method f12648;

    /* JADX INFO: renamed from: ˏᵩʨ, reason: contains not printable characters */
    public static final Method f12649;

    /* JADX INFO: renamed from: ᵛˀˊ, reason: contains not printable characters */
    public static final Method f12650;

    /* JADX INFO: renamed from: ʿٴˇ, reason: contains not printable characters */
    public boolean f12652;

    /* JADX INFO: renamed from: ˀᵭ, reason: contains not printable characters */
    public View f12653;

    /* JADX INFO: renamed from: ˁʢᵛ, reason: contains not printable characters */
    public final C3566 f12654;

    /* JADX INFO: renamed from: ˁˌᵩ, reason: contains not printable characters */
    public C0067 f12655;

    /* JADX INFO: renamed from: ˈᵲᵢ, reason: contains not printable characters */
    public int f12656;

    /* JADX INFO: renamed from: ˈⁱᵡ, reason: contains not printable characters */
    public final Handler f12657;

    /* JADX INFO: renamed from: ˊˌˊ, reason: contains not printable characters */
    public boolean f12659;

    /* JADX INFO: renamed from: ˊᵡᵗʨ, reason: contains not printable characters */
    public AdapterView.OnItemSelectedListener f12660;

    /* JADX INFO: renamed from: ˊᵾʽʼ, reason: contains not printable characters */
    public AdapterView.OnItemClickListener f12661;

    /* JADX INFO: renamed from: ˌᴵ, reason: contains not printable characters */
    public final Context f12662;

    /* JADX INFO: renamed from: ˑˊᵲ, reason: contains not printable characters */
    public boolean f12665;

    /* JADX INFO: renamed from: ᵔᵖᵹᵫ, reason: contains not printable characters */
    public C5565 f12666;

    /* JADX INFO: renamed from: ᵜᵪʾ, reason: contains not printable characters */
    public ListAdapter f12668;

    /* JADX INFO: renamed from: ᵞᵛᵘ, reason: contains not printable characters */
    public Rect f12669;

    /* JADX INFO: renamed from: ᵶˇᵱ, reason: contains not printable characters */
    public int f12675;

    /* JADX INFO: renamed from: ᵸˆˁ, reason: contains not printable characters */
    public boolean f12676;

    /* JADX INFO: renamed from: ᵨᵼⁱ, reason: contains not printable characters */
    public final int f12672 = -2;

    /* JADX INFO: renamed from: ᵯᵷʽ, reason: contains not printable characters */
    public int f12673 = -2;

    /* JADX INFO: renamed from: ˌᵨʠᵫ, reason: contains not printable characters */
    public final int f12663 = 1002;

    /* JADX INFO: renamed from: ᵠˏˏ, reason: contains not printable characters */
    public int f12670 = 0;

    /* JADX INFO: renamed from: ˉᵵᵜ, reason: contains not printable characters */
    public final int f12658 = Integer.MAX_VALUE;

    /* JADX INFO: renamed from: ᵛˑﹳ, reason: contains not printable characters */
    public final RunnableC1700 f12667 = new RunnableC1700(this, 1);

    /* JADX INFO: renamed from: ᵵᵬᵽ, reason: contains not printable characters */
    public final ViewOnTouchListenerC4680 f12674 = new ViewOnTouchListenerC4680(this);

    /* JADX INFO: renamed from: ˑʢ, reason: contains not printable characters */
    public final C1387 f12664 = new C1387(this);

    /* JADX INFO: renamed from: ʽᵡᵢᵾ, reason: contains not printable characters */
    public final RunnableC1700 f12651 = new RunnableC1700(this, 0);

    /* JADX INFO: renamed from: ᵨˈʼﹶ, reason: contains not printable characters */
    public final Rect f12671 = new Rect();

    static {
        int i = Build.VERSION.SDK_INT;
        Class cls = Boolean.TYPE;
        if (i <= 28) {
            try {
                f12648 = PopupWindow.class.getDeclaredMethod("setClipToScreenEnabled", cls);
            } catch (NoSuchMethodException unused) {
            }
            try {
                f12650 = PopupWindow.class.getDeclaredMethod("setEpicenterBounds", Rect.class);
            } catch (NoSuchMethodException unused2) {
            }
        }
        if (Build.VERSION.SDK_INT == 23) {
            try {
                f12649 = PopupWindow.class.getDeclaredMethod("getMaxAvailableHeight", View.class, Integer.TYPE, cls);
            } catch (NoSuchMethodException unused3) {
            }
        }
    }

    public C3295(Context context, AttributeSet attributeSet, int i, int i2) {
        int resourceId;
        this.f12662 = context;
        this.f12657 = new Handler(context.getMainLooper());
        TypedArray typedArrayObtainStyledAttributes = context.obtainStyledAttributes(attributeSet, AbstractC0430.f2392, i, 0);
        this.f12675 = typedArrayObtainStyledAttributes.getDimensionPixelOffset(0, 0);
        int dimensionPixelOffset = typedArrayObtainStyledAttributes.getDimensionPixelOffset(1, 0);
        this.f12656 = dimensionPixelOffset;
        if (dimensionPixelOffset != 0) {
            this.f12676 = true;
        }
        typedArrayObtainStyledAttributes.recycle();
        C3566 c3566 = new C3566(context, attributeSet, i, 0);
        TypedArray typedArrayObtainStyledAttributes2 = context.obtainStyledAttributes(attributeSet, AbstractC0430.f2378, i, 0);
        if (typedArrayObtainStyledAttributes2.hasValue(2)) {
            c3566.setOverlapAnchor(typedArrayObtainStyledAttributes2.getBoolean(2, false));
        }
        c3566.setBackgroundDrawable((!typedArrayObtainStyledAttributes2.hasValue(0) || (resourceId = typedArrayObtainStyledAttributes2.getResourceId(0, 0)) == 0) ? typedArrayObtainStyledAttributes2.getDrawable(0) : ᵥˇᵛˎ.ᵶˇᵱ(context, resourceId));
        typedArrayObtainStyledAttributes2.recycle();
        this.f12654 = c3566;
        c3566.setInputMethodMode(1);
    }

    @Override // defpackage.InterfaceC3957
    public final void dismiss() {
        C3566 c3566 = this.f12654;
        c3566.dismiss();
        c3566.setContentView(null);
        this.f12666 = null;
        this.f12657.removeCallbacks(this.f12667);
    }

    /* JADX INFO: renamed from: ʽˈˋ, reason: contains not printable characters */
    public final int m7539() {
        return this.f12675;
    }

    /* JADX INFO: renamed from: ˊᵙᵾᵲ, reason: contains not printable characters */
    public final void m7540(int i) {
        Drawable background = this.f12654.getBackground();
        if (background == null) {
            this.f12673 = i;
            return;
        }
        Rect rect = this.f12671;
        background.getPadding(rect);
        this.f12673 = rect.left + rect.right + i;
    }

    /* JADX INFO: renamed from: ːˏᵟᵯ, reason: contains not printable characters */
    public final void m7541(int i) {
        this.f12675 = i;
    }

    /* JADX INFO: renamed from: ᵟᵹᵙ */
    public void mo5928(ListAdapter listAdapter) {
        C0067 c0067 = this.f12655;
        if (c0067 == null) {
            this.f12655 = new C0067(this);
        } else {
            ListAdapter listAdapter2 = this.f12668;
            if (listAdapter2 != null) {
                listAdapter2.unregisterDataSetObserver(c0067);
            }
        }
        this.f12668 = listAdapter;
        if (listAdapter != null) {
            listAdapter.registerDataSetObserver(this.f12655);
        }
        C5565 c5565 = this.f12666;
        if (c5565 != null) {
            c5565.setAdapter(this.f12668);
        }
    }

    /* JADX INFO: renamed from: ᵨᵣ, reason: contains not printable characters */
    public final Drawable m7542() {
        return this.f12654.getBackground();
    }

    /* JADX INFO: renamed from: ᵪᵹᵥᵻ, reason: contains not printable characters */
    public final int m7543() {
        if (this.f12676) {
            return this.f12656;
        }
        return 0;
    }

    /* JADX INFO: renamed from: ᵮᵣᵗˈ, reason: contains not printable characters */
    public final void m7544(int i) {
        this.f12656 = i;
        this.f12676 = true;
    }

    /* JADX INFO: renamed from: ᵱʡˏ */
    public C5565 mo6791(Context context, boolean z) {
        return new C5565(context, z);
    }

    @Override // defpackage.InterfaceC3957
    /* JADX INFO: renamed from: ᵱᵽʡᵚ, reason: contains not printable characters */
    public final C5565 mo7545() {
        return this.f12666;
    }

    @Override // defpackage.InterfaceC3957
    /* JADX INFO: renamed from: ᵲᵶᵳˈ, reason: contains not printable characters */
    public final boolean mo7546() {
        return this.f12654.isShowing();
    }

    /* JADX INFO: renamed from: ᵻʽᵯ, reason: contains not printable characters */
    public final void m7547(Drawable drawable) {
        this.f12654.setBackgroundDrawable(drawable);
    }

    @Override // defpackage.InterfaceC3957
    /* JADX INFO: renamed from: ᵻˈᵦʼ, reason: contains not printable characters */
    public final void mo7548() {
        int i;
        int iM8162;
        int paddingBottom;
        C5565 c5565;
        C5565 c55652 = this.f12666;
        Context context = this.f12662;
        C3566 c3566 = this.f12654;
        int i2 = 1;
        if (c55652 == null) {
            C5565 c5565Mo6791 = mo6791(context, !this.f12659);
            this.f12666 = c5565Mo6791;
            c5565Mo6791.setAdapter(this.f12668);
            this.f12666.setOnItemClickListener(this.f12661);
            this.f12666.setFocusable(true);
            this.f12666.setFocusableInTouchMode(true);
            this.f12666.setOnItemSelectedListener(new C0182(i2, this));
            this.f12666.setOnScrollListener(this.f12664);
            AdapterView.OnItemSelectedListener onItemSelectedListener = this.f12660;
            if (onItemSelectedListener != null) {
                this.f12666.setOnItemSelectedListener(onItemSelectedListener);
            }
            c3566.setContentView(this.f12666);
        }
        Drawable background = c3566.getBackground();
        Rect rect = this.f12671;
        if (background != null) {
            background.getPadding(rect);
            int i3 = rect.top;
            i = rect.bottom + i3;
            if (!this.f12676) {
                this.f12656 = -i3;
            }
        } else {
            rect.setEmpty();
            i = 0;
        }
        boolean z = c3566.getInputMethodMode() == 2;
        View view = this.f12653;
        int i4 = this.f12656;
        if (Build.VERSION.SDK_INT == 23) {
            Method method = f12649;
            if (method != null) {
                try {
                    iM8162 = ((Integer) method.invoke(c3566, view, Integer.valueOf(i4), Boolean.valueOf(z))).intValue();
                } catch (Exception unused) {
                    iM8162 = c3566.getMaxAvailableHeight(view, i4);
                }
            } else {
                iM8162 = c3566.getMaxAvailableHeight(view, i4);
            }
        } else {
            iM8162 = AbstractC3619.m8162(c3566, view, i4, z);
        }
        int i5 = this.f12672;
        if (i5 == -1) {
            paddingBottom = iM8162 + i;
        } else {
            int i6 = this.f12673;
            int iM11208 = this.f12666.m11208(i6 != -2 ? i6 != -1 ? View.MeasureSpec.makeMeasureSpec(i6, 1073741824) : View.MeasureSpec.makeMeasureSpec(context.getResources().getDisplayMetrics().widthPixels - (rect.left + rect.right), 1073741824) : View.MeasureSpec.makeMeasureSpec(context.getResources().getDisplayMetrics().widthPixels - (rect.left + rect.right), Integer.MIN_VALUE), iM8162);
            paddingBottom = iM11208 + (iM11208 > 0 ? this.f12666.getPaddingBottom() + this.f12666.getPaddingTop() + i : 0);
        }
        boolean z2 = c3566.getInputMethodMode() == 2;
        c3566.setWindowLayoutType(this.f12663);
        if (c3566.isShowing()) {
            if (this.f12653.isAttachedToWindow()) {
                int width = this.f12673;
                if (width == -1) {
                    width = -1;
                } else if (width == -2) {
                    width = this.f12653.getWidth();
                }
                if (i5 == -1) {
                    i5 = z2 ? paddingBottom : -1;
                    int i7 = this.f12673;
                    if (z2) {
                        c3566.setWidth(i7 == -1 ? -1 : 0);
                        c3566.setHeight(0);
                    } else {
                        c3566.setWidth(i7 == -1 ? -1 : 0);
                        c3566.setHeight(-1);
                    }
                } else if (i5 == -2) {
                    i5 = paddingBottom;
                }
                c3566.setOutsideTouchable(true);
                int i8 = width;
                c3566.update(this.f12653, this.f12675, this.f12656, i8 < 0 ? -1 : i8, i5 < 0 ? -1 : i5);
                return;
            }
            return;
        }
        int width2 = this.f12673;
        if (width2 == -1) {
            width2 = -1;
        } else if (width2 == -2) {
            width2 = this.f12653.getWidth();
        }
        if (i5 == -1) {
            i5 = -1;
        } else if (i5 == -2) {
            i5 = paddingBottom;
        }
        c3566.setWidth(width2);
        c3566.setHeight(i5);
        if (Build.VERSION.SDK_INT <= 28) {
            Method method2 = f12648;
            if (method2 != null) {
                try {
                    method2.invoke(c3566, Boolean.TRUE);
                } catch (Exception unused2) {
                }
            }
        } else {
            AbstractC1630.m4502(c3566);
        }
        c3566.setOutsideTouchable(true);
        c3566.setTouchInterceptor(this.f12674);
        if (this.f12652) {
            c3566.setOverlapAnchor(this.f12665);
        }
        if (Build.VERSION.SDK_INT <= 28) {
            Method method3 = f12650;
            if (method3 != null) {
                try {
                    method3.invoke(c3566, this.f12669);
                } catch (Exception unused3) {
                }
            }
        } else {
            AbstractC1630.m4503(c3566, this.f12669);
        }
        c3566.showAsDropDown(this.f12653, this.f12675, this.f12656, this.f12670);
        this.f12666.setSelection(-1);
        if ((!this.f12659 || this.f12666.isInTouchMode()) && (c5565 = this.f12666) != null) {
            c5565.setListSelectionHidden(true);
            c5565.requestLayout();
        }
        if (this.f12659) {
            return;
        }
        this.f12657.post(this.f12651);
    }
}
