package com.bytedance.android.live.design.app;

import X.6Is;
import X.AnonymousClass0CB;
import X.AnonymousClass0CH;
import X.AnonymousClass1MM;
import X.C013905h;
import X.C022408o;
import X.C11180cu;
import X.C11200cw;
import X.C11240d0;
import X.C11250d1;
import X.C11260d2;
import X.C11280d4;
import X.C11300d6;
import X.C11310d7;
import X.C11320d8;
import X.C11360dC;
import X.C11630dd;
import X.C31161Lu;
import X.C40901jk;
import X.C46301sS;
import X.C46321sU;
import android.content.Context;
import android.content.res.ColorStateList;
import android.graphics.drawable.Drawable;
import android.os.Build;
import android.os.Bundle;
import android.text.TextUtils;
import android.text.method.LinkMovementMethod;
import android.view.View;
import android.view.ViewGroup;
import android.view.Window;
import android.widget.FrameLayout;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.TextView;
import com.bytedance.covode.number.Covode;
import com.bytedance.frameworks.apm.trace.MethodCollector;
import java.util.Collections;
import java.util.List;

public class LiveDialog extends LifecycleAwareDialog implements 6Is {
    public View LIZ;
    public View LIZIZ;
    public AnonymousClass1MM LIZJ;
    public ImageView LIZLLL;
    public ImageView LJ;
    public TextView LJFF;
    public View LJI;
    public FrameLayout LJII;
    public C40901jk LJIIIIZZ;
    public ImageView LJIIIZ;
    public FrameLayout LJIIJ;
    public C11180cu LJIIJJI;
    public FrameLayout LJIIL;
    public boolean LJIILIIL;
    public CharSequence LJIILJJIL;
    public CharSequence LJIILL;
    public View LJIILLIIL;
    public C11360dC LJIIZILJ;
    public boolean LJIJ;
    public ColorStateList LJIJI;
    public int LJIJJ;
    public int LJIJJLI;
    public int LJIL;
    public int LJJ;
    public int LJJI;
    public boolean LJJIFFI;
    public float LJJII;
    public boolean LJJIII;
    public boolean LJJIIJ;
    public ColorStateList LJJIIJZLJL;
    public C11240d0 LJJIIZ;
    public C11250d1 LJJIIZI;
    public C11300d6 LJJIJ;
    public LinearLayout LJJIJIIJI;

    static {
        Covode.recordClassIndex(5693);
    }

    public void onStateChanged(AnonymousClass0CH r1, AnonymousClass0CB r2) {
        super.onStateChanged(r1, r2);
    }

    public void onDetachedFromWindow() {
        super.onDetachedFromWindow();
    }

    private void LIZIZ() {
        ImageView imageView = this.LJ;
        if (imageView != null) {
            C013905h r2 = (C013905h) imageView.getLayoutParams();
            if (this.LJJIFFI) {
                r2.height = this.LJJI;
                r2.dimensionRatio = null;
            } else if (this.LJJIII) {
                r2.height = 0;
                r2.dimensionRatio = "w, " + this.LJJII;
            } else {
                r2.height = -2;
                r2.dimensionRatio = null;
            }
            this.LJ.setLayoutParams(r2);
        }
    }

    private void LIZJ() {
        MethodCollector.i(9821);
        List<T> unmodifiableList = Collections.unmodifiableList(this.LJJIJ.LIZ);
        int size = unmodifiableList.size();
        for (int i = 0; i < size; i++) {
            C11280d4 r1 = (C11280d4) unmodifiableList.get(i);
            C46321sU r3 = new C46321sU(getContext());
            r3.LIZ(r1.LIZIZ);
            if (r1.LIZJ != null) {
                r3.setOnClickListener(new C11320d8(this, r1));
            }
            r3.setText(r1.LIZ);
            r3.setEnabled(r1.LIZLLL);
            LinearLayout.LayoutParams layoutParams = new LinearLayout.LayoutParams(-1, -2);
            if (i > 0) {
                layoutParams.topMargin = getContext().getResources().getDimensionPixelSize(2131165745);
            }
            r3.setLayoutParams(layoutParams);
            this.LJJIJIIJI.addView(r3);
        }
        if (size > 1) {
            LinearLayout linearLayout = this.LJJIJIIJI;
            linearLayout.setPadding(linearLayout.getPaddingLeft(), this.LJJIJIIJI.getPaddingTop(), this.LJJIJIIJI.getPaddingRight(), getContext().getResources().getDimensionPixelSize(2131165779));
            MethodCollector.o(9821);
            return;
        }
        LinearLayout linearLayout2 = this.LJJIJIIJI;
        linearLayout2.setPadding(linearLayout2.getPaddingLeft(), this.LJJIJIIJI.getPaddingTop(), this.LJJIJIIJI.getPaddingRight(), getContext().getResources().getDimensionPixelSize(2131165755));
        MethodCollector.o(9821);
    }

