package p037.p041.p051;

import android.R;
import android.content.Context;
import android.content.DialogInterface;
import android.content.res.ColorStateList;
import android.content.res.Resources;
import android.content.res.TypedArray;
import android.database.DataSetObserver;
import android.graphics.PorterDuff;
import android.graphics.Rect;
import android.graphics.drawable.Drawable;
import android.os.Build;
import android.os.Parcel;
import android.os.Parcelable;
import android.util.AttributeSet;
import android.util.Log;
import android.view.MotionEvent;
import android.view.View;
import android.view.ViewGroup;
import android.view.ViewTreeObserver;
import android.widget.AdapterView;
import android.widget.ArrayAdapter;
import android.widget.ListAdapter;
import android.widget.ListView;
import android.widget.PopupWindow;
import android.widget.Spinner;
import android.widget.SpinnerAdapter;
import android.widget.ThemedSpinnerAdapter;
import androidx.appcompat.app.AlertController;
import p037.p041.C1474;
import p037.p041.C1477;
import p037.p041.p042.DialogInterfaceC1489;
import p037.p041.p043.p044.C1527;
import p037.p041.p049.C1550;
import p037.p065.p078.C1920;

/* JADX INFO: renamed from: މ.ؠ.ގ.ޓ, reason: contains not printable characters */
/* JADX INFO: loaded from: classes.dex */
public class C1628 extends Spinner {

    /* JADX INFO: renamed from: ދ, reason: contains not printable characters */
    public static final int[] f5283 = {R.attr.spinnerMode};

    /* JADX INFO: renamed from: ރ, reason: contains not printable characters */
    public final C1610 f5284;

    /* JADX INFO: renamed from: ބ, reason: contains not printable characters */
    public final Context f5285;

    /* JADX INFO: renamed from: ޅ, reason: contains not printable characters */
    public AbstractViewOnTouchListenerC1655 f5286;

    /* JADX INFO: renamed from: ކ, reason: contains not printable characters */
    public SpinnerAdapter f5287;

    /* JADX INFO: renamed from: އ, reason: contains not printable characters */
    public final boolean f5288;

    /* JADX INFO: renamed from: ވ, reason: contains not printable characters */
    public InterfaceC1638 f5289;

    /* JADX INFO: renamed from: މ, reason: contains not printable characters */
    public int f5290;

    /* JADX INFO: renamed from: ފ, reason: contains not printable characters */
    public final Rect f5291;

    /* JADX INFO: renamed from: މ.ؠ.ގ.ޓ$֏, reason: contains not printable characters */
    public class ViewTreeObserverOnGlobalLayoutListenerC1629 implements ViewTreeObserver.OnGlobalLayoutListener {
        public ViewTreeObserverOnGlobalLayoutListenerC1629() {
        }

        @Override // android.view.ViewTreeObserver.OnGlobalLayoutListener
        public void onGlobalLayout() {
            if (!C1628.this.getInternalPopup().mo3183()) {
                C1628.this.m3177();
            }
            ViewTreeObserver viewTreeObserver = C1628.this.getViewTreeObserver();
            if (viewTreeObserver != null) {
                viewTreeObserver.removeOnGlobalLayoutListener(this);
            }
        }
    }

    /* JADX INFO: renamed from: މ.ؠ.ގ.ޓ$ؠ, reason: contains not printable characters */
    public class DialogInterfaceOnClickListenerC1630 implements InterfaceC1638, DialogInterface.OnClickListener {

        /* JADX INFO: renamed from: ރ, reason: contains not printable characters */
        public DialogInterfaceC1489 f5293;

        /* JADX INFO: renamed from: ބ, reason: contains not printable characters */
        public ListAdapter f5294;

        /* JADX INFO: renamed from: ޅ, reason: contains not printable characters */
        public CharSequence f5295;

        public DialogInterfaceOnClickListenerC1630() {
        }

        @Override // p037.p041.p051.C1628.InterfaceC1638
        public void dismiss() {
            DialogInterfaceC1489 dialogInterfaceC1489 = this.f5293;
            if (dialogInterfaceC1489 != null) {
                dialogInterfaceC1489.dismiss();
                this.f5293 = null;
            }
        }

        @Override // android.content.DialogInterface.OnClickListener
        public void onClick(DialogInterface dialogInterface, int i) {
            C1628.this.setSelection(i);
            if (C1628.this.getOnItemClickListener() != null) {
                C1628.this.performItemClick(null, i, this.f5294.getItemId(i));
            }
            DialogInterfaceC1489 dialogInterfaceC1489 = this.f5293;
            if (dialogInterfaceC1489 != null) {
                dialogInterfaceC1489.dismiss();
                this.f5293 = null;
            }
        }

