package defpackage;

import android.content.Context;
import android.content.DialogInterface;
import android.graphics.drawable.Drawable;
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.view.Window;
import android.widget.Button;
import android.widget.FrameLayout;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.ListAdapter;
import android.widget.TextView;
import androidx.appcompat.app.AlertController$RecycleListView;
import androidx.core.widget.NestedScrollView;
import ar.tvplayer.tv.R;
import java.util.WeakHashMap;

/* JADX INFO: renamed from: ᵥᐧʽ, reason: contains not printable characters */
/* JADX INFO: loaded from: classes3.dex */
public final class DialogInterfaceC3504 extends DialogC1635 implements DialogInterface, InterfaceC1011 {

    /* JADX INFO: renamed from: ᵨᵼⁱ, reason: contains not printable characters */
    public LayoutInflaterFactory2C5168 f13461;

    /* JADX INFO: renamed from: ᵯᵷʽ, reason: contains not printable characters */
    public final C4608 f13462;

    /* JADX INFO: renamed from: ᵶˇᵱ, reason: contains not printable characters */
    public final C3208 f13463;

    /* JADX WARN: Type inference failed for: r2v2, types: [ᵳᵱ] */
    public DialogInterfaceC3504(ContextThemeWrapper contextThemeWrapper, int i) {
        int i2;
        int iM8004 = m8004(contextThemeWrapper, i);
        if (iM8004 == 0) {
            TypedValue typedValue = new TypedValue();
            contextThemeWrapper.getTheme().resolveAttribute(R.attr._4d5_res_0x7f0401f9, typedValue, true);
            i2 = typedValue.resourceId;
        } else {
            i2 = iM8004;
        }
        super(contextThemeWrapper, i2);
        this.f13462 = new InterfaceC4336() { // from class: ᵳᵱ
            @Override // defpackage.InterfaceC4336
            /* JADX INFO: renamed from: ᵲᵶᵳˈ */
            public final boolean mo9326(KeyEvent keyEvent) {
                return this.f17520.m8006(keyEvent);
            }
        };
        AbstractC5112 abstractC5112M8005 = m8005();
        if (iM8004 == 0) {
            TypedValue typedValue2 = new TypedValue();
            contextThemeWrapper.getTheme().resolveAttribute(R.attr._4d5_res_0x7f0401f9, typedValue2, true);
            iM8004 = typedValue2.resourceId;
        }
        ((LayoutInflaterFactory2C5168) abstractC5112M8005).f19426 = iM8004;
        abstractC5112M8005.mo10612();
        this.f13463 = new C3208(getContext(), this, getWindow());
    }

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

    @Override // defpackage.DialogC1635, android.app.Dialog
    public final void addContentView(View view, ViewGroup.LayoutParams layoutParams) {
        m4524();
        LayoutInflaterFactory2C5168 layoutInflaterFactory2C5168 = (LayoutInflaterFactory2C5168) m8005();
        layoutInflaterFactory2C5168.m10677();
        ((ViewGroup) layoutInflaterFactory2C5168.f19421.findViewById(android.R.id.content)).addView(view, layoutParams);
        layoutInflaterFactory2C5168.f19430.m7419(layoutInflaterFactory2C5168.f19451.getCallback());
    }

    @Override // android.app.Dialog, android.content.DialogInterface
    public final void dismiss() {
        super.dismiss();
        m8005().mo10614();
    }

    @Override // android.app.Dialog, android.view.Window.Callback
    public final boolean dispatchKeyEvent(KeyEvent keyEvent) {
        return ᵗʓ.ᵮᵣᵗˈ(this.f13462, getWindow().getDecorView(), this, keyEvent);
    }

    @Override // android.app.Dialog
    public final View findViewById(int i) {
        LayoutInflaterFactory2C5168 layoutInflaterFactory2C5168 = (LayoutInflaterFactory2C5168) m8005();
        layoutInflaterFactory2C5168.m10677();
        return layoutInflaterFactory2C5168.f19451.findViewById(i);
    }

    @Override // android.app.Dialog
    public final void invalidateOptionsMenu() {
        LayoutInflaterFactory2C5168 layoutInflaterFactory2C5168 = (LayoutInflaterFactory2C5168) m8005();
        if (layoutInflaterFactory2C5168.f19424 != null) {
            layoutInflaterFactory2C5168.m10682();
            layoutInflaterFactory2C5168.f19424.getClass();
            layoutInflaterFactory2C5168.m10685(0);
        }
    }