    private void LIZ(boolean z) {
        this.LJIJ = z;
        AnonymousClass1MM r0 = this.LIZJ;
        if (r0 != null) {
            r0.setIconAutoMirrored(z);
        }
    }

    public void setTitle(int i) {
        setTitle((CharSequence) getContext().getResources().getString(i));
    }

    public final void LIZ(int i) {
        LIZ(C11630dd.LIZ.LIZ(getContext(), i));
        LIZ(C11630dd.LIZ.LIZ(i));
    }

    public void setCanceledOnTouchOutside(boolean z) {
        super.setCanceledOnTouchOutside(z);
        this.LJIILIIL = z;
        View view = this.LIZ;
        if (view == null) {
            return;
        }
        if (z) {
            view.setOnClickListener(new C11260d2(this));
        } else {
            view.setOnClickListener((View.OnClickListener) null);
        }
    }

    private void LIZ(Drawable drawable) {
        if (drawable != null) {
            LIZJ((Drawable) null);
            LIZLLL((Drawable) null);
            this.LJIIZILJ = null;
            this.LJIIZILJ = new C11360dC(drawable, 1);
            AnonymousClass1MM r1 = this.LIZJ;
            if (r1 != null) {
                r1.setIconAutoMirrored(this.LJIJ);
                this.LIZJ.setIconTintList(this.LJIJI);
            }
            LIZIZ(drawable);
        }
    }

    private void LIZJ(Drawable drawable) {
        ImageView imageView = this.LIZLLL;
        if (imageView != null && this.LIZIZ != null) {
            if (drawable == null) {
                imageView.setImageDrawable((Drawable) null);
                this.LIZLLL.setVisibility(8);
                this.LIZIZ.setVisibility(8);
                return;
            }
            imageView.setImageDrawable(drawable);
            this.LIZLLL.setVisibility(0);
            this.LIZIZ.setVisibility(0);
        }
    }

    private void LIZLLL(Drawable drawable) {
        ImageView imageView = this.LJ;
        if (imageView != null && this.LIZIZ != null) {
            if (drawable == null) {
                imageView.setImageDrawable((Drawable) null);
                this.LJ.setVisibility(8);
                this.LIZIZ.setVisibility(8);
                return;
            }
            imageView.setImageDrawable(drawable);
            this.LJ.setVisibility(0);
            this.LIZIZ.setVisibility(0);
        }
    }

    public void setTitle(CharSequence charSequence) {
        this.LJIILJJIL = charSequence;
        if (this.LJFF != null) {
            if (TextUtils.isEmpty(charSequence)) {
                this.LJFF.setText("");
                this.LJFF.setVisibility(8);
            } else {
                this.LJFF.setText(this.LJIILJJIL);
                this.LJFF.setVisibility(0);
            }
        }
        LIZ(this.LJIILL, this.LJIILLIIL);
    }

    private void LIZIZ(Drawable drawable) {
        AnonymousClass1MM r1 = this.LIZJ;
        if (r1 != null && this.LIZIZ != null) {
            if (drawable == null) {
                r1.setImageDrawable((Drawable) null);
                this.LIZJ.setVisibility(8);
                this.LIZIZ.setVisibility(8);
                return;
            }
            r1.setImageDrawable(drawable);
            this.LIZJ.setVisibility(0);
            this.LIZIZ.setVisibility(0);
        }
    }