        @Override // p037.p041.p051.C1628.InterfaceC1638
        /* JADX INFO: renamed from: ֏, reason: contains not printable characters */
        public void mo3178(int i) {
            Log.e("AppCompatSpinner", "Cannot set vertical offset for MODE_DIALOG, ignoring");
        }

        @Override // p037.p041.p051.C1628.InterfaceC1638
        /* JADX INFO: renamed from: ֏, reason: contains not printable characters */
        public void mo3179(int i, int i2) {
            if (this.f5294 == null) {
                return;
            }
            DialogInterfaceC1489.C1490 c1490 = new DialogInterfaceC1489.C1490(C1628.this.getPopupContext());
            CharSequence charSequence = this.f5295;
            if (charSequence != null) {
                c1490.f4672.f173 = charSequence;
            }
            ListAdapter listAdapter = this.f5294;
            int selectedItemPosition = C1628.this.getSelectedItemPosition();
            AlertController.C0030 c0030 = c1490.f4672;
            c0030.f185 = listAdapter;
            c0030.f186 = this;
            c0030.f193 = selectedItemPosition;
            c0030.f192 = true;
            DialogInterfaceC1489 dialogInterfaceC1489M2816 = c1490.m2816();
            this.f5293 = dialogInterfaceC1489M2816;
            ListView listView = dialogInterfaceC1489M2816.f4671.f126;
            listView.setTextDirection(i);
            listView.setTextAlignment(i2);
            this.f5293.show();
        }

        @Override // p037.p041.p051.C1628.InterfaceC1638
        /* JADX INFO: renamed from: ֏, reason: contains not printable characters */
        public void mo3180(Drawable drawable) {
            Log.e("AppCompatSpinner", "Cannot set popup background for MODE_DIALOG, ignoring");
        }

        @Override // p037.p041.p051.C1628.InterfaceC1638
        /* JADX INFO: renamed from: ֏, reason: contains not printable characters */
        public void mo3181(ListAdapter listAdapter) {
            this.f5294 = listAdapter;
        }

        @Override // p037.p041.p051.C1628.InterfaceC1638
        /* JADX INFO: renamed from: ֏, reason: contains not printable characters */
        public void mo3182(CharSequence charSequence) {
            this.f5295 = charSequence;
        }

        @Override // p037.p041.p051.C1628.InterfaceC1638
        /* JADX INFO: renamed from: ֏, reason: contains not printable characters */
        public boolean mo3183() {
            DialogInterfaceC1489 dialogInterfaceC1489 = this.f5293;
            if (dialogInterfaceC1489 != null) {
                return dialogInterfaceC1489.isShowing();
            }
            return false;
        }

        @Override // p037.p041.p051.C1628.InterfaceC1638
        /* JADX INFO: renamed from: ؠ, reason: contains not printable characters */
        public int mo3184() {
            return 0;
        }

        @Override // p037.p041.p051.C1628.InterfaceC1638
        /* JADX INFO: renamed from: ؠ, reason: contains not printable characters */
        public void mo3185(int i) {
            Log.e("AppCompatSpinner", "Cannot set horizontal (original) offset for MODE_DIALOG, ignoring");
        }

        @Override // p037.p041.p051.C1628.InterfaceC1638
        /* JADX INFO: renamed from: ހ, reason: contains not printable characters */
        public void mo3186(int i) {
            Log.e("AppCompatSpinner", "Cannot set horizontal offset for MODE_DIALOG, ignoring");
        }

        @Override // p037.p041.p051.C1628.InterfaceC1638
        /* JADX INFO: renamed from: ށ, reason: contains not printable characters */
        public Drawable mo3187() {
            return null;
        }

        @Override // p037.p041.p051.C1628.InterfaceC1638
        /* JADX INFO: renamed from: ރ, reason: contains not printable characters */
        public int mo3188() {
            return 0;
        }

        @Override // p037.p041.p051.C1628.InterfaceC1638
        /* JADX INFO: renamed from: ބ, reason: contains not printable characters */
        public CharSequence mo3189() {
            return this.f5295;
        }
    }

    /* JADX INFO: renamed from: މ.ؠ.ގ.ޓ$ހ, reason: contains not printable characters */
    public static class C1631 implements ListAdapter, SpinnerAdapter {

        /* JADX INFO: renamed from: ރ, reason: contains not printable characters */
        public SpinnerAdapter f5297;

        /* JADX INFO: renamed from: ބ, reason: contains not printable characters */
        public ListAdapter f5298;

