package com.bytedance.android.livesdk.hashtag;

import X.0AA;
import X.0CB;
import X.0CH;
import X.6Is;
import X.C1064Fv7;
import X.C2675Gg0;
import X.G08;
import X.G0I;
import X.G94;
import X.G95;
import X.G96;
import X.G97;
import X.HES;
import X.HFP;
import X.M12;
import android.view.View;
import android.widget.ImageView;
import android.widget.TextView;
import com.bytedance.android.livesdk.model.Hashtag;
import com.bytedance.android.livesdkapi.depend.model.live.Room;
import com.bytedance.covode.number.Covode;
import com.bytedance.ies.sdk.datachannel.DataChannel;
import com.bytedance.ies.sdk.datachannel.DataChannelGlobal;
import com.bytedance.ies.sdk.widgets.widgetloadpriority.RoomRecycleWidget;
import kotlin.h.b.n;

public abstract class BaseHashTagWidget extends RoomRecycleWidget implements 6Is {
    public TextView LIZ;
    public ImageView LIZIZ;
    public boolean LIZJ;
    public long LIZLLL;

    static {
        Covode.recordClassIndex(16778);
    }

    public abstract void LIZ();

    public abstract void LIZ(0AA r1);

    public abstract void LIZ(Hashtag hashtag);

    public abstract void LIZIZ();

    public int getLayoutId() {
        return 2131561793;
    }

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

    public void onUnload() {
        super.onUnload();
        DataChannel dataChannel = this.dataChannel;
        if (dataChannel != null) {
            dataChannel.LIZIZ((Object) this);
        }
    }

    private final void LIZLLL() {
        Hashtag hashtag;
        Room room = (Room) this.dataChannel.LIZIZ(C1064Fv7.class);
        Long l = null;
        if (room == null || (hashtag = room.hashtag) == null) {
            hide();
            return;
        }
        Hashtag hashtag2 = (Hashtag) this.dataChannel.LIZIZ(G08.class);
        this.dataChannel.LIZIZ(G08.class, hashtag);
        DataChannelGlobal.LIZLLL.LIZ(HES.class, hashtag);
        Long l2 = hashtag.id;
        if (hashtag2 != null) {
            l = hashtag2.id;
        }
        if (n.LIZ(l2, l)) {
            LIZ(hashtag);
        }
    }

    public final void LIZJ() {
        Hashtag hashtag = (Hashtag) this.dataChannel.LIZIZ(G08.class);
        if (hashtag == null) {
            return;
        }
        if (!G0I.LIZ(hashtag) || !n.LIZ(this.dataChannel.LIZIZ(HFP.class), true) || this.LIZJ) {
            if (isShowing()) {
                hide();
            }
        } else if (!isShowing()) {
            show();
            LIZIZ();
        }
    }

    public void onGetRoomInfo(Room room) {
        super.onGetRoomInfo(room);
        LIZLLL();
    }

    public void onInit(Object[] objArr) {
        View findViewById = findViewById(2131371021);
        n.LIZIZ(findViewById, "");
        this.LIZ = (TextView) findViewById;
        View findViewById2 = findViewById(2131371016);
        n.LIZIZ(findViewById2, "");
        this.LIZIZ = (ImageView) findViewById2;
        View view = getView();
        if (view != null) {
            view.setOnClickListener(new G95(this));
        }
    }

    public void onLoad(Object[] objArr) {
        super.onLoad(objArr);
        hide();
        C2675Gg0.LIZ().LIZIZ(this, G97.class).LIZ(new G96(this));
        this.dataChannel.LIZ((Object) this, G08.class, new G94(this));
        LIZLLL();
    }

    public final void LIZIZ(Hashtag hashtag) {
        M12.LIZ(hashtag);
        if (G0I.LIZ(hashtag)) {
            TextView textView = this.LIZ;
            if (textView == null) {
                n.LIZ("");
            }
            textView.setText(hashtag.title);
        } else {
            hide();
        }
        if (!G0I.LIZ(hashtag) || !hashtag.isUseGameTagAsHashTag()) {
            ImageView imageView = this.LIZIZ;
            if (imageView == null) {
                n.LIZ("");
            }
            imageView.setImageResource(2131234591);
        } else {
            ImageView imageView2 = this.LIZIZ;
            if (imageView2 == null) {
                n.LIZ("");
            }
            imageView2.setImageResource(2131234590);
        }
        LIZJ();
    }
}
