package com.bytedance.android.livesdk.chatroom.widget;

import X.0CB;
import X.0CH;
import X.0cm;
import X.1jk;
import X.6Is;
import X.7AW;
import X.C1198FxH;
import X.C1393G1a;
import X.C1661GBi;
import X.C1664GBl;
import X.C1665GBm;
import X.C1666GBn;
import X.C1856GIv;
import X.C4307HFc;
import X.GBU;
import X.HFX;
import X.HFY;
import android.os.Handler;
import android.os.Looper;
import android.view.View;
import com.bytedance.android.live.definition.IDefinitionService;
import com.bytedance.android.livesdk.livesetting.watchlive.EnableCacheLastSelectDefinitionSetting;
import com.bytedance.covode.number.Covode;
import com.bytedance.ies.sdk.datachannel.DataChannel;
import com.bytedance.ies.sdk.widgets.LiveRecyclableWidget;
import java.util.Objects;
import kotlin.h.b.n;

public final class SwitchDefinitionTipsWidget extends LiveRecyclableWidget implements 6Is {
    public static long LJFF;
    public static final C1666GBn LJI = new C1666GBn((byte) 0);
    public Handler LIZ;
    public boolean LIZIZ;
    public GBU LIZJ;
    public Runnable LIZLLL;
    public boolean LJ;

    static {
        Covode.recordClassIndex(14704);
    }

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

    public final int getLayoutId() {
        if (EnableCacheLastSelectDefinitionSetting.INSTANCE.isEnableAutoTips()) {
            return 2131562239;
        }
        return 2131562238;
    }

    public SwitchDefinitionTipsWidget() {
        Looper myLooper = Looper.myLooper();
        if (myLooper == null) {
            n.LIZIZ();
        }
        this.LIZ = new Handler(myLooper);
        this.LIZIZ = true;
        this.LIZLLL = new C1664GBl(this);
    }

    public final void hide() {
        super.hide();
        DataChannel dataChannel = this.dataChannel;
        if (dataChannel != null) {
            dataChannel.LIZIZ(C1198FxH.class, false);
        }
    }

    public final void onUnload() {
        GBU gbu = this.LIZJ;
        if (gbu != null) {
            this.LIZ.removeCallbacks(gbu);
        }
        this.LIZ.removeCallbacks(this.LIZLLL);
    }

    public final void show() {
        String str;
        String str2;
        C1856GIv gIv;
        Long l;
        super.show();
        DataChannel dataChannel = this.dataChannel;
        String str3 = "";
        if (dataChannel == null || (l = (Long) dataChannel.LIZIZ(HFY.class)) == null || (str = String.valueOf(l.longValue())) == null) {
            str = str3;
        }
        DataChannel dataChannel2 = this.dataChannel;
        if (!(dataChannel2 == null || (gIv = (C1856GIv) dataChannel2.LIZIZ(C4307HFc.class)) == null)) {
            str3 = C1393G1a.LIZ(gIv);
        }
        boolean z = this.LIZIZ;
        if (z) {
            str2 = "0";
        } else if (!z) {
            str2 = "1";
        } else {
            throw new 7AW();
        }
        IDefinitionService LIZ2 = 0cm.LIZ(IDefinitionService.class);
        if (LIZ2 != null) {
            LIZ2.reportAudienceDefinitionTipsShow(str, str3, str2);
        }
        LJFF = System.currentTimeMillis();
        DataChannel dataChannel3 = this.dataChannel;
        if (dataChannel3 != null) {
            dataChannel3.LIZIZ(C1198FxH.class, true);
        }
        this.LIZ.postDelayed(this.LIZLLL, 5000);
    }

    public final void onLoad(Object[] objArr) {
        boolean z;
        Boolean bool;
        DataChannel dataChannel = this.dataChannel;
        if (dataChannel == null || (bool = (Boolean) dataChannel.LIZIZ(HFX.class)) == null) {
            z = true;
        } else {
            z = bool.booleanValue();
        }
        this.LIZIZ = z;
    }

    public final void onInit(Object[] objArr) {
        int i;
        View view;
        if (!(objArr == null || objArr.length == 0 || !(objArr[0] instanceof Boolean))) {
            Boolean bool = objArr[0];
            Objects.requireNonNull(bool, "null cannot be cast to non-null type kotlin.Boolean");
            this.LJ = bool.booleanValue();
        }
        if (EnableCacheLastSelectDefinitionSetting.INSTANCE.isEnableAutoTips()) {
            i = 2131363044;
        } else {
            i = 2131363043;
        }
        1jk findViewById = findViewById(i);
        findViewById.setOnClickListener(new C1661GBi(this));
        if (EnableCacheLastSelectDefinitionSetting.INSTANCE.isEnableAutoTips() && (view = getView()) != null) {
            view.setOnClickListener(new C1665GBm(findViewById));
        }
    }
}