        public C1631(SpinnerAdapter spinnerAdapter, Resources.Theme theme) {
            this.f5297 = spinnerAdapter;
            if (spinnerAdapter instanceof ListAdapter) {
                this.f5298 = (ListAdapter) spinnerAdapter;
            }
            if (theme != null) {
                if (Build.VERSION.SDK_INT >= 23 && (spinnerAdapter instanceof ThemedSpinnerAdapter)) {
                    ThemedSpinnerAdapter themedSpinnerAdapter = (ThemedSpinnerAdapter) spinnerAdapter;
                    if (themedSpinnerAdapter.getDropDownViewTheme() != theme) {
                        themedSpinnerAdapter.setDropDownViewTheme(theme);
                        return;
                    }
                    return;
                }
                if (spinnerAdapter instanceof InterfaceC1685) {
                    InterfaceC1685 interfaceC1685 = (InterfaceC1685) spinnerAdapter;
                    if (interfaceC1685.getDropDownViewTheme() == null) {
                        interfaceC1685.setDropDownViewTheme(theme);
                    }
                }
            }
        }

        @Override // android.widget.ListAdapter
        public boolean areAllItemsEnabled() {
            ListAdapter listAdapter = this.f5298;
            if (listAdapter != null) {
                return listAdapter.areAllItemsEnabled();
            }
            return true;
        }

        @Override // android.widget.Adapter
        public int getCount() {
            SpinnerAdapter spinnerAdapter = this.f5297;
            if (spinnerAdapter == null) {
                return 0;
            }
            return spinnerAdapter.getCount();
        }

        @Override // android.widget.SpinnerAdapter
        public View getDropDownView(int i, View view, ViewGroup viewGroup) {
            SpinnerAdapter spinnerAdapter = this.f5297;
            if (spinnerAdapter == null) {
                return null;
            }
            return spinnerAdapter.getDropDownView(i, view, viewGroup);
        }

        @Override // android.widget.Adapter
        public Object getItem(int i) {
            SpinnerAdapter spinnerAdapter = this.f5297;
            if (spinnerAdapter == null) {
                return null;
            }
            return spinnerAdapter.getItem(i);
        }

        @Override // android.widget.Adapter
        public long getItemId(int i) {
            SpinnerAdapter spinnerAdapter = this.f5297;
            if (spinnerAdapter == null) {
                return -1L;
            }
            return spinnerAdapter.getItemId(i);
        }

        @Override // android.widget.Adapter
        public int getItemViewType(int i) {
            return 0;
        }

        @Override // android.widget.Adapter
        public View getView(int i, View view, ViewGroup viewGroup) {
            SpinnerAdapter spinnerAdapter = this.f5297;
            if (spinnerAdapter == null) {
                return null;
            }
            return spinnerAdapter.getDropDownView(i, view, viewGroup);
        }

        @Override // android.widget.Adapter
        public int getViewTypeCount() {
            return 1;
        }

        @Override // android.widget.Adapter
        public boolean hasStableIds() {
            SpinnerAdapter spinnerAdapter = this.f5297;
            return spinnerAdapter != null && spinnerAdapter.hasStableIds();
        }

        @Override // android.widget.Adapter
        public boolean isEmpty() {
            return getCount() == 0;
        }

        @Override // android.widget.ListAdapter
        public boolean isEnabled(int i) {
            ListAdapter listAdapter = this.f5298;
            if (listAdapter != null) {
                return listAdapter.isEnabled(i);
            }
            return true;
        }

        @Override // android.widget.Adapter
        public void registerDataSetObserver(DataSetObserver dataSetObserver) {
            SpinnerAdapter spinnerAdapter = this.f5297;
            if (spinnerAdapter != null) {
                spinnerAdapter.registerDataSetObserver(dataSetObserver);
            }
        }

        @Override // android.widget.Adapter
        public void unregisterDataSetObserver(DataSetObserver dataSetObserver) {
            SpinnerAdapter spinnerAdapter = this.f5297;
            if (spinnerAdapter != null) {
                spinnerAdapter.unregisterDataSetObserver(dataSetObserver);
            }
        }
    }

    /* JADX INFO: renamed from: މ.ؠ.ގ.ޓ$ށ, reason: contains not printable characters */
    public class C1632 extends C1661 implements InterfaceC1638 {

        /* JADX INFO: renamed from: ޢ, reason: contains not printable characters */
        public CharSequence f5299;

        /* JADX INFO: renamed from: ޣ, reason: contains not printable characters */
        public ListAdapter f5300;

        /* JADX INFO: renamed from: ޤ, reason: contains not printable characters */
        public final Rect f5301;

        /* JADX INFO: renamed from: ޥ, reason: contains not printable characters */
        public int f5302;