    @Override // defpackage.DialogC1635, android.app.Dialog
    public final void onCreate(Bundle bundle) {
        int i;
        ListAdapter listAdapter;
        View viewFindViewById;
        m8007(bundle);
        C3208 c3208 = this.f13463;
        c3208.f12196.setContentView(c3208.f12218);
        Context context = c3208.f12221;
        Window window = c3208.f12207;
        View viewFindViewById2 = window.findViewById(R.id.up);
        View viewFindViewById3 = viewFindViewById2.findViewById(R.id._38i_res_0x7f0b03c4);
        View viewFindViewById4 = viewFindViewById2.findViewById(R.id._2tt_res_0x7f0b00f9);
        View viewFindViewById5 = viewFindViewById2.findViewById(R.id._3jh_res_0x7f0b00bb);
        ViewGroup viewGroup = (ViewGroup) viewFindViewById2.findViewById(R.id._3m2_res_0x7f0b0112);
        View view = c3208.f12222;
        if (view == null) {
            view = null;
        }
        boolean z = view != null;
        if (!z || !C3208.m7342(view)) {
            window.setFlags(131072, 131072);
        }
        if (z) {
            FrameLayout frameLayout = (FrameLayout) window.findViewById(R.id._1u7_res_0x7f0b0111);
            frameLayout.addView(view, new ViewGroup.LayoutParams(-1, -1));
            if (c3208.f12202) {
                frameLayout.setPadding(0, 0, 0, 0);
            }
            if (c3208.f12228 != null) {
                ((LinearLayout.LayoutParams) ((C0917) viewGroup.getLayoutParams())).weight = 0.0f;
            }
        } else {
            viewGroup.setVisibility(8);
        }
        View viewFindViewById6 = viewGroup.findViewById(R.id._38i_res_0x7f0b03c4);
        View viewFindViewById7 = viewGroup.findViewById(R.id._2tt_res_0x7f0b00f9);
        View viewFindViewById8 = viewGroup.findViewById(R.id._3jh_res_0x7f0b00bb);
        ViewGroup viewGroupM7341 = C3208.m7341(viewFindViewById6, viewFindViewById3);
        ViewGroup viewGroupM73412 = C3208.m7341(viewFindViewById7, viewFindViewById4);
        ViewGroup viewGroupM73413 = C3208.m7341(viewFindViewById8, viewFindViewById5);
        NestedScrollView nestedScrollView = (NestedScrollView) window.findViewById(R.id._4g4_res_0x7f0b0346);
        c3208.f12200 = nestedScrollView;
        nestedScrollView.setFocusable(false);
        c3208.f12200.setNestedScrollingEnabled(false);
        TextView textView = (TextView) viewGroupM73412.findViewById(android.R.id.message);
        c3208.f12204 = textView;
        if (textView != null) {
            CharSequence charSequence = c3208.f12214;
            if (charSequence != null) {
                textView.setText(charSequence);
            } else {
                textView.setVisibility(8);
                c3208.f12200.removeView(c3208.f12204);
                if (c3208.f12228 != null) {
                    ViewGroup viewGroup2 = (ViewGroup) c3208.f12200.getParent();
                    int iIndexOfChild = viewGroup2.indexOfChild(c3208.f12200);
                    viewGroup2.removeViewAt(iIndexOfChild);
                    viewGroup2.addView(c3208.f12228, iIndexOfChild, new ViewGroup.LayoutParams(-1, -1));
                } else {
                    viewGroupM73412.setVisibility(8);
                }
            }
        }
        Button button = (Button) viewGroupM73413.findViewById(android.R.id.button1);
        c3208.f12227 = button;
        ViewOnClickListenerC1781 viewOnClickListenerC1781 = c3208.f12213;
        button.setOnClickListener(viewOnClickListenerC1781);
        boolean zIsEmpty = TextUtils.isEmpty(c3208.f12220);
        Button button2 = c3208.f12227;
        if (zIsEmpty) {
            button2.setVisibility(8);
            i = 0;
        } else {
            button2.setText(c3208.f12220);
            c3208.f12227.setVisibility(0);
            i = 1;
        }
        Button button3 = (Button) viewGroupM73413.findViewById(android.R.id.button2);
        c3208.f12217 = button3;
        button3.setOnClickListener(viewOnClickListenerC1781);
        boolean zIsEmpty2 = TextUtils.isEmpty(c3208.f12211);
        Button button4 = c3208.f12217;
        if (zIsEmpty2) {
            button4.setVisibility(8);
        } else {
            button4.setText(c3208.f12211);
            c3208.f12217.setVisibility(0);
            i |= 2;
        }
        Button button5 = (Button) viewGroupM73413.findViewById(android.R.id.button3);
        c3208.f12216 = button5;
        button5.setOnClickListener(viewOnClickListenerC1781);
        boolean zIsEmpty3 = TextUtils.isEmpty(c3208.f12212);
        Button button6 = c3208.f12216;
        if (zIsEmpty3) {
            button6.setVisibility(8);
        } else {
            button6.setText(c3208.f12212);
            c3208.f12216.setVisibility(0);
            i |= 4;
        }
        TypedValue typedValue = new TypedValue();
        context.getTheme().resolveAttribute(R.attr._1t_res_0x7f040031, typedValue, true);
        if (typedValue.data != 0) {
            if (i == 1) {
                Button button7 = c3208.f12227;
                LinearLayout.LayoutParams layoutParams = (LinearLayout.LayoutParams) button7.getLayoutParams();
                layoutParams.gravity = 1;
                layoutParams.weight = 0.5f;
                button7.setLayoutParams(layoutParams);
            } else if (i == 2) {
                Button button8 = c3208.f12217;
                LinearLayout.LayoutParams layoutParams2 = (LinearLayout.LayoutParams) button8.getLayoutParams();
                layoutParams2.gravity = 1;
                layoutParams2.weight = 0.5f;
                button8.setLayoutParams(layoutParams2);
            } else if (i == 4) {
                Button button9 = c3208.f12216;
                LinearLayout.LayoutParams layoutParams3 = (LinearLayout.LayoutParams) button9.getLayoutParams();
                layoutParams3.gravity = 1;
                layoutParams3.weight = 0.5f;
                button9.setLayoutParams(layoutParams3);
            }
        }
        if (i == 0) {
            viewGroupM73413.setVisibility(8);
        }
        if (c3208.f12210 != null) {
            viewGroupM7341.addView(c3208.f12210, 0, new ViewGroup.LayoutParams(-1, -2));
            window.findViewById(R.id._4gm_res_0x7f0b03bf).setVisibility(8);
        } else {
            c3208.f12206 = (ImageView) window.findViewById(android.R.id.icon);
            if (TextUtils.isEmpty(c3208.f12225) || !c3208.f12208) {
                window.findViewById(R.id._4gm_res_0x7f0b03bf).setVisibility(8);
                c3208.f12206.setVisibility(8);
                viewGroupM7341.setVisibility(8);
            } else {
                TextView textView2 = (TextView) window.findViewById(R.id._201_res_0x7f0b0056);
                c3208.f12201 = textView2;
                textView2.setText(c3208.f12225);
                Drawable drawable = c3208.f12199;
                if (drawable != null) {
                    c3208.f12206.setImageDrawable(drawable);
                } else {
                    c3208.f12201.setPadding(c3208.f12206.getPaddingLeft(), c3208.f12206.getPaddingTop(), c3208.f12206.getPaddingRight(), c3208.f12206.getPaddingBottom());
                    c3208.f12206.setVisibility(8);
                }
            }
        }
        boolean z2 = viewGroup.getVisibility() != 8;
        int i2 = (viewGroupM7341 == null || viewGroupM7341.getVisibility() == 8) ? 0 : 1;
        boolean z3 = viewGroupM73413.getVisibility() != 8;
        if (!z3 && (viewFindViewById = viewGroupM73412.findViewById(R.id._1sj_res_0x7f0b03a8)) != null) {
            viewFindViewById.setVisibility(0);
        }
        if (i2 != 0) {
            NestedScrollView nestedScrollView2 = c3208.f12200;
            if (nestedScrollView2 != null) {
                nestedScrollView2.setClipToPadding(true);
            }
            View viewFindViewById9 = (c3208.f12214 == null && c3208.f12228 == null) ? null : viewGroupM7341.findViewById(R.id._3rk_res_0x7f0b03bc);
            if (viewFindViewById9 != null) {
                viewFindViewById9.setVisibility(0);
            }
        } else {
            View viewFindViewById10 = viewGroupM73412.findViewById(R.id._16e_res_0x7f0b03a9);
            if (viewFindViewById10 != null) {
                viewFindViewById10.setVisibility(0);
            }
        }
        AlertController$RecycleListView alertController$RecycleListView = c3208.f12228;
        if (alertController$RecycleListView != null) {
            alertController$RecycleListView.getClass();
            if (!z3 || i2 == 0) {
                alertController$RecycleListView.setPadding(alertController$RecycleListView.getPaddingLeft(), i2 != 0 ? alertController$RecycleListView.getPaddingTop() : alertController$RecycleListView.f38, alertController$RecycleListView.getPaddingRight(), z3 ? alertController$RecycleListView.getPaddingBottom() : alertController$RecycleListView.f39);
            }
        }
        if (!z2) {
            View view2 = c3208.f12228;
            if (view2 == null) {
                view2 = c3208.f12200;
            }
            if (view2 != null) {
                int i3 = z3 ? 2 : 0;
                View viewFindViewById11 = window.findViewById(R.id._2ke_res_0x7f0b0345);
                View viewFindViewById12 = window.findViewById(R.id._3vk_res_0x7f0b0344);
                WeakHashMap weakHashMap = AbstractC2746.f10556;
                view2.setScrollIndicators(i2 | i3, 3);
                if (viewFindViewById11 != null) {
                    viewGroupM73412.removeView(viewFindViewById11);
                }
                if (viewFindViewById12 != null) {
                    viewGroupM73412.removeView(viewFindViewById12);
                }
            }
        }
        AlertController$RecycleListView alertController$RecycleListView2 = c3208.f12228;
        if (alertController$RecycleListView2 == null || (listAdapter = c3208.f12209) == null) {
            return;
        }
        alertController$RecycleListView2.setAdapter(listAdapter);
        int i4 = c3208.f12215;
        if (i4 > -1) {
            alertController$RecycleListView2.setItemChecked(i4, true);
            alertController$RecycleListView2.setSelection(i4);
        }
    }