    public final void LIZ(C11180cu r6) {
        MethodCollector.i(9208);
        this.LJIIJJI = r6;
        FrameLayout frameLayout = this.LJIIJ;
        if (frameLayout != null) {
            frameLayout.removeAllViews();
            C11180cu r3 = this.LJIIJJI;
            if (r3 != null) {
                View LIZ2 = r3.LIZ(getContext(), this.LJIIJ);
                if (LIZ2 != null) {
                    ViewGroup.LayoutParams layoutParams = LIZ2.getLayoutParams();
                    if (layoutParams == null) {
                        layoutParams = new FrameLayout.LayoutParams(-1, -2);
                    } else if (!(layoutParams instanceof FrameLayout.LayoutParams)) {
                        layoutParams = new FrameLayout.LayoutParams(layoutParams);
                    }
                    this.LJIIJ.addView(LIZ2, layoutParams);
                    this.LJIIJ.setVisibility(0);
                    MethodCollector.o(9208);
                    return;
                }
                this.LJIIJ.setVisibility(8);
                MethodCollector.o(9208);
                return;
            }
            this.LJIIJ.setVisibility(8);
        }
        MethodCollector.o(9208);
    }

    private void LIZ(C11240d0 r7) {
        MethodCollector.i(9817);
        if (this.LJJIIZ == null && r7 == null) {
            MethodCollector.o(9817);
            return;
        }
        this.LJJIJ = null;
        this.LJJIIZ = r7;
        FrameLayout frameLayout = this.LJIIL;
        if (frameLayout != null) {
            frameLayout.removeAllViews();
            if (this.LJJIIZ != null) {
                if (this.LJJIIZI == null) {
                    this.LJJIIZI = new C11250d1(getContext());
                }
                List<T> unmodifiableList = Collections.unmodifiableList(this.LJJIIZ.LIZ);
                this.LJJIIZI.removeAllViews();
                if (unmodifiableList != null && !unmodifiableList.isEmpty()) {
                    for (T t : unmodifiableList) {
                        C46301sS r2 = new C46301sS(getContext());
                        r2.LIZ.LIZ(t.LIZIZ);
                        r2.setText(t.LIZ);
                        if (t.LIZJ != null) {
                            r2.setOnClickListener(new C11310d7(this, t));
                        }
                        r2.setEnabled(t.LIZLLL);
                        t.LJ = r2;
                        if (!(t.LJFF == null || t.LJ == null)) {
                            t.LJ.setTextColor(t.LJFF);
                        }
                        this.LJJIIZI.addView(r2);
                    }
                }
                this.LJJIIZI.requestLayout();
                this.LJJIIZI.setOrientation(this.LJJIIZ.LIZIZ);
                this.LJIIL.addView(this.LJJIIZI, -1, -2);
                MethodCollector.o(9817);
                return;
            }
            C11250d1 r0 = this.LJJIIZI;
            if (r0 != null) {
                r0.removeAllViews();
            }
        }
        MethodCollector.o(9817);
    }