        /* JADX INFO: renamed from: މ.ؠ.ގ.ޓ$ށ$֏, reason: contains not printable characters */
        public class C1633 implements AdapterView.OnItemClickListener {
            public C1633(C1628 c1628) {
            }

            @Override // android.widget.AdapterView.OnItemClickListener
            public void onItemClick(AdapterView<?> adapterView, View view, int i, long j) {
                C1628.this.setSelection(i);
                if (C1628.this.getOnItemClickListener() != null) {
                    C1632 c1632 = C1632.this;
                    C1628.this.performItemClick(view, i, c1632.f5300.getItemId(i));
                }
                C1632.this.dismiss();
            }
        }

        /* JADX INFO: renamed from: މ.ؠ.ގ.ޓ$ށ$ؠ, reason: contains not printable characters */
        public class ViewTreeObserverOnGlobalLayoutListenerC1634 implements ViewTreeObserver.OnGlobalLayoutListener {
            public ViewTreeObserverOnGlobalLayoutListenerC1634() {
            }

            @Override // android.view.ViewTreeObserver.OnGlobalLayoutListener
            public void onGlobalLayout() {
                C1632 c1632 = C1632.this;
                C1628 c1628 = C1628.this;
                if (c1632 == null) {
                    throw null;
                }
                if (!(C1920.m3769(c1628) && c1628.getGlobalVisibleRect(c1632.f5301))) {
                    C1632.this.dismiss();
                } else {
                    C1632.this.m3191();
                    C1632.super.mo3073();
                }
            }
        }

        /* JADX INFO: renamed from: މ.ؠ.ގ.ޓ$ށ$ހ, reason: contains not printable characters */
        public class C1635 implements PopupWindow.OnDismissListener {

            /* JADX INFO: renamed from: ރ, reason: contains not printable characters */
            public final /* synthetic */ ViewTreeObserver.OnGlobalLayoutListener f5306;

            public C1635(ViewTreeObserver.OnGlobalLayoutListener onGlobalLayoutListener) {
                this.f5306 = onGlobalLayoutListener;
            }

            @Override // android.widget.PopupWindow.OnDismissListener
            public void onDismiss() {
                ViewTreeObserver viewTreeObserver = C1628.this.getViewTreeObserver();
                if (viewTreeObserver != null) {
                    viewTreeObserver.removeGlobalOnLayoutListener(this.f5306);
                }
            }
        }

        public C1632(Context context, AttributeSet attributeSet, int i) {
            super(context, attributeSet, i, 0);
            this.f5301 = new Rect();
            this.f5416 = C1628.this;
            m3254(true);
            this.f5414 = 0;
            this.f5417 = new C1633(C1628.this);
        }

        @Override // p037.p041.p051.C1628.InterfaceC1638
        /* JADX INFO: renamed from: ֏ */
        public void mo3179(int i, int i2) {
            ViewTreeObserver viewTreeObserver;
            boolean zMo3070 = mo3070();
            m3191();
            this.f5426.setInputMethodMode(2);
            super.mo3073();
            C1651 c1651 = this.f5401;
            c1651.setChoiceMode(1);
            c1651.setTextDirection(i);
            c1651.setTextAlignment(i2);
            int selectedItemPosition = C1628.this.getSelectedItemPosition();
            C1651 c16512 = this.f5401;
            if (mo3070() && c16512 != null) {
                c16512.setListSelectionHidden(false);
                c16512.setSelection(selectedItemPosition);
                if (c16512.getChoiceMode() != 0) {
                    c16512.setItemChecked(selectedItemPosition, true);
                }
            }
            if (zMo3070 || (viewTreeObserver = C1628.this.getViewTreeObserver()) == null) {
                return;
            }
            ViewTreeObserverOnGlobalLayoutListenerC1634 viewTreeObserverOnGlobalLayoutListenerC1634 = new ViewTreeObserverOnGlobalLayoutListenerC1634();
            viewTreeObserver.addOnGlobalLayoutListener(viewTreeObserverOnGlobalLayoutListenerC1634);
            this.f5426.setOnDismissListener(new C1635(viewTreeObserverOnGlobalLayoutListenerC1634));
        }

        @Override // p037.p041.p051.C1661, p037.p041.p051.C1628.InterfaceC1638
        /* JADX INFO: renamed from: ֏ */
        public void mo3181(ListAdapter listAdapter) {
            super.mo3181(listAdapter);
            this.f5300 = listAdapter;
        }

        @Override // p037.p041.p051.C1628.InterfaceC1638
        /* JADX INFO: renamed from: ֏ */
        public void mo3182(CharSequence charSequence) {
            this.f5299 = charSequence;
        }

