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;

/* renamed from: ᵿˑ, reason: contains not printable characters */
/* loaded from: classes3.dex */
public final class DialogInterfaceC5504 extends DialogC1493 implements DialogInterface, InterfaceC5006 {

    /* renamed from: ᵡⁱᵥ, reason: contains not printable characters */
    public final C2892 f20709;

    /* renamed from: ᵤᵙᵷ, reason: contains not printable characters */
    public final C0537 f20710;

    /* renamed from: ᵾᵬ, reason: contains not printable characters */
    public LayoutInflaterFactory2C4211 f20711;

    /* JADX WARN: Type inference failed for: r2v2, types: [ˀˋᵽ] */
    public DialogInterfaceC5504(ContextThemeWrapper contextThemeWrapper, int i) {
        int i2;
        int iM11129 = m11129(contextThemeWrapper, i);
        if (iM11129 == 0) {
            TypedValue typedValue = new TypedValue();
            contextThemeWrapper.getTheme().resolveAttribute(R.attr._11_res_0x7f0401f9, typedValue, true);
            i2 = typedValue.resourceId;
        } else {
            i2 = iM11129;
        }
        super(contextThemeWrapper, i2);
        this.f20710 = new InterfaceC3105() { // from class: ˀˋᵽ
            @Override // defpackage.InterfaceC3105
            /* renamed from: ᵥᵯˎ, reason: contains not printable characters */
            public final boolean mo2329(KeyEvent keyEvent) {
                return this.f2788.m11130(keyEvent);
            }
        };
        AbstractC4175 abstractC4175M11132 = m11132();
        if (iM11129 == 0) {
            TypedValue typedValue2 = new TypedValue();
            contextThemeWrapper.getTheme().resolveAttribute(R.attr._11_res_0x7f0401f9, typedValue2, true);
            iM11129 = typedValue2.resourceId;
        }
        ((LayoutInflaterFactory2C4211) abstractC4175M11132).f15776 = iM11129;
        abstractC4175M11132.mo9094();
        this.f20709 = new C2892(getContext(), this, getWindow());
    }

    /* renamed from: ˇʼʤˎ, reason: contains not printable characters */
    public static int m11129(Context context, int i) {
        if (((i >>> 24) & 255) >= 1) {
            return i;
        }
        TypedValue typedValue = new TypedValue();
        context.getTheme().resolveAttribute(R.attr._11_res_0x7f040033, typedValue, true);
        return typedValue.resourceId;
    }

    @Override // defpackage.DialogC1493, android.app.Dialog
    public final void addContentView(View view, ViewGroup.LayoutParams layoutParams) {
        m4423();
        LayoutInflaterFactory2C4211 layoutInflaterFactory2C4211 = (LayoutInflaterFactory2C4211) m11132();
        layoutInflaterFactory2C4211.m9160();
        ((ViewGroup) layoutInflaterFactory2C4211.f15770.findViewById(android.R.id.content)).addView(view, layoutParams);
        layoutInflaterFactory2C4211.f15788.m4286(layoutInflaterFactory2C4211.f15775.getCallback());
    }

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

    @Override // android.app.Dialog, android.view.Window.Callback
    public final boolean dispatchKeyEvent(KeyEvent keyEvent) {
        return ᵕˏᵛ.ᵧᵾˀˈ(this.f20710, getWindow().getDecorView(), this, keyEvent);
    }

    @Override // android.app.Dialog
    public final View findViewById(int i) {
        LayoutInflaterFactory2C4211 layoutInflaterFactory2C4211 = (LayoutInflaterFactory2C4211) m11132();
        layoutInflaterFactory2C4211.m9160();
        return layoutInflaterFactory2C4211.f15775.findViewById(i);
    }

    @Override // android.app.Dialog
    public final void invalidateOptionsMenu() {
        LayoutInflaterFactory2C4211 layoutInflaterFactory2C4211 = (LayoutInflaterFactory2C4211) m11132();
        if (layoutInflaterFactory2C4211.f15763 != null) {
            layoutInflaterFactory2C4211.m9166();
            layoutInflaterFactory2C4211.f15763.getClass();
            layoutInflaterFactory2C4211.m9157(0);
        }
    }

