package p037.p041.p042;

import android.R;
import android.content.Context;
import android.content.DialogInterface;
import android.graphics.drawable.Drawable;
import android.os.Build;
import android.os.Bundle;
import android.text.TextUtils;
import android.util.TypedValue;
import android.view.ContextThemeWrapper;
import android.view.KeyEvent;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.Button;
import android.widget.FrameLayout;
import android.widget.ImageView;
import android.widget.ListAdapter;
import android.widget.ListView;
import android.widget.TextView;
import androidx.appcompat.app.AlertController;
import androidx.core.widget.NestedScrollView;
import p037.p041.C1468;
import p037.p041.C1473;
import p037.p041.p051.C1658;
import p037.p065.p078.C1920;

/* JADX INFO: renamed from: މ.ؠ.ވ.ކ, reason: contains not printable characters */
/* JADX INFO: loaded from: classes.dex */
public class DialogInterfaceC1489 extends DialogC1515 implements DialogInterface {

    /* JADX INFO: renamed from: ޅ, reason: contains not printable characters */
    public final AlertController f4671;

    /* JADX INFO: renamed from: މ.ؠ.ވ.ކ$֏, reason: contains not printable characters */
    public static class C1490 {

        /* JADX INFO: renamed from: ֏, reason: contains not printable characters */
        public final AlertController.C0030 f4672;

        /* JADX INFO: renamed from: ؠ, reason: contains not printable characters */
        public final int f4673;

        public C1490(Context context) {
            int iM2815 = DialogInterfaceC1489.m2815(context, 0);
            this.f4672 = new AlertController.C0030(new ContextThemeWrapper(context, DialogInterfaceC1489.m2815(context, iM2815)));
            this.f4673 = iM2815;
        }