        @Override // p037.p041.p051.C1628.InterfaceC1638
        /* JADX INFO: renamed from: ؠ */
        public void mo3185(int i) {
            this.f5302 = i;
        }

        @Override // p037.p041.p051.C1628.InterfaceC1638
        /* JADX INFO: renamed from: ބ */
        public CharSequence mo3189() {
            return this.f5299;
        }

        /* JADX INFO: renamed from: ޅ, reason: contains not printable characters */
        public void m3191() {
            Drawable drawableM3257 = m3257();
            int i = 0;
            if (drawableM3257 != null) {
                drawableM3257.getPadding(C1628.this.f5291);
                i = C1698.m3318(C1628.this) ? C1628.this.f5291.right : -C1628.this.f5291.left;
            } else {
                Rect rect = C1628.this.f5291;
                rect.right = 0;
                rect.left = 0;
            }
            int paddingLeft = C1628.this.getPaddingLeft();
            int paddingRight = C1628.this.getPaddingRight();
            int width = C1628.this.getWidth();
            C1628 c1628 = C1628.this;
            int i2 = c1628.f5290;
            if (i2 == -2) {
                int iM3176 = c1628.m3176((SpinnerAdapter) this.f5300, m3257());
                int i3 = C1628.this.getContext().getResources().getDisplayMetrics().widthPixels;
                Rect rect2 = C1628.this.f5291;
                int i4 = (i3 - rect2.left) - rect2.right;
                if (iM3176 > i4) {
                    iM3176 = i4;
                }
                m3258(Math.max(iM3176, (width - paddingLeft) - paddingRight));
            } else if (i2 == -1) {
                m3258((width - paddingLeft) - paddingRight);
            } else {
                m3258(i2);
            }
            this.f5404 = C1698.m3318(C1628.this) ? (((width - paddingRight) - this.f5403) - this.f5302) + i : paddingLeft + this.f5302 + i;
        }
    }

    /* JADX INFO: renamed from: މ.ؠ.ގ.ޓ$ނ, reason: contains not printable characters */
    public static class C1636 extends View.BaseSavedState {
        public static final Parcelable.Creator<C1636> CREATOR = new C1637();

        /* JADX INFO: renamed from: ރ, reason: contains not printable characters */
        public boolean f5308;

        /* JADX INFO: renamed from: މ.ؠ.ގ.ޓ$ނ$֏, reason: contains not printable characters */
        public class C1637 implements Parcelable.Creator<C1636> {
            @Override // android.os.Parcelable.Creator
            public C1636 createFromParcel(Parcel parcel) {
                return new C1636(parcel);
            }

            @Override // android.os.Parcelable.Creator
            public C1636[] newArray(int i) {
                return new C1636[i];
            }
        }

        public C1636(Parcel parcel) {
            super(parcel);
            this.f5308 = parcel.readByte() != 0;
        }

        public C1636(Parcelable parcelable) {
            super(parcelable);
        }

        @Override // android.view.View.BaseSavedState, android.view.AbsSavedState, android.os.Parcelable
        public void writeToParcel(Parcel parcel, int i) {
            super.writeToParcel(parcel, i);
            parcel.writeByte(this.f5308 ? (byte) 1 : (byte) 0);
        }
    }

    /* JADX INFO: renamed from: މ.ؠ.ގ.ޓ$ރ, reason: contains not printable characters */
    public interface InterfaceC1638 {
        void dismiss();

        /* JADX INFO: renamed from: ֏ */
        void mo3178(int i);

        /* JADX INFO: renamed from: ֏ */
        void mo3179(int i, int i2);

        /* JADX INFO: renamed from: ֏ */
        void mo3180(Drawable drawable);

        /* JADX INFO: renamed from: ֏ */
        void mo3181(ListAdapter listAdapter);

        /* JADX INFO: renamed from: ֏ */
        void mo3182(CharSequence charSequence);

        /* JADX INFO: renamed from: ֏ */
        boolean mo3183();

        /* JADX INFO: renamed from: ؠ */
        int mo3184();

        /* JADX INFO: renamed from: ؠ */
        void mo3185(int i);

        /* JADX INFO: renamed from: ހ */
        void mo3186(int i);

        /* JADX INFO: renamed from: ށ */
        Drawable mo3187();

        /* JADX INFO: renamed from: ރ */
        int mo3188();

        /* JADX INFO: renamed from: ބ */
        CharSequence mo3189();
    }