    @Override // android.app.Dialog, android.view.KeyEvent.Callback
    public final boolean onKeyDown(int i, KeyEvent keyEvent) {
        NestedScrollView nestedScrollView = this.f13463.f12200;
        if (nestedScrollView == null || !nestedScrollView.m93(keyEvent)) {
            return super.onKeyDown(i, keyEvent);
        }
        return true;
    }

    @Override // android.app.Dialog, android.view.KeyEvent.Callback
    public final boolean onKeyUp(int i, KeyEvent keyEvent) {
        NestedScrollView nestedScrollView = this.f13463.f12200;
        if (nestedScrollView == null || !nestedScrollView.m93(keyEvent)) {
            return super.onKeyUp(i, keyEvent);
        }
        return true;
    }

    @Override // defpackage.DialogC1635, android.app.Dialog
    public final void onStop() {
        super.onStop();
        LayoutInflaterFactory2C5168 layoutInflaterFactory2C5168 = (LayoutInflaterFactory2C5168) m8005();
        layoutInflaterFactory2C5168.m10682();
        C1905 c1905 = layoutInflaterFactory2C5168.f19424;
        if (c1905 != null) {
            c1905.f7550 = false;
            C0192 c0192 = c1905.f7544;
            if (c0192 != null) {
                c0192.m1350();
            }
        }
    }