        /* JADX INFO: renamed from: ֏, reason: contains not printable characters */
        public DialogInterfaceC1489 m2816() {
            ListAdapter c0032;
            DialogInterfaceC1489 dialogInterfaceC1489 = new DialogInterfaceC1489(this.f4672.f168, this.f4673);
            AlertController.C0030 c0030 = this.f4672;
            AlertController alertController = dialogInterfaceC1489.f4671;
            View view = c0030.f174;
            if (view != null) {
                alertController.f152 = view;
            } else {
                CharSequence charSequence = c0030.f173;
                if (charSequence != null) {
                    alertController.f124 = charSequence;
                    TextView textView = alertController.f150;
                    if (textView != null) {
                        textView.setText(charSequence);
                    }
                }
                Drawable drawable = c0030.f171;
                if (drawable != null) {
                    alertController.f148 = drawable;
                    alertController.f147 = 0;
                    ImageView imageView = alertController.f149;
                    if (imageView != null) {
                        imageView.setVisibility(0);
                        alertController.f149.setImageDrawable(drawable);
                    }
                }
                int i = c0030.f170;
                if (i != 0) {
                    alertController.m100(i);
                }
                int i2 = c0030.f172;
                if (i2 != 0) {
                    if (alertController == null) {
                        throw null;
                    }
                    TypedValue typedValue = new TypedValue();
                    alertController.f120.getTheme().resolveAttribute(i2, typedValue, true);
                    alertController.m100(typedValue.resourceId);
                }
            }
            CharSequence charSequence2 = c0030.f175;
            if (charSequence2 != null) {
                alertController.f125 = charSequence2;
                TextView textView2 = alertController.f151;
                if (textView2 != null) {
                    textView2.setText(charSequence2);
                }
            }
            CharSequence charSequence3 = c0030.f176;
            if (charSequence3 != null) {
                alertController.m101(-1, charSequence3, c0030.f177, null, null);
            }
            CharSequence charSequence4 = c0030.f178;
            if (charSequence4 != null) {
                alertController.m101(-2, charSequence4, c0030.f179, null, null);
            }
            if (c0030.f184 != null || c0030.f185 != null) {
                AlertController.RecycleListView recycleListView = (AlertController.RecycleListView) c0030.f169.inflate(alertController.f157, (ViewGroup) null);
                if (c0030.f191) {
                    c0032 = new C1486(c0030, c0030.f168, alertController.f158, R.id.text1, c0030.f184, recycleListView);
                } else {
                    int i3 = c0030.f192 ? alertController.f159 : alertController.f160;
                    c0032 = c0030.f185;
                    if (c0032 == null) {
                        c0032 = new AlertController.C0032(c0030.f168, i3, R.id.text1, c0030.f184);
                    }
                }
                alertController.f153 = c0032;
                alertController.f154 = c0030.f193;
                if (c0030.f186 != null) {
                    recycleListView.setOnItemClickListener(new C1487(c0030, alertController));
                } else if (c0030.f194 != null) {
                    recycleListView.setOnItemClickListener(new C1488(c0030, recycleListView, alertController));
                }
                if (c0030.f192) {
                    recycleListView.setChoiceMode(1);
                } else if (c0030.f191) {
                    recycleListView.setChoiceMode(2);
                }
                alertController.f126 = recycleListView;
            }
            View view2 = c0030.f188;
            if (view2 == null) {
                int i4 = c0030.f187;
                if (i4 != 0) {
                    alertController.f127 = null;
                    alertController.f128 = i4;
                    alertController.f133 = false;
                }
            } else if (c0030.f189) {
                alertController.f127 = view2;
                alertController.f128 = 0;
                alertController.f133 = true;
                alertController.f129 = 0;
                alertController.f130 = 0;
                alertController.f131 = 0;
                alertController.f132 = 0;
            } else {
                alertController.f127 = view2;
                alertController.f128 = 0;
                alertController.f133 = false;
            }
            dialogInterfaceC1489.setCancelable(this.f4672.f180);
            if (this.f4672.f180) {
                dialogInterfaceC1489.setCanceledOnTouchOutside(true);
            }
            dialogInterfaceC1489.setOnCancelListener(this.f4672.f181);
            dialogInterfaceC1489.setOnDismissListener(this.f4672.f182);
            DialogInterface.OnKeyListener onKeyListener = this.f4672.f183;
            if (onKeyListener != null) {
                dialogInterfaceC1489.setOnKeyListener(onKeyListener);
            }
            return dialogInterfaceC1489;
        }
    }

    public DialogInterfaceC1489(Context context, int i) {
        super(context, m2815(context, i));
        this.f4671 = new AlertController(getContext(), this, getWindow());
    }

    /* JADX INFO: renamed from: ֏, reason: contains not printable characters */
    public static int m2815(Context context, int i) {
        if (((i >>> 24) & 255) >= 1) {
            return i;
        }
        TypedValue typedValue = new TypedValue();
        context.getTheme().resolveAttribute(C1468.alertDialogTheme, typedValue, true);
        return typedValue.resourceId;
    }