    public void onCreate(Bundle bundle) {
        MethodCollector.i(5841);
        super.onCreate(bundle);
        Window window = getWindow();
        if (window != null) {
            window.setStatusBarColor(0);
            window.setNavigationBarColor(0);
            window.addFlags(Integer.MIN_VALUE);
            if (Build.VERSION.SDK_INT < 23) {
                window.addFlags(67108864);
                window.addFlags(134217728);
            }
            window.getDecorView().setSystemUiVisibility(512);
            window.setLayout(-1, -1);
        }
        setContentView(View.inflate(getContext(), 2131560559, (ViewGroup) null), new ViewGroup.LayoutParams(-1, -1));
        this.LIZ = findViewById(2131367187);
        setCanceledOnTouchOutside(this.LJIILIIL);
        this.LIZIZ = findViewById(2131367181);
        this.LIZJ = (AnonymousClass1MM) findViewById(2131367179);
        this.LIZLLL = (ImageView) findViewById(2131367180);
        this.LJ = (ImageView) findViewById(2131367178);
        C11360dC r0 = this.LJIIZILJ;
        if (!(r0 == null || r0.LIZ == null)) {
            if (this.LJIIZILJ.LIZIZ == 1) {
                LIZ(this.LJIIZILJ.LIZ);
                LIZ(this.LJIJ);
                ColorStateList colorStateList = this.LJIJI;
                AnonymousClass1MM r02 = this.LIZJ;
                if (r02 != null) {
                    r02.setIconTintList(colorStateList);
                }
                int i = this.LJIJJ;
                this.LJIJJ = i;
                AnonymousClass1MM r03 = this.LIZJ;
                if (r03 != null) {
                    ViewGroup.LayoutParams layoutParams = r03.getLayoutParams();
                    layoutParams.width = i;
                    this.LIZJ.setLayoutParams(layoutParams);
                }
                int i2 = this.LJIJJLI;
                this.LJIJJLI = i2;
                AnonymousClass1MM r04 = this.LIZJ;
                if (r04 != null) {
                    ViewGroup.LayoutParams layoutParams2 = r04.getLayoutParams();
                    layoutParams2.height = i2;
                    this.LIZJ.setLayoutParams(layoutParams2);
                }
            } else if (this.LJIIZILJ.LIZIZ == 2) {
                Drawable drawable = this.LJIIZILJ.LIZ;
                int i3 = this.LJIL;
                int i4 = this.LJJ;
                if (!(this.LJIIZILJ == null && drawable == null)) {
                    LIZIZ((Drawable) null);
                    LIZLLL((Drawable) null);
                    this.LJIIZILJ = null;
                    C11360dC r05 = new C11360dC(drawable, 2);
                    this.LJIIZILJ = r05;
                    LIZJ(r05.LIZ);
                    this.LJIL = i3;
                    this.LJJ = i4;
                    ImageView imageView = this.LIZLLL;
                    if (imageView != null) {
                        ViewGroup.LayoutParams layoutParams3 = imageView.getLayoutParams();
                        layoutParams3.width = this.LJIL;
                        layoutParams3.height = this.LJJ;
                        this.LIZLLL.setLayoutParams(layoutParams3);
                    }
                }
            } else if (this.LJIIZILJ.LIZIZ == 3) {
                if (this.LJJIFFI) {
                    Drawable drawable2 = this.LJIIZILJ.LIZ;
                    int i5 = this.LJJI;
                    if (!(this.LJIIZILJ == null && drawable2 == null)) {
                        LIZIZ((Drawable) null);
                        LIZJ((Drawable) null);
                        this.LJIIZILJ = null;
                        C11360dC r06 = new C11360dC(drawable2, 3);
                        this.LJIIZILJ = r06;
                        LIZLLL(r06.LIZ);
                        this.LJJI = i5;
                        this.LJJIFFI = true;
                        this.LJJIII = false;
                        LIZIZ();
                    }
                } else if (this.LJJIII) {
                    Drawable drawable3 = this.LJIIZILJ.LIZ;
                    float f = this.LJJII;
                    if (!(this.LJIIZILJ == null && drawable3 == null)) {
                        LIZIZ((Drawable) null);
                        LIZJ((Drawable) null);
                        this.LJIIZILJ = null;
                        C11360dC r07 = new C11360dC(drawable3, 3);
                        this.LJIIZILJ = r07;
                        LIZLLL(r07.LIZ);
                        this.LJJII = f;
                        this.LJJIII = true;
                        this.LJJIFFI = false;
                        LIZIZ();
                    }
                }
            }
        }
        this.LJFF = (TextView) findViewById(2131367186);
        setTitle(this.LJIILJJIL);
        this.LJI = findViewById(2131367184);
        this.LJII = (FrameLayout) findViewById(2131367183);
        C40901jk r1 = (C40901jk) findViewById(2131367185);
        this.LJIIIIZZ = r1;
        r1.setMovementMethod(LinkMovementMethod.getInstance());
        LIZ(this.LJIILL, this.LJIILLIIL);
        ImageView imageView2 = (ImageView) findViewById(2131367176);
        this.LJIIIZ = imageView2;
        imageView2.setOnClickListener(new C11200cw(this));
        boolean z = this.LJJIIJ;
        this.LJJIIJ = z;
        ImageView imageView3 = this.LJIIIZ;
        if (imageView3 != null) {
            if (z) {
                imageView3.setVisibility(0);
            } else {
                imageView3.setVisibility(8);
            }
        }
        ColorStateList colorStateList2 = this.LJJIIJZLJL;
        this.LJJIIJZLJL = colorStateList2;
        ImageView imageView4 = this.LJIIIZ;
        if (imageView4 != null) {
            C022408o.LIZ(imageView4, colorStateList2);
        }
        this.LJIIJ = (FrameLayout) findViewById(2131367174);
        LIZ(this.LJIIJJI);
        this.LJIIL = (FrameLayout) findViewById(2131367175);
        LIZ(this.LJJIIZ);
        C11300d6 r08 = this.LJJIJ;
        if (r08 != null) {
            this.LJJIIZ = null;
            this.LJJIJ = r08;
            FrameLayout frameLayout = this.LJIIL;
            if (frameLayout != null) {
                frameLayout.removeAllViews();
                if (this.LJJIJ != null) {
                    LinearLayout linearLayout = this.LJJIJIIJI;
                    if (linearLayout == null) {
                        LinearLayout linearLayout2 = new LinearLayout(getContext());
                        linearLayout2.setOrientation(1);
                        FrameLayout.LayoutParams layoutParams4 = new FrameLayout.LayoutParams(-1, -2);
                        layoutParams4.topMargin = getContext().getResources().getDimensionPixelSize(2131165744);
                        int dimensionPixelSize = getContext().getResources().getDimensionPixelSize(2131165776);
                        layoutParams4.rightMargin = dimensionPixelSize;
                        layoutParams4.leftMargin = dimensionPixelSize;
                        linearLayout2.setLayoutParams(layoutParams4);
                        this.LJJIJIIJI = linearLayout2;
                    } else {
                        linearLayout.removeAllViews();
                    }
                    LIZJ();
                    this.LJIIL.addView(this.LJJIJIIJI);
                    MethodCollector.o(5841);
                    return;
                }
                this.LJJIJIIJI.removeAllViews();
            }
        }
        MethodCollector.o(5841);
    }

