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 z4.c;

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

    /* renamed from: d0, reason: collision with root package name */
    private final Context f4983d0;

    /* renamed from: e0, reason: collision with root package name */
    private final ArrayAdapter f4984e0;

    /* renamed from: f0, reason: collision with root package name */
    private Spinner f4985f0;

    /* renamed from: g0, reason: collision with root package name */
    private final AdapterView.OnItemSelectedListener f4986g0;

    /* loaded from: classes.dex */
    class a implements AdapterView.OnItemSelectedListener {
        a() {
        }

        @Override // android.widget.AdapterView.OnItemSelectedListener
        public void onItemSelected(AdapterView adapterView, View view, int i10, long j10) {
            if (i10 >= 0) {
                String charSequence = DropDownPreference.this.V()[i10].toString();
                if (charSequence.equals(DropDownPreference.this.W()) || !DropDownPreference.this.a(charSequence)) {
                    return;
                }
                DropDownPreference.this.Y(charSequence);
            }
        }

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

    public DropDownPreference(Context context, AttributeSet attributeSet) {
        this(context, attributeSet, c.f53156c);
    }

    private void a0() {
        this.f4984e0.clear();
        if (T() != null) {
            for (CharSequence charSequence : T()) {
                this.f4984e0.add(charSequence.toString());
            }
        }
    }

    /* JADX INFO: Access modifiers changed from: protected */
    @Override // androidx.preference.Preference
    public void E() {
        super.E();
        ArrayAdapter arrayAdapter = this.f4984e0;
        if (arrayAdapter != null) {
            arrayAdapter.notifyDataSetChanged();
        }
    }

    /* JADX INFO: Access modifiers changed from: protected */
    @Override // androidx.preference.DialogPreference, androidx.preference.Preference
    public void G() {
        this.f4985f0.performClick();
    }

    protected ArrayAdapter Z() {
        return new ArrayAdapter(this.f4983d0, R.layout.simple_spinner_dropdown_item);
    }

    public DropDownPreference(Context context, AttributeSet attributeSet, int i10) {
        this(context, attributeSet, i10, 0);
    }

    public DropDownPreference(Context context, AttributeSet attributeSet, int i10, int i11) {
        super(context, attributeSet, i10, i11);
        this.f4986g0 = new a();
        this.f4983d0 = context;
        this.f4984e0 = Z();
        a0();
    }
}