    @Override // p037.p041.p042.DialogC1515, android.app.Dialog
    public void onCreate(Bundle bundle) {
        int i;
        ListAdapter listAdapter;
        View viewFindViewById;
        super.onCreate(bundle);
        AlertController alertController = this.f4671;
        int i2 = alertController.f156;
        if (i2 == 0 || alertController.f162 != 1) {
            i2 = alertController.f155;
        }
        alertController.f121.setContentView(i2);
        View viewFindViewById2 = alertController.f122.findViewById(C1473.parentPanel);
        View viewFindViewById3 = viewFindViewById2.findViewById(C1473.topPanel);
        View viewFindViewById4 = viewFindViewById2.findViewById(C1473.contentPanel);
        View viewFindViewById5 = viewFindViewById2.findViewById(C1473.buttonPanel);
        ViewGroup viewGroup = (ViewGroup) viewFindViewById2.findViewById(C1473.customPanel);
        View viewInflate = alertController.f127;
        View view = null;
        if (viewInflate == null) {
            viewInflate = alertController.f128 != 0 ? LayoutInflater.from(alertController.f120).inflate(alertController.f128, viewGroup, false) : null;
        }
        boolean z = viewInflate != null;
        if (!z || !AlertController.m98(viewInflate)) {
            alertController.f122.setFlags(131072, 131072);
        }
        if (z) {
            FrameLayout frameLayout = (FrameLayout) alertController.f122.findViewById(C1473.custom);
            frameLayout.addView(viewInflate, new ViewGroup.LayoutParams(-1, -1));
            if (alertController.f133) {
                frameLayout.setPadding(alertController.f129, alertController.f130, alertController.f131, alertController.f132);
            }
            if (alertController.f126 != null) {
                ((C1658.C1659) viewGroup.getLayoutParams()).f5393 = 0.0f;
            }
        } else {
            viewGroup.setVisibility(8);
        }
        View viewFindViewById6 = viewGroup.findViewById(C1473.topPanel);
        View viewFindViewById7 = viewGroup.findViewById(C1473.contentPanel);
        View viewFindViewById8 = viewGroup.findViewById(C1473.buttonPanel);
        ViewGroup viewGroupM99 = alertController.m99(viewFindViewById6, viewFindViewById3);
        ViewGroup viewGroupM992 = alertController.m99(viewFindViewById7, viewFindViewById4);
        ViewGroup viewGroupM993 = alertController.m99(viewFindViewById8, viewFindViewById5);
        NestedScrollView nestedScrollView = (NestedScrollView) alertController.f122.findViewById(C1473.scrollView);
        alertController.f146 = nestedScrollView;
        nestedScrollView.setFocusable(false);
        alertController.f146.setNestedScrollingEnabled(false);
        TextView textView = (TextView) viewGroupM992.findViewById(R.id.message);
        alertController.f151 = textView;
        if (textView != null) {
            CharSequence charSequence = alertController.f125;
            if (charSequence != null) {
                textView.setText(charSequence);
            } else {
                textView.setVisibility(8);
                alertController.f146.removeView(alertController.f151);
                if (alertController.f126 != null) {
                    ViewGroup viewGroup2 = (ViewGroup) alertController.f146.getParent();
                    int iIndexOfChild = viewGroup2.indexOfChild(alertController.f146);
                    viewGroup2.removeViewAt(iIndexOfChild);
                    viewGroup2.addView(alertController.f126, iIndexOfChild, new ViewGroup.LayoutParams(-1, -1));
                } else {
                    viewGroupM992.setVisibility(8);
                }
            }
        }
        Button button = (Button) viewGroupM993.findViewById(R.id.button1);
        alertController.f134 = button;
        button.setOnClickListener(alertController.f164);
        if (TextUtils.isEmpty(alertController.f135) && alertController.f137 == null) {
            alertController.f134.setVisibility(8);
            i = 0;
        } else {
            alertController.f134.setText(alertController.f135);
            Drawable drawable = alertController.f137;
            if (drawable != null) {
                int i3 = alertController.f123;
                drawable.setBounds(0, 0, i3, i3);
                alertController.f134.setCompoundDrawables(alertController.f137, null, null, null);
            }
            alertController.f134.setVisibility(0);
            i = 1;
        }
        Button button2 = (Button) viewGroupM993.findViewById(R.id.button2);
        alertController.f138 = button2;
        button2.setOnClickListener(alertController.f164);
        if (TextUtils.isEmpty(alertController.f139) && alertController.f141 == null) {
            alertController.f138.setVisibility(8);
        } else {
            alertController.f138.setText(alertController.f139);
            Drawable drawable2 = alertController.f141;
            if (drawable2 != null) {
                int i4 = alertController.f123;
                drawable2.setBounds(0, 0, i4, i4);
                alertController.f138.setCompoundDrawables(alertController.f141, null, null, null);
            }
            alertController.f138.setVisibility(0);
            i |= 2;
        }
        Button button3 = (Button) viewGroupM993.findViewById(R.id.button3);
        alertController.f142 = button3;
        button3.setOnClickListener(alertController.f164);
        if (TextUtils.isEmpty(alertController.f143) && alertController.f145 == null) {
            alertController.f142.setVisibility(8);
        } else {
            alertController.f142.setText(alertController.f143);
            Drawable drawable3 = alertController.f145;
            if (drawable3 != null) {
                int i5 = alertController.f123;
                drawable3.setBounds(0, 0, i5, i5);
                alertController.f142.setCompoundDrawables(alertController.f145, null, null, null);
            }
            alertController.f142.setVisibility(0);
            i |= 4;
        }
        Context context = alertController.f120;
        TypedValue typedValue = new TypedValue();
        context.getTheme().resolveAttribute(C1468.alertDialogCenterButtons, typedValue, true);
        if (typedValue.data != 0) {
            if (i == 1) {
                alertController.m102(alertController.f134);
            } else if (i == 2) {
                alertController.m102(alertController.f138);
            } else if (i == 4) {
                alertController.m102(alertController.f142);
            }
        }
        if (!(i != 0)) {
            viewGroupM993.setVisibility(8);
        }
        if (alertController.f152 != null) {
            viewGroupM99.addView(alertController.f152, 0, new ViewGroup.LayoutParams(-1, -2));
            alertController.f122.findViewById(C1473.title_template).setVisibility(8);
        } else {
            alertController.f149 = (ImageView) alertController.f122.findViewById(R.id.icon);
            if ((!TextUtils.isEmpty(alertController.f124)) && alertController.f161) {
                TextView textView2 = (TextView) alertController.f122.findViewById(C1473.alertTitle);
                alertController.f150 = textView2;
                textView2.setText(alertController.f124);
                int i6 = alertController.f147;
                if (i6 != 0) {
                    alertController.f149.setImageResource(i6);
                } else {
                    Drawable drawable4 = alertController.f148;
                    if (drawable4 != null) {
                        alertController.f149.setImageDrawable(drawable4);
                    } else {
                        alertController.f150.setPadding(alertController.f149.getPaddingLeft(), alertController.f149.getPaddingTop(), alertController.f149.getPaddingRight(), alertController.f149.getPaddingBottom());
                        alertController.f149.setVisibility(8);
                    }
                }
            } else {
                alertController.f122.findViewById(C1473.title_template).setVisibility(8);
                alertController.f149.setVisibility(8);
                viewGroupM99.setVisibility(8);
            }
        }
        boolean z2 = viewGroup.getVisibility() != 8;
        int i7 = (viewGroupM99 == null || viewGroupM99.getVisibility() == 8) ? 0 : 1;
        boolean z3 = viewGroupM993.getVisibility() != 8;
        if (!z3 && (viewFindViewById = viewGroupM992.findViewById(C1473.textSpacerNoButtons)) != null) {
            viewFindViewById.setVisibility(0);
        }
        if (i7 != 0) {
            NestedScrollView nestedScrollView2 = alertController.f146;
            if (nestedScrollView2 != null) {
                nestedScrollView2.setClipToPadding(true);
            }
            View viewFindViewById9 = (alertController.f125 == null && alertController.f126 == null) ? null : viewGroupM99.findViewById(C1473.titleDividerNoCustom);
            if (viewFindViewById9 != null) {
                viewFindViewById9.setVisibility(0);
            }
        } else {
            View viewFindViewById10 = viewGroupM992.findViewById(C1473.textSpacerNoTitle);
            if (viewFindViewById10 != null) {
                viewFindViewById10.setVisibility(0);
            }
        }
        ListView listView = alertController.f126;
        if (listView instanceof AlertController.RecycleListView) {
            AlertController.RecycleListView recycleListView = (AlertController.RecycleListView) listView;
            if (recycleListView == null) {
                throw null;
            }
            if (!z3 || i7 == 0) {
                recycleListView.setPadding(recycleListView.getPaddingLeft(), i7 != 0 ? recycleListView.getPaddingTop() : recycleListView.f165, recycleListView.getPaddingRight(), z3 ? recycleListView.getPaddingBottom() : recycleListView.f166);
            }
        }
        if (!z2) {
            View view2 = alertController.f126;
            if (view2 == null) {
                view2 = alertController.f146;
            }
            if (view2 != null) {
                int i8 = i7 | (z3 ? 2 : 0);
                View viewFindViewById11 = alertController.f122.findViewById(C1473.scrollIndicatorUp);
                View viewFindViewById12 = alertController.f122.findViewById(C1473.scrollIndicatorDown);
                if (Build.VERSION.SDK_INT >= 23) {
                    C1920.m3741(view2, i8, 3);
                    if (viewFindViewById11 != null) {
                        viewGroupM992.removeView(viewFindViewById11);
                    }
                    if (viewFindViewById12 != null) {
                        viewGroupM992.removeView(viewFindViewById12);
                    }
                } else {
                    if (viewFindViewById11 != null && (i8 & 1) == 0) {
                        viewGroupM992.removeView(viewFindViewById11);
                        viewFindViewById11 = null;
                    }
                    if (viewFindViewById12 == null || (i8 & 2) != 0) {
                        view = viewFindViewById12;
                    } else {
                        viewGroupM992.removeView(viewFindViewById12);
                    }
                    if (viewFindViewById11 != null || view != null) {
                        if (alertController.f125 != null) {
                            alertController.f146.setOnScrollChangeListener(new C1482(alertController, viewFindViewById11, view));
                            alertController.f146.post(new RunnableC1483(alertController, viewFindViewById11, view));
                        } else {
                            ListView listView2 = alertController.f126;
                            if (listView2 != null) {
                                listView2.setOnScrollListener(new C1484(alertController, viewFindViewById11, view));
                                alertController.f126.post(new RunnableC1485(alertController, viewFindViewById11, view));
                            } else {
                                if (viewFindViewById11 != null) {
                                    viewGroupM992.removeView(viewFindViewById11);
                                }
                                if (view != null) {
                                    viewGroupM992.removeView(view);
                                }
                            }
                        }
                    }
                }
            }
        }
        ListView listView3 = alertController.f126;
        if (listView3 == null || (listAdapter = alertController.f153) == null) {
            return;
        }
        listView3.setAdapter(listAdapter);
        int i9 = alertController.f154;
        if (i9 > -1) {
            listView3.setItemChecked(i9, true);
            listView3.setSelection(i9);
        }
    }

    @Override // android.app.Dialog, android.view.KeyEvent.Callback
    public boolean onKeyDown(int i, KeyEvent keyEvent) {
        NestedScrollView nestedScrollView = this.f4671.f146;
        if (nestedScrollView != null && nestedScrollView.m246(keyEvent)) {
            return true;
        }
        return super.onKeyDown(i, keyEvent);
    }

    @Override // android.app.Dialog, android.view.KeyEvent.Callback
    public boolean onKeyUp(int i, KeyEvent keyEvent) {
        NestedScrollView nestedScrollView = this.f4671.f146;
        if (nestedScrollView != null && nestedScrollView.m246(keyEvent)) {
            return true;
        }
        return super.onKeyUp(i, keyEvent);
    }

    @Override // p037.p041.p042.DialogC1515, android.app.Dialog
    public void setTitle(CharSequence charSequence) {
        super.setTitle(charSequence);
        AlertController alertController = this.f4671;
        alertController.f124 = charSequence;
        TextView textView = alertController.f150;
        if (textView != null) {
            textView.setText(charSequence);
        }
    }
}
