package com.bytedance.android.livesdk.broadcast.preview.widget;

import X.0CB;
import X.0CH;
import X.0aP;
import X.0b0;
import X.1jk;
import X.2sR;
import X.6Is;
import X.7vl;
import X.C1088FvV;
import X.C1313Fz8;
import X.C1365Fzy;
import X.C1379G0m;
import X.C1380G0n;
import X.C1381G0o;
import X.C1781GFy;
import X.C3491GtA;
import X.Crj;
import X.G06;
import X.M12;
import android.view.View;
import android.widget.ImageView;
import com.bytedance.android.livesdk.broadcast.preview.base.PreviewToolBaseWidget;
import com.bytedance.android.livesdk.livesetting.broadcast.BroadcastInteractionLibraSetting;
import com.bytedance.android.livesdk.model.GameTag;
import com.bytedance.covode.number.Covode;
import com.bytedance.ies.sdk.datachannel.DataChannel;
import kotlin.h.b.n;

public final class PreviewChangeOrientationWidget extends PreviewToolBaseWidget implements 6Is {
    public static final C1381G0o LIZLLL = new C1381G0o((byte) 0);
    public boolean LIZIZ;
    public GameTag LIZJ;
    public final Crj LJ;
    public final int LJFF;
    public final int LJI;

    static {
        Covode.recordClassIndex(12265);
    }

    public final void onStateChanged(0CH r1, 0CB r2) {
        super.onStateChanged(r1, r2);
    }

    public final int LIZ() {
        return this.LJFF;
    }

    public final int LIZIZ() {
        return this.LJI;
    }

    public PreviewChangeOrientationWidget() {
        boolean z;
        2sR<Boolean> r1 = C1781GFy.LLIL;
        n.LIZIZ(r1, "");
        Boolean bool = (Boolean) r1.LIZ();
        if (bool != null) {
            z = bool.booleanValue();
        } else {
            z = false;
        }
        this.LIZIZ = z;
        this.LJ = 7vl.LIZ(new C1380G0n(this));
        this.LJFF = 2131830227;
        this.LJI = 2131234227;
    }

    public final void onCreate() {
        super.onCreate();
        LJ();
        if (BroadcastInteractionLibraSetting.INSTANCE.isExperimentGroup()) {
            this.LIZJ = G06.LIZJ.LIZIZ();
            0aP.LIZ(4, "PreviewChangeOrientationWidget", "onCreate() selectGameTag = " + this.LIZJ);
            DataChannel dataChannel = this.dataChannel;
            if (dataChannel != null) {
                dataChannel.LIZIZ((0CH) this, C1365Fzy.class, new C1379G0m(this));
            }
        }
    }

    public final void LJ() {
        1jk findViewById;
        ImageView imageView;
        1jk findViewById2;
        ImageView imageView2;
        if (this.LIZIZ) {
            View view = getView();
            if (!(view == null || (imageView2 = (ImageView) view.findViewById(2131373121)) == null)) {
                imageView2.setImageResource(2131234227);
            }
            View view2 = getView();
            if (!(view2 == null || (findViewById2 = view2.findViewById(2131373124)) == null)) {
                findViewById2.setText(2131830228);
            }
        } else {
            View view3 = getView();
            if (!(view3 == null || (imageView = (ImageView) view3.findViewById(2131373121)) == null)) {
                imageView.setImageResource(2131234228);
            }
            View view4 = getView();
            if (!(view4 == null || (findViewById = view4.findViewById(2131373124)) == null)) {
                findViewById.setText(2131830230);
            }
        }
        2sR<Boolean> r1 = C1781GFy.LLIL;
        n.LIZIZ(r1, "");
        r1.LIZ(Boolean.valueOf(this.LIZIZ));
        DataChannel dataChannel = this.dataChannel;
        if (dataChannel != null) {
            dataChannel.LIZIZ(C1088FvV.class, Boolean.valueOf(this.LIZIZ));
        }
    }

    public final void LIZ(View view) {
        int i;
        int i2;
        GameTag gameTag;
        Integer valueOf;
        M12.LIZ(view);
        if (!BroadcastInteractionLibraSetting.INSTANCE.isExperimentGroup()) {
            boolean z = !this.LIZIZ;
            this.LIZIZ = z;
            LIZ(z, true);
            LJ();
            if (this.LIZIZ) {
                i = 2131830229;
            } else {
                i = 2131830231;
            }
            C1313Fz8.LIZ(0b0.LJ(), i);
        } else if (!((Boolean) this.LJ.getValue()).booleanValue() || (gameTag = this.LIZJ) == null || gameTag.landscape == 0) {
            boolean z2 = !this.LIZIZ;
            this.LIZIZ = z2;
            LIZ(z2, true);
            LJ();
            if (this.LIZIZ) {
                i2 = 2131828832;
            } else {
                i2 = 2131828841;
            }
            C1313Fz8.LIZ(0b0.LJ(), i2);
        } else {
            GameTag gameTag2 = this.LIZJ;
            if (gameTag2 != null && (valueOf = Integer.valueOf(gameTag2.landscape)) != null) {
                if (valueOf.intValue() == 1) {
                    C1313Fz8.LIZ(0b0.LJ(), 2131828833);
                } else if (valueOf.intValue() == 2) {
                    C1313Fz8.LIZ(0b0.LJ(), 2131828842);
                }
            }
        }
    }

    public final void LIZ(boolean z, boolean z2) {
        String str;
        String str2;
        C3491GtA LIZ = C3491GtA.LJFF.LIZ("livesdk_live_takepage_orientation_click");
        LIZ.LIZ(this.dataChannel);
        if (z) {
            str = "landscape";
        } else {
            str = "portrait";
        }
        LIZ.LIZ("action_result", str);
        if (z2) {
            str2 = "click";
        } else {
            str2 = "auto";
        }
        LIZ.LIZ("action_type", str2);
        LIZ.LIZLLL();
    }
}