    public LiveDialog(Context context, C31161Lu r3) {
        super(context, r3);
        this.LJIIZILJ = r3.LJFF;
        this.LJIJ = r3.LJII;
        this.LJIJI = r3.LJI;
        this.LJIJJ = r3.LJIIIIZZ;
        this.LJIJJLI = r3.LJIIIZ;
        this.LJIL = r3.LJIIJ;
        this.LJJ = r3.LJIIJJI;
        this.LJJI = r3.LJIIL;
        this.LJJII = r3.LJIILJJIL;
        this.LJJIFFI = r3.LJIILIIL;
        this.LJJIII = r3.LJIILL;
        this.LJIILJJIL = r3.LIZJ;
        this.LJIILL = r3.LJ;
        this.LJIILLIIL = r3.LIZLLL;
        this.LJJIIJ = r3.LJIILLIIL;
        this.LJJIIJZLJL = r3.LJIIZILJ;
        this.LJIIJJI = r3.LJJI;
        setOnShowListener(r3.LJIJJ);
        setOnCancelListener(r3.LJIL);
        setOnDismissListener(r3.LJIJJLI);
        setOnKeyListener(r3.LJJ);
        setCancelable(r3.LJIJI);
        setCanceledOnTouchOutside(r3.LJIJ);
        this.LJJIIZ = r3.LJJIFFI;
        this.LJJIJ = r3.LJJII;
    }

    private void LIZ(CharSequence charSequence, View view) {
        FrameLayout frameLayout;
        MethodCollector.i(9206);
        if (this.LJI == null || this.LJIIIIZZ == null || (frameLayout = this.LJII) == null) {
            MethodCollector.o(9206);
            return;
        }
        View view2 = this.LJIILLIIL;
        if (view2 != null) {
            frameLayout.removeView(view2);
        }
        this.LJIILL = charSequence;
        this.LJIILLIIL = view;
        if (!TextUtils.isEmpty(charSequence)) {
            this.LJIIIIZZ.setText(this.LJIILL);
            if (TextUtils.isEmpty(this.LJIILJJIL)) {
                this.LJIIIIZZ.LIZ(2131886888);
            } else {
                this.LJIIIIZZ.LIZ(2131886891);
            }
            this.LJIIIIZZ.setVisibility(0);
            this.LJI.setVisibility(0);
            MethodCollector.o(9206);
            return;
        }
        View view3 = this.LJIILLIIL;
        if (view3 != null) {
            this.LJII.addView(view3, -1, -2);
            this.LJIIIIZZ.setText("");
            this.LJIIIIZZ.setVisibility(8);
            this.LJI.setVisibility(0);
            MethodCollector.o(9206);
            return;
        }
        this.LJIIIIZZ.setText("");
        this.LJIIIIZZ.setVisibility(8);
        this.LJI.setVisibility(8);
        MethodCollector.o(9206);
    }

    public /* synthetic */ LiveDialog(Context context, C31161Lu r2, byte b) {
        this(context, r2);
    }
}