    @Override // defpackage.DialogC1635, android.app.Dialog
    public final void setContentView(int i) {
        m4524();
        m8005().mo10618(i);
    }

    @Override // defpackage.DialogC1635, android.app.Dialog
    public final void setContentView(View view) {
        m4524();
        m8005().mo10617(view);
    }

    @Override // defpackage.DialogC1635, android.app.Dialog
    public final void setContentView(View view, ViewGroup.LayoutParams layoutParams) {
        m4524();
        m8005().mo10613(view, layoutParams);
    }

    @Override // android.app.Dialog
    public final void setTitle(int i) {
        super.setTitle(i);
        m8005().mo10616(getContext().getString(i));
    }

    @Override // android.app.Dialog
    public final void setTitle(CharSequence charSequence) {
        m8008(charSequence);
        C3208 c3208 = this.f13463;
        c3208.f12225 = charSequence;
        TextView textView = c3208.f12201;
        if (textView != null) {
            textView.setText(charSequence);
        }
        c3208.f12207.setTitle(charSequence);
    }

    /* JADX INFO: renamed from: ːˏᵟᵯ, reason: contains not printable characters */
    public final AbstractC5112 m8005() {
        if (this.f13461 == null) {
            ExecutorC4005 executorC4005 = AbstractC5112.f19255;
            this.f13461 = new LayoutInflaterFactory2C5168(getContext(), getWindow(), this, this);
        }
        return this.f13461;
    }

    /* JADX INFO: renamed from: ᵵᵽ, reason: contains not printable characters */
    public final boolean m8006(KeyEvent keyEvent) {
        return super.dispatchKeyEvent(keyEvent);
    }

    /* JADX INFO: renamed from: ᵷᵺʾᵖ, reason: contains not printable characters */
    public final void m8007(Bundle bundle) {
        LayoutInflaterFactory2C5168 layoutInflaterFactory2C5168 = (LayoutInflaterFactory2C5168) m8005();
        LayoutInflater layoutInflaterFrom = LayoutInflater.from(layoutInflaterFactory2C5168.f19418);
        if (layoutInflaterFrom.getFactory() == null) {
            layoutInflaterFrom.setFactory2(layoutInflaterFactory2C5168);
        } else {
            layoutInflaterFrom.getFactory2();
        }
        super.onCreate(bundle);
        m8005().mo10612();
    }

    /* JADX INFO: renamed from: ᵻˈᵦʼ, reason: contains not printable characters */
    public final void m8008(CharSequence charSequence) {
        super.setTitle(charSequence);
        m8005().mo10616(charSequence);
    }
}
