package o;

import android.R;
import android.content.Context;
import android.content.res.ColorStateList;
import android.graphics.drawable.ColorDrawable;
import android.graphics.drawable.Drawable;
import android.graphics.drawable.RippleDrawable;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;
import android.widget.TextView;
import java.util.WeakHashMap;

/* compiled from: r8-map-id-3b7cc9102578c509342fa2f0fabed2bfc72239cd258d579fc679bfcbc198b048 */
/* loaded from: classes.dex */
public final class JN extends ArrayAdapter {
    public ColorStateList a;
    public ColorStateList b;
    public final /* synthetic */ KN c;

    /* JADX WARN: 'super' call moved to the top of the method (can break code semantics) */
    public JN(KN kn, Context context, int i, String[] strArr) {
        super(context, i, strArr);
        this.c = kn;
        a();
    }

    public final void a() {
        ColorStateList colorStateList;
        KN kn = this.c;
        ColorStateList colorStateList2 = kn.w;
        ColorStateList colorStateList3 = null;
        if (colorStateList2 != null) {
            int[] iArr = {R.attr.state_pressed};
            colorStateList = new ColorStateList(new int[][]{iArr, new int[0]}, new int[]{colorStateList2.getColorForState(iArr, 0), 0});
        } else {
            colorStateList = null;
        }
        this.b = colorStateList;
        if (kn.v != 0 && kn.w != null) {
            int[] iArr2 = {R.attr.state_hovered, -16842919};
            int[] iArr3 = {R.attr.state_selected, -16842919};
            colorStateList3 = new ColorStateList(new int[][]{iArr3, iArr2, new int[0]}, new int[]{AbstractC0501Ti.b(kn.w.getColorForState(iArr3, 0), kn.v), AbstractC0501Ti.b(kn.w.getColorForState(iArr2, 0), kn.v), kn.v});
        }
        this.a = colorStateList3;
    }

    @Override // android.widget.ArrayAdapter, android.widget.Adapter
    public final View getView(int i, View view, ViewGroup viewGroup) {
        View view2 = super.getView(i, view, viewGroup);
        if (view2 instanceof TextView) {
            TextView textView = (TextView) view2;
            KN kn = this.c;
            Drawable rippleDrawable = null;
            if (kn.getText().toString().contentEquals(textView.getText()) && kn.v != 0) {
                ColorDrawable colorDrawable = new ColorDrawable(kn.v);
                if (this.b != null) {
                    colorDrawable.setTintList(this.a);
                    rippleDrawable = new RippleDrawable(this.b, colorDrawable, null);
                } else {
                    rippleDrawable = colorDrawable;
                }
            }
            WeakHashMap weakHashMap = Oj0.a;
            textView.setBackground(rippleDrawable);
        }
        return view2;
    }
}
