package e;

import android.R;
import android.content.Context;
import android.content.DialogInterface;
import android.graphics.drawable.Drawable;
import android.view.ContextThemeWrapper;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.ListAdapter;
import android.widget.TextView;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.annotation.StringRes;
import androidx.annotation.StyleRes;
import androidx.appcompat.app.AlertController$RecycleListView;

/* JADX INFO: loaded from: classes.dex */
public class l {

    /* JADX INFO: renamed from: a, reason: collision with root package name */
    public final h f25255a;

    /* JADX INFO: renamed from: b, reason: collision with root package name */
    public final int f25256b;

    public l(Context context) {
        this(context, m.f(context, 0));
    }

    @NonNull
    public m create() {
        h hVar = this.f25255a;
        m mVar = new m(hVar.f25201a, this.f25256b);
        View view = hVar.f25205e;
        int i10 = 0;
        k kVar = mVar.f25273f;
        if (view != null) {
            kVar.C = view;
        } else {
            CharSequence charSequence = hVar.f25204d;
            if (charSequence != null) {
                kVar.f25232e = charSequence;
                TextView textView = kVar.A;
                if (textView != null) {
                    textView.setText(charSequence);
                }
            }
            Drawable drawable = hVar.f25203c;
            if (drawable != null) {
                kVar.f25252y = drawable;
                kVar.f25251x = 0;
                ImageView imageView = kVar.f25253z;
                if (imageView != null) {
                    imageView.setVisibility(0);
                    kVar.f25253z.setImageDrawable(drawable);
                }
            }
        }
        CharSequence charSequence2 = hVar.f25206f;
        if (charSequence2 != null) {
            kVar.f25233f = charSequence2;
            TextView textView2 = kVar.B;
            if (textView2 != null) {
                textView2.setText(charSequence2);
            }
        }
        CharSequence charSequence3 = hVar.f25207g;
        if (charSequence3 != null) {
            kVar.d(-1, charSequence3, hVar.f25208h);
        }
        CharSequence charSequence4 = hVar.f25209i;
        if (charSequence4 != null) {
            kVar.d(-2, charSequence4, hVar.f25210j);
        }
        if (hVar.f25214n != null) {
            AlertController$RecycleListView alertController$RecycleListView = (AlertController$RecycleListView) hVar.f25202b.inflate(kVar.G, (ViewGroup) null);
            int i11 = hVar.f25217q ? kVar.H : kVar.I;
            ListAdapter jVar = hVar.f25214n;
            if (jVar == null) {
                jVar = new j(hVar.f25201a, i11, R.id.text1, null);
            }
            kVar.D = jVar;
            kVar.E = hVar.f25218r;
            if (hVar.f25215o != null) {
                alertController$RecycleListView.setOnItemClickListener(new g(hVar, kVar, i10));
            }
            if (hVar.f25217q) {
                alertController$RecycleListView.setChoiceMode(1);
            }
            kVar.f25234g = alertController$RecycleListView;
        }
        View view2 = hVar.f25216p;
        if (view2 != null) {
            kVar.f25235h = view2;
            kVar.f25236i = 0;
            kVar.f25237j = false;
        }
        mVar.setCancelable(hVar.f25211k);
        if (hVar.f25211k) {
            mVar.setCanceledOnTouchOutside(true);
        }
        mVar.setOnCancelListener(hVar.f25212l);
        mVar.setOnDismissListener(null);
        DialogInterface.OnKeyListener onKeyListener = hVar.f25213m;
        if (onKeyListener != null) {
            mVar.setOnKeyListener(onKeyListener);
        }
        return mVar;
    }

    @NonNull
    public Context getContext() {
        return this.f25255a.f25201a;
    }

    public l setCustomTitle(@Nullable View view) {
        this.f25255a.f25205e = view;
        return this;
    }

    public l setIcon(@Nullable Drawable drawable) {
        this.f25255a.f25203c = drawable;
        return this;
    }

    public l setMessage(@Nullable CharSequence charSequence) {
        this.f25255a.f25206f = charSequence;
        return this;
    }

    public l setNegativeButton(@StringRes int i10, DialogInterface.OnClickListener onClickListener) {
        h hVar = this.f25255a;
        hVar.f25209i = hVar.f25201a.getText(i10);
        hVar.f25210j = onClickListener;
        return this;
    }

    public l setPositiveButton(@StringRes int i10, DialogInterface.OnClickListener onClickListener) {
        h hVar = this.f25255a;
        hVar.f25207g = hVar.f25201a.getText(i10);
        hVar.f25208h = onClickListener;
        return this;
    }

    public l setTitle(@Nullable CharSequence charSequence) {
        this.f25255a.f25204d = charSequence;
        return this;
    }

    public l setView(View view) {
        this.f25255a.f25216p = view;
        return this;
    }

    public l(@NonNull Context context, @StyleRes int i10) {
        this.f25255a = new h(new ContextThemeWrapper(context, m.f(context, i10)));
        this.f25256b = i10;
    }
}