    @Override // defpackage.DialogC1493, android.app.Dialog
    public final void onCreate(Bundle bundle) {
        int i;
        ListAdapter listAdapter;
        View viewFindViewById;
        m11133(bundle);
        C2892 c2892 = this.f20709;
        c2892.f11243.setContentView(c2892.f11234);
        Context context = c2892.f11235;
        Window window = c2892.f11225;
        View viewFindViewById2 = window.findViewById(R.id._11_res_0x7f0b02f6);
        View viewFindViewById3 = viewFindViewById2.findViewById(R.id._11_res_0x7f0b03c4);
        View viewFindViewById4 = viewFindViewById2.findViewById(R.id._11_res_0x7f0b00f9);
        View viewFindViewById5 = viewFindViewById2.findViewById(R.id._11_res_0x7f0b00bb);
        ViewGroup viewGroup = (ViewGroup) viewFindViewById2.findViewById(R.id._11_res_0x7f0b0112);
        View view = c2892.f11222;
        if (view == null) {
            view = null;
        }
        boolean z = view != null;
        if (!z || !C2892.m7056(view)) {
            window.setFlags(131072, 131072);
        }
        if (z) {
            FrameLayout frameLayout = (FrameLayout) window.findViewById(R.id._11_res_0x7f0b0111);
            frameLayout.addView(view, new ViewGroup.LayoutParams(-1, -1));
            if (c2892.f11247) {
                frameLayout.setPadding(0, 0, 0, 0);
            }
            if (c2892.f11224 != null) {
                ((LinearLayout.LayoutParams) ((C1316) viewGroup.getLayoutParams())).weight = 0.0f;
            }
        } else {
            viewGroup.setVisibility(8);
        }
        View viewFindViewById6 = viewGroup.findViewById(R.id._11_res_0x7f0b03c4);
        View viewFindViewById7 = viewGroup.findViewById(R.id._11_res_0x7f0b00f9);
        View viewFindViewById8 = viewGroup.findViewById(R.id._11_res_0x7f0b00bb);
        ViewGroup viewGroupM7057 = C2892.m7057(viewFindViewById6, viewFindViewById3);
        ViewGroup viewGroupM70572 = C2892.m7057(viewFindViewById7, viewFindViewById4);
        ViewGroup viewGroupM70573 = C2892.m7057(viewFindViewById8, viewFindViewById5);
        NestedScrollView nestedScrollView = (NestedScrollView) window.findViewById(R.id._11_res_0x7f0b0346);
        c2892.f11245 = nestedScrollView;
        nestedScrollView.setFocusable(false);
        c2892.f11245.setNestedScrollingEnabled(false);
        TextView textView = (TextView) viewGroupM70572.findViewById(android.R.id.message);
        c2892.f11237 = textView;
        if (textView != null) {
            CharSequence charSequence = c2892.f11219;
            if (charSequence != null) {
                textView.setText(charSequence);
            } else {
                textView.setVisibility(8);
                c2892.f11245.removeView(c2892.f11237);
                if (c2892.f11224 != null) {
                    ViewGroup viewGroup2 = (ViewGroup) c2892.f11245.getParent();
                    int iIndexOfChild = viewGroup2.indexOfChild(c2892.f11245);
                    viewGroup2.removeViewAt(iIndexOfChild);
                    viewGroup2.addView(c2892.f11224, iIndexOfChild, new ViewGroup.LayoutParams(-1, -1));
                } else {
                    viewGroupM70572.setVisibility(8);
                }
            }
        }
        Button button = (Button) viewGroupM70573.findViewById(android.R.id.button1);
        c2892.f11228 = button;
        ViewOnClickListenerC4018 viewOnClickListenerC4018 = c2892.f11236;
        button.setOnClickListener(viewOnClickListenerC4018);
        boolean zIsEmpty = TextUtils.isEmpty(c2892.f11244);
        Button button2 = c2892.f11228;
        if (zIsEmpty) {
            button2.setVisibility(8);
            i = 0;
        } else {
            button2.setText(c2892.f11244);
            c2892.f11228.setVisibility(0);
            i = 1;
        }
        Button button3 = (Button) viewGroupM70573.findViewById(android.R.id.button2);
        c2892.f11221 = button3;
        button3.setOnClickListener(viewOnClickListenerC4018);
        boolean zIsEmpty2 = TextUtils.isEmpty(c2892.f11241);
        Button button4 = c2892.f11221;
        if (zIsEmpty2) {
            button4.setVisibility(8);
        } else {
            button4.setText(c2892.f11241);
            c2892.f11221.setVisibility(0);
            i |= 2;
        }
        Button button5 = (Button) viewGroupM70573.findViewById(android.R.id.button3);
        c2892.f11242 = button5;
        button5.setOnClickListener(viewOnClickListenerC4018);
        boolean zIsEmpty3 = TextUtils.isEmpty(c2892.f11220);
        Button button6 = c2892.f11242;
        if (zIsEmpty3) {
            button6.setVisibility(8);
        } else {
            button6.setText(c2892.f11220);
            c2892.f11242.setVisibility(0);
            i |= 4;
        }
        TypedValue typedValue = new TypedValue();
        context.getTheme().resolveAttribute(R.attr._11_res_0x7f040031, typedValue, true);
        if (typedValue.data != 0) {
            if (i == 1) {
                Button button7 = c2892.f11228;
                LinearLayout.LayoutParams layoutParams = (LinearLayout.LayoutParams) button7.getLayoutParams();
                layoutParams.gravity = 1;
                layoutParams.weight = 0.5f;
                button7.setLayoutParams(layoutParams);
            } else if (i == 2) {
                Button button8 = c2892.f11221;
                LinearLayout.LayoutParams layoutParams2 = (LinearLayout.LayoutParams) button8.getLayoutParams();
                layoutParams2.gravity = 1;
                layoutParams2.weight = 0.5f;
                button8.setLayoutParams(layoutParams2);
            } else if (i == 4) {
                Button button9 = c2892.f11242;
                LinearLayout.LayoutParams layoutParams3 = (LinearLayout.LayoutParams) button9.getLayoutParams();
                layoutParams3.gravity = 1;
                layoutParams3.weight = 0.5f;
                button9.setLayoutParams(layoutParams3);
            }
        }
        if (i == 0) {
            viewGroupM70573.setVisibility(8);
        }
        if (c2892.f11233 != null) {
            viewGroupM7057.addView(c2892.f11233, 0, new ViewGroup.LayoutParams(-1, -2));
            window.findViewById(R.id._11_res_0x7f0b03bf).setVisibility(8);
        } else {
            c2892.f11238 = (ImageView) window.findViewById(android.R.id.icon);
            if (TextUtils.isEmpty(c2892.f11248) || !c2892.f11223) {
                window.findViewById(R.id._11_res_0x7f0b03bf).setVisibility(8);
                c2892.f11238.setVisibility(8);
                viewGroupM7057.setVisibility(8);
            } else {
                TextView textView2 = (TextView) window.findViewById(R.id._11_res_0x7f0b0056);
                c2892.f11227 = textView2;
                textView2.setText(c2892.f11248);
                Drawable drawable = c2892.f11229;
                if (drawable != null) {
                    c2892.f11238.setImageDrawable(drawable);
                } else {
                    c2892.f11227.setPadding(c2892.f11238.getPaddingLeft(), c2892.f11238.getPaddingTop(), c2892.f11238.getPaddingRight(), c2892.f11238.getPaddingBottom());
                    c2892.f11238.setVisibility(8);
                }
            }
        }
        boolean z2 = viewGroup.getVisibility() != 8;
        int i2 = (viewGroupM7057 == null || viewGroupM7057.getVisibility() == 8) ? 0 : 1;
        boolean z3 = viewGroupM70573.getVisibility() != 8;
        if (!z3 && (viewFindViewById = viewGroupM70572.findViewById(R.id._11_res_0x7f0b03a8)) != null) {
            viewFindViewById.setVisibility(0);
        }
        if (i2 != 0) {
            NestedScrollView nestedScrollView2 = c2892.f11245;
            if (nestedScrollView2 != null) {
                nestedScrollView2.setClipToPadding(true);
            }
            View viewFindViewById9 = (c2892.f11219 == null && c2892.f11224 == null) ? null : viewGroupM7057.findViewById(R.id._11_res_0x7f0b03bc);
            if (viewFindViewById9 != null) {
                viewFindViewById9.setVisibility(0);
            }
        } else {
            View viewFindViewById10 = viewGroupM70572.findViewById(R.id._11_res_0x7f0b03a9);
            if (viewFindViewById10 != null) {
                viewFindViewById10.setVisibility(0);
            }
        }
        AlertController$RecycleListView alertController$RecycleListView = c2892.f11224;
        if (alertController$RecycleListView != null) {
            alertController$RecycleListView.getClass();
            if (!z3 || i2 == 0) {
                alertController$RecycleListView.setPadding(alertController$RecycleListView.getPaddingLeft(), i2 != 0 ? alertController$RecycleListView.getPaddingTop() : alertController$RecycleListView.f39, alertController$RecycleListView.getPaddingRight(), z3 ? alertController$RecycleListView.getPaddingBottom() : alertController$RecycleListView.f38);
            }
        }
        if (!z2) {
            View view2 = c2892.f11224;
            if (view2 == null) {
                view2 = c2892.f11245;
            }
            if (view2 != null) {
                int i3 = z3 ? 2 : 0;
                View viewFindViewById11 = window.findViewById(R.id._11_res_0x7f0b0345);
                View viewFindViewById12 = window.findViewById(R.id._11_res_0x7f0b0344);
                WeakHashMap weakHashMap = AbstractC2873.f11133;
                view2.setScrollIndicators(i2 | i3, 3);
                if (viewFindViewById11 != null) {
                    viewGroupM70572.removeView(viewFindViewById11);
                }
                if (viewFindViewById12 != null) {
                    viewGroupM70572.removeView(viewFindViewById12);
                }
            }
        }
        AlertController$RecycleListView alertController$RecycleListView2 = c2892.f11224;
        if (alertController$RecycleListView2 == null || (listAdapter = c2892.f11250) == null) {
            return;
        }
        alertController$RecycleListView2.setAdapter(listAdapter);
        int i4 = c2892.f11249;
        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.f20709.f11245;
        if (nestedScrollView == null || !nestedScrollView.m81(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.f20709.f11245;
        if (nestedScrollView == null || !nestedScrollView.m81(keyEvent)) {
            return super.onKeyUp(i, keyEvent);
        }
        return true;
    }

    @Override // defpackage.DialogC1493, android.app.Dialog
    public final void onStop() {
        super.onStop();
        LayoutInflaterFactory2C4211 layoutInflaterFactory2C4211 = (LayoutInflaterFactory2C4211) m11132();
        layoutInflaterFactory2C4211.m9166();
        C3966 c3966 = layoutInflaterFactory2C4211.f15763;
        if (c3966 != null) {
            c3966.f14968 = false;
            C2772 c2772 = c3966.f14963;
            if (c2772 != null) {
                c2772.m6844();
            }
        }
    }

    @Override // defpackage.DialogC1493, android.app.Dialog
    public final void setContentView(int i) {
        m4423();
        m11132().mo9091(i);
    }

    @Override // defpackage.DialogC1493, android.app.Dialog
    public final void setContentView(View view) {
        m4423();
        m11132().mo9090(view);
    }

    @Override // defpackage.DialogC1493, android.app.Dialog
    public final void setContentView(View view, ViewGroup.LayoutParams layoutParams) {
        m4423();
        m11132().mo9093(view, layoutParams);
    }

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

    @Override // android.app.Dialog
    public final void setTitle(CharSequence charSequence) {
        m11131(charSequence);
        C2892 c2892 = this.f20709;
        c2892.f11248 = charSequence;
        TextView textView = c2892.f11227;
        if (textView != null) {
            textView.setText(charSequence);
        }
        c2892.f11225.setTitle(charSequence);
    }

    /* renamed from: ˎˏʜʾ, reason: contains not printable characters */
    public final boolean m11130(KeyEvent keyEvent) {
        return super.dispatchKeyEvent(keyEvent);
    }

    /* renamed from: ˏˋٴ, reason: contains not printable characters */
    public final void m11131(CharSequence charSequence) {
        super.setTitle(charSequence);
        m11132().mo9095(charSequence);
    }

    /* renamed from: ˏᵙ, reason: contains not printable characters */
    public final AbstractC4175 m11132() {
        if (this.f20711 == null) {
            ExecutorC1145 executorC1145 = AbstractC4175.f15603;
            this.f20711 = new LayoutInflaterFactory2C4211(getContext(), getWindow(), this, this);
        }
        return this.f20711;
    }

    /* renamed from: ᵻᵢﹳᵰ, reason: contains not printable characters */
    public final void m11133(Bundle bundle) {
        LayoutInflaterFactory2C4211 layoutInflaterFactory2C4211 = (LayoutInflaterFactory2C4211) m11132();
        LayoutInflater layoutInflaterFrom = LayoutInflater.from(layoutInflaterFactory2C4211.f15779);
        if (layoutInflaterFrom.getFactory() == null) {
            layoutInflaterFrom.setFactory2(layoutInflaterFactory2C4211);
        } else {
            layoutInflaterFrom.getFactory2();
        }
        super.onCreate(bundle);
        m11132().mo9094();
    }
}