    /* JADX WARN: Removed duplicated region for block: B:25:0x005f  */
    /* JADX WARN: Removed duplicated region for block: B:28:0x009c  */
    /* JADX WARN: Removed duplicated region for block: B:31:0x00b4  */
    /* JADX WARN: Removed duplicated region for block: B:34:0x00cd  */
    /* JADX WARN: Removed duplicated region for block: B:38:0x00da  */
    /*
        Code decompiled incorrectly, please refer to instructions dump.
    */
    public C1628(Context context, AttributeSet attributeSet, int i) throws Throwable {
        Exception e;
        TypedArray typedArrayObtainStyledAttributes;
        CharSequence[] textArray;
        SpinnerAdapter spinnerAdapter;
        super(context, attributeSet, i);
        this.f5291 = new Rect();
        C1684.m3289(this, getContext());
        TypedArray typedArrayObtainStyledAttributes2 = context.obtainStyledAttributes(attributeSet, C1477.Spinner, i, 0);
        this.f5284 = new C1610(this);
        int resourceId = typedArrayObtainStyledAttributes2.getResourceId(C1477.Spinner_popupTheme, 0);
        if (resourceId != 0) {
            this.f5285 = new C1550(context, resourceId);
        } else {
            this.f5285 = context;
        }
        TypedArray typedArray = null;
        int i2 = -1;
        try {
            try {
                typedArrayObtainStyledAttributes = context.obtainStyledAttributes(attributeSet, f5283, i, 0);
                try {
                    if (typedArrayObtainStyledAttributes.hasValue(0)) {
                        i2 = typedArrayObtainStyledAttributes.getInt(0, 0);
                    }
                } catch (Exception e2) {
                    e = e2;
                    Log.i("AppCompatSpinner", "Could not read android:spinnerMode", e);
                    if (typedArrayObtainStyledAttributes != null) {
                    }
                    if (i2 != 0) {
                    }
                    textArray = typedArrayObtainStyledAttributes2.getTextArray(C1477.Spinner_android_entries);
                    if (textArray != null) {
                    }
                    typedArrayObtainStyledAttributes2.recycle();
                    this.f5288 = true;
                    spinnerAdapter = this.f5287;
                    if (spinnerAdapter != null) {
                    }
                    this.f5284.m3148(attributeSet, i);
                }
            } catch (Throwable th) {
                th = th;
                typedArray = typedArrayObtainStyledAttributes;
                if (typedArray != null) {
                    typedArray.recycle();
                }
                throw th;
            }
        } catch (Exception e3) {
            e = e3;
            typedArrayObtainStyledAttributes = null;
        } catch (Throwable th2) {
            th = th2;
            if (typedArray != null) {
            }
            throw th;
        }
        typedArrayObtainStyledAttributes.recycle();
        if (i2 != 0) {
            DialogInterfaceOnClickListenerC1630 dialogInterfaceOnClickListenerC1630 = new DialogInterfaceOnClickListenerC1630();
            this.f5289 = dialogInterfaceOnClickListenerC1630;
            dialogInterfaceOnClickListenerC1630.mo3182(typedArrayObtainStyledAttributes2.getString(C1477.Spinner_android_prompt));
        } else if (i2 == 1) {
            C1632 c1632 = new C1632(this.f5285, attributeSet, i);
            C1689 c1689M3294 = C1689.m3294(this.f5285, attributeSet, C1477.Spinner, i, 0);
            this.f5290 = c1689M3294.m3303(C1477.Spinner_android_dropDownWidth, -2);
            c1632.f5426.setBackgroundDrawable(c1689M3294.m3300(C1477.Spinner_android_popupBackground));
            c1632.f5299 = typedArrayObtainStyledAttributes2.getString(C1477.Spinner_android_prompt);
            c1689M3294.f5496.recycle();
            this.f5289 = c1632;
            this.f5286 = new C1627(this, this, c1632);
        }
        textArray = typedArrayObtainStyledAttributes2.getTextArray(C1477.Spinner_android_entries);
        if (textArray != null) {
            ArrayAdapter arrayAdapter = new ArrayAdapter(context, R.layout.simple_spinner_item, textArray);
            arrayAdapter.setDropDownViewResource(C1474.support_simple_spinner_dropdown_item);
            setAdapter((SpinnerAdapter) arrayAdapter);
        }
        typedArrayObtainStyledAttributes2.recycle();
        this.f5288 = true;
        spinnerAdapter = this.f5287;
        if (spinnerAdapter != null) {
            setAdapter(spinnerAdapter);
            this.f5287 = null;
        }
        this.f5284.m3148(attributeSet, i);
    }

    @Override // android.view.ViewGroup, android.view.View
    public void drawableStateChanged() {
        super.drawableStateChanged();
        C1610 c1610 = this.f5284;
        if (c1610 != null) {
            c1610.m3144();
        }
    }

