package defpackage;

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.appcompat.app.AlertController$RecycleListView;

/* renamed from: ᵹᵛ, reason: contains not printable characters */
/* loaded from: classes3.dex */
public class C5049 {

    /* renamed from: ᵥᵯˎ, reason: contains not printable characters */
    public final C0591 f18871;

    /* renamed from: ᵴᵳ, reason: contains not printable characters */
    public final int f18872;

    public C5049(Context context) {
        this(context, DialogInterfaceC5504.m11129(context, 0));
    }

    public C5049(Context context, int i) {
        this.f18871 = new C0591(new ContextThemeWrapper(context, DialogInterfaceC5504.m11129(context, i)));
        this.f18872 = i;
    }

    public DialogInterfaceC5504 create() {
        ListAdapter c2435;
        C0591 c0591 = this.f18871;
        ContextThemeWrapper contextThemeWrapper = c0591.f2996;
        ContextThemeWrapper contextThemeWrapper2 = c0591.f2996;
        DialogInterfaceC5504 dialogInterfaceC5504 = new DialogInterfaceC5504(contextThemeWrapper, this.f18872);
        View view = c0591.f2987;
        C2892 c2892 = dialogInterfaceC5504.f20709;
        if (view != null) {
            c2892.f11233 = view;
        } else {
            CharSequence charSequence = c0591.f3006;
            if (charSequence != null) {
                c2892.f11248 = charSequence;
                TextView textView = c2892.f11227;
                if (textView != null) {
                    textView.setText(charSequence);
                }
                c2892.f11225.setTitle(charSequence);
            }
            Drawable drawable = c0591.f2992;
            if (drawable != null) {
                c2892.f11229 = drawable;
                ImageView imageView = c2892.f11238;
                if (imageView != null) {
                    imageView.setVisibility(0);
                    c2892.f11238.setImageDrawable(drawable);
                }
            }
        }
        CharSequence charSequence2 = c0591.f2991;
        if (charSequence2 != null) {
            c2892.f11219 = charSequence2;
            TextView textView2 = c2892.f11237;
            if (textView2 != null) {
                textView2.setText(charSequence2);
            }
        }
        CharSequence charSequence3 = c0591.f2990;
        if (charSequence3 != null) {
            c2892.m7058(-1, charSequence3, c0591.f3005);
        }
        CharSequence charSequence4 = c0591.f2993;
        if (charSequence4 != null) {
            c2892.m7058(-2, charSequence4, c0591.f3002);
        }
        if (c0591.f2989 != null || c0591.f2999 != null) {
            AlertController$RecycleListView alertController$RecycleListView = (AlertController$RecycleListView) c0591.f3001.inflate(c2892.f11232, (ViewGroup) null);
            if (c0591.f2995) {
                c2435 = new C5155(c0591, contextThemeWrapper2, c2892.f11218, c0591.f2989, alertController$RecycleListView);
            } else {
                int i = c0591.f3003 ? c2892.f11231 : c2892.f11226;
                c2435 = c0591.f2999;
                if (c2435 == null) {
                    c2435 = new C2435(contextThemeWrapper2, i, R.id.text1, c0591.f2989);
                }
            }
            c2892.f11250 = c2435;
            c2892.f11249 = c0591.f2994;
            if (c0591.f2998 != null) {
                alertController$RecycleListView.setOnItemClickListener(new C2613(c0591, c2892));
            } else if (c0591.f2997 != null) {
                alertController$RecycleListView.setOnItemClickListener(new C5066(c0591, alertController$RecycleListView, c2892));
            }
            if (c0591.f3003) {
                alertController$RecycleListView.setChoiceMode(1);
            } else if (c0591.f2995) {
                alertController$RecycleListView.setChoiceMode(2);
            }
            c2892.f11224 = alertController$RecycleListView;
        }
        View view2 = c0591.f3000;
        if (view2 != null) {
            c2892.f11222 = view2;
            c2892.f11247 = false;
        }
        dialogInterfaceC5504.setCancelable(true);
        dialogInterfaceC5504.setCanceledOnTouchOutside(true);
        dialogInterfaceC5504.setOnCancelListener(null);
        dialogInterfaceC5504.setOnDismissListener(null);
        DialogInterfaceOnKeyListenerC3753 dialogInterfaceOnKeyListenerC3753 = c0591.f3004;
        if (dialogInterfaceOnKeyListenerC3753 != null) {
            dialogInterfaceC5504.setOnKeyListener(dialogInterfaceOnKeyListenerC3753);
        }
        return dialogInterfaceC5504;
    }

    public Context getContext() {
        return this.f18871.f2996;
    }

    public C5049 setNegativeButton(int i, DialogInterface.OnClickListener onClickListener) {
        C0591 c0591 = this.f18871;
        c0591.f2993 = c0591.f2996.getText(i);
        c0591.f3002 = onClickListener;
        return this;
    }

    public C5049 setPositiveButton(int i, DialogInterface.OnClickListener onClickListener) {
        C0591 c0591 = this.f18871;
        c0591.f2990 = c0591.f2996.getText(i);
        c0591.f3005 = onClickListener;
        return this;
    }

    public C5049 setTitle(CharSequence charSequence) {
        this.f18871.f3006 = charSequence;
        return this;
    }

    public C5049 setView(View view) {
        this.f18871.f3000 = view;
        return this;
    }
}
