package androidx.preference;

import android.R;
import android.content.Context;
import android.util.AttributeSet;
import android.view.View;
import android.widget.AdapterView;
import android.widget.ArrayAdapter;
import android.widget.Spinner;
import android.widget.SpinnerAdapter;
import p037.p106.C2293;
import p037.p106.C2294;
import p037.p106.C2296;

/* JADX INFO: loaded from: classes.dex */
public class DropDownPreference extends ListPreference {

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

    /* JADX INFO: renamed from: ໞ, reason: contains not printable characters */
    public final ArrayAdapter f988;

    /* JADX INFO: renamed from: ໟ, reason: contains not printable characters */
    public Spinner f989;

    /* JADX INFO: renamed from: ྈ, reason: contains not printable characters */
    public final AdapterView.OnItemSelectedListener f990;

    /* JADX INFO: renamed from: androidx.preference.DropDownPreference$֏, reason: contains not printable characters */
    public class C0150 implements AdapterView.OnItemSelectedListener {
        public C0150() {
        }

        @Override // android.widget.AdapterView.OnItemSelectedListener
        public void onItemSelected(AdapterView<?> adapterView, View view, int i, long j) {
            if (i >= 0) {
                String string = DropDownPreference.this.f996[i].toString();
                if (string.equals(DropDownPreference.this.f997)) {
                    return;
                }
                DropDownPreference dropDownPreference = DropDownPreference.this;
                if (dropDownPreference == null) {
                    throw null;
                }
                dropDownPreference.m374(string);
            }
        }

        @Override // android.widget.AdapterView.OnItemSelectedListener
        public void onNothingSelected(AdapterView<?> adapterView) {
        }
    }

    /* JADX WARN: 'super' call moved to the top of the method (can break code semantics) */
    public DropDownPreference(Context context, AttributeSet attributeSet) {
        super(context, attributeSet, C2294.dropdownPreferenceStyle, 0);
        this.f990 = new C0150();
        this.f987 = context;
        ArrayAdapter arrayAdapter = new ArrayAdapter(this.f987, R.layout.simple_spinner_dropdown_item);
        this.f988 = arrayAdapter;
        arrayAdapter.clear();
        CharSequence[] charSequenceArr = this.f995;
        if (charSequenceArr != null) {
            for (CharSequence charSequence : charSequenceArr) {
                this.f988.add(charSequence.toString());
            }
        }
    }

    @Override // androidx.preference.Preference
    /* JADX INFO: renamed from: ֏ */
    public void mo360(C2293 c2293) {
        Spinner spinner = (Spinner) c2293.f1326.findViewById(C2296.spinner);
        this.f989 = spinner;
        spinner.setAdapter((SpinnerAdapter) this.f988);
        this.f989.setOnItemSelectedListener(this.f990);
        Spinner spinner2 = this.f989;
        String str = this.f997;
        CharSequence[] charSequenceArr = this.f996;
        int i = -1;
        if (str != null && charSequenceArr != null) {
            int length = charSequenceArr.length - 1;
            while (true) {
                if (length < 0) {
                    break;
                }
                if (charSequenceArr[length].equals(str)) {
                    i = length;
                    break;
                }
                length--;
            }
        }
        spinner2.setSelection(i);
        super.mo360(c2293);
    }

    @Override // androidx.preference.Preference
    /* JADX INFO: renamed from: ތ, reason: contains not printable characters */
    public void mo364() {
        super.mo364();
        ArrayAdapter arrayAdapter = this.f988;
        if (arrayAdapter != null) {
            arrayAdapter.notifyDataSetChanged();
        }
    }

    @Override // androidx.preference.DialogPreference, androidx.preference.Preference
    /* JADX INFO: renamed from: ޏ */
    public void mo362() {
        this.f989.performClick();
    }
}