    @Override // android.widget.Spinner
    public int getDropDownHorizontalOffset() {
        InterfaceC1638 interfaceC1638 = this.f5289;
        return interfaceC1638 != null ? interfaceC1638.mo3184() : super.getDropDownHorizontalOffset();
    }

    @Override // android.widget.Spinner
    public int getDropDownVerticalOffset() {
        InterfaceC1638 interfaceC1638 = this.f5289;
        return interfaceC1638 != null ? interfaceC1638.mo3188() : super.getDropDownVerticalOffset();
    }

    @Override // android.widget.Spinner
    public int getDropDownWidth() {
        return this.f5289 != null ? this.f5290 : super.getDropDownWidth();
    }

    public final InterfaceC1638 getInternalPopup() {
        return this.f5289;
    }

    @Override // android.widget.Spinner
    public Drawable getPopupBackground() {
        InterfaceC1638 interfaceC1638 = this.f5289;
        return interfaceC1638 != null ? interfaceC1638.mo3187() : super.getPopupBackground();
    }

    @Override // android.widget.Spinner
    public Context getPopupContext() {
        return this.f5285;
    }

    @Override // android.widget.Spinner
    public CharSequence getPrompt() {
        InterfaceC1638 interfaceC1638 = this.f5289;
        return interfaceC1638 != null ? interfaceC1638.mo3189() : super.getPrompt();
    }

    public ColorStateList getSupportBackgroundTintList() {
        C1610 c1610 = this.f5284;
        if (c1610 != null) {
            return c1610.m3149();
        }
        return null;
    }

    public PorterDuff.Mode getSupportBackgroundTintMode() {
        C1610 c1610 = this.f5284;
        if (c1610 != null) {
            return c1610.m3151();
        }
        return null;
    }

    @Override // android.widget.Spinner, android.widget.AdapterView, android.view.ViewGroup, android.view.View
    public void onDetachedFromWindow() {
        super.onDetachedFromWindow();
        InterfaceC1638 interfaceC1638 = this.f5289;
        if (interfaceC1638 == null || !interfaceC1638.mo3183()) {
            return;
        }
        this.f5289.dismiss();
    }

    @Override // android.widget.Spinner, android.widget.AbsSpinner, android.view.View
    public void onMeasure(int i, int i2) {
        super.onMeasure(i, i2);
        if (this.f5289 == null || View.MeasureSpec.getMode(i) != Integer.MIN_VALUE) {
            return;
        }
        setMeasuredDimension(Math.min(Math.max(getMeasuredWidth(), m3176(getAdapter(), getBackground())), View.MeasureSpec.getSize(i)), getMeasuredHeight());
    }

    @Override // android.widget.Spinner, android.widget.AbsSpinner, android.view.View
    public void onRestoreInstanceState(Parcelable parcelable) {
        ViewTreeObserver viewTreeObserver;
        C1636 c1636 = (C1636) parcelable;
        super.onRestoreInstanceState(c1636.getSuperState());
        if (!c1636.f5308 || (viewTreeObserver = getViewTreeObserver()) == null) {
            return;
        }
        viewTreeObserver.addOnGlobalLayoutListener(new ViewTreeObserverOnGlobalLayoutListenerC1629());
    }

    @Override // android.widget.Spinner, android.widget.AbsSpinner, android.view.View
    public Parcelable onSaveInstanceState() {
        C1636 c1636 = new C1636(super.onSaveInstanceState());
        InterfaceC1638 interfaceC1638 = this.f5289;
        c1636.f5308 = interfaceC1638 != null && interfaceC1638.mo3183();
        return c1636;
    }

    @Override // android.widget.Spinner, android.view.View
    public boolean onTouchEvent(MotionEvent motionEvent) {
        AbstractViewOnTouchListenerC1655 abstractViewOnTouchListenerC1655 = this.f5286;
        if (abstractViewOnTouchListenerC1655 == null || !abstractViewOnTouchListenerC1655.onTouch(this, motionEvent)) {
            return super.onTouchEvent(motionEvent);
        }
        return true;
    }

    @Override // android.widget.Spinner, android.view.View
    public boolean performClick() {
        InterfaceC1638 interfaceC1638 = this.f5289;
        if (interfaceC1638 == null) {
            return super.performClick();
        }
        if (interfaceC1638.mo3183()) {
            return true;
        }
        m3177();
        return true;
    }

    @Override // android.widget.AdapterView
    public void setAdapter(SpinnerAdapter spinnerAdapter) {
        if (!this.f5288) {
            this.f5287 = spinnerAdapter;
            return;
        }
        super.setAdapter(spinnerAdapter);
        if (this.f5289 != null) {
            Context context = this.f5285;
            if (context == null) {
                context = getContext();
            }
            this.f5289.mo3181(new C1631(spinnerAdapter, context.getTheme()));
        }
    }

    @Override // android.view.View
    public void setBackgroundDrawable(Drawable drawable) {
        super.setBackgroundDrawable(drawable);
        C1610 c1610 = this.f5284;
        if (c1610 != null) {
            c1610.m3152();
        }
    }

    @Override // android.view.View
    public void setBackgroundResource(int i) {
        super.setBackgroundResource(i);
        C1610 c1610 = this.f5284;
        if (c1610 != null) {
            c1610.m3145(i);
        }
    }

    @Override // android.widget.Spinner
    public void setDropDownHorizontalOffset(int i) {
        InterfaceC1638 interfaceC1638 = this.f5289;
        if (interfaceC1638 == null) {
            super.setDropDownHorizontalOffset(i);
        } else {
            interfaceC1638.mo3185(i);
            this.f5289.mo3186(i);
        }
    }

    @Override // android.widget.Spinner
    public void setDropDownVerticalOffset(int i) {
        InterfaceC1638 interfaceC1638 = this.f5289;
        if (interfaceC1638 != null) {
            interfaceC1638.mo3178(i);
        } else {
            super.setDropDownVerticalOffset(i);
        }
    }

    @Override // android.widget.Spinner
    public void setDropDownWidth(int i) {
        if (this.f5289 != null) {
            this.f5290 = i;
        } else {
            super.setDropDownWidth(i);
        }
    }

    @Override // android.widget.Spinner
    public void setPopupBackgroundDrawable(Drawable drawable) {
        InterfaceC1638 interfaceC1638 = this.f5289;
        if (interfaceC1638 != null) {
            interfaceC1638.mo3180(drawable);
        } else {
            super.setPopupBackgroundDrawable(drawable);
        }
    }

    @Override // android.widget.Spinner
    public void setPopupBackgroundResource(int i) {
        setPopupBackgroundDrawable(C1527.m3025(getPopupContext(), i));
    }

    @Override // android.widget.Spinner
    public void setPrompt(CharSequence charSequence) {
        InterfaceC1638 interfaceC1638 = this.f5289;
        if (interfaceC1638 != null) {
            interfaceC1638.mo3182(charSequence);
        } else {
            super.setPrompt(charSequence);
        }
    }

    public void setSupportBackgroundTintList(ColorStateList colorStateList) {
        C1610 c1610 = this.f5284;
        if (c1610 != null) {
            c1610.m3150(colorStateList);
        }
    }

    public void setSupportBackgroundTintMode(PorterDuff.Mode mode) {
        C1610 c1610 = this.f5284;
        if (c1610 != null) {
            c1610.m3147(mode);
        }
    }

    /* JADX INFO: renamed from: ֏, reason: contains not printable characters */
    public int m3176(SpinnerAdapter spinnerAdapter, Drawable drawable) {
        int i = 0;
        if (spinnerAdapter == null) {
            return 0;
        }
        int iMakeMeasureSpec = View.MeasureSpec.makeMeasureSpec(getMeasuredWidth(), 0);
        int iMakeMeasureSpec2 = View.MeasureSpec.makeMeasureSpec(getMeasuredHeight(), 0);
        int iMax = Math.max(0, getSelectedItemPosition());
        int iMin = Math.min(spinnerAdapter.getCount(), iMax + 15);
        View view = null;
        int iMax2 = 0;
        for (int iMax3 = Math.max(0, iMax - (15 - (iMin - iMax))); iMax3 < iMin; iMax3++) {
            int itemViewType = spinnerAdapter.getItemViewType(iMax3);
            if (itemViewType != i) {
                view = null;
                i = itemViewType;
            }
            view = spinnerAdapter.getView(iMax3, view, this);
            if (view.getLayoutParams() == null) {
                view.setLayoutParams(new ViewGroup.LayoutParams(-2, -2));
            }
            view.measure(iMakeMeasureSpec, iMakeMeasureSpec2);
            iMax2 = Math.max(iMax2, view.getMeasuredWidth());
        }
        if (drawable == null) {
            return iMax2;
        }
        drawable.getPadding(this.f5291);
        Rect rect = this.f5291;
        return iMax2 + rect.left + rect.right;
    }

    /* JADX INFO: renamed from: ֏, reason: contains not printable characters */
    public void m3177() {
        this.f5289.mo3179(getTextDirection(), getTextAlignment());
    }
}
