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

import X.0CB;
import X.0CH;
import X.0yx;
import X.15V;
import X.2cN;
import X.3Vj;
import X.6Is;
import X.C1064Fv7;
import X.C2424Gbx;
import X.C2425Gby;
import X.C2426Gbz;
import X.C2427Gc0;
import X.C2428Gc1;
import X.C2429Gc2;
import X.C2675Gg0;
import X.C6455Hzs;
import X.CwZ;
import X.Cwu;
import X.G97;
import X.GM2;
import X.LWw;
import X.M12;
import X.Mjy;
import android.view.View;
import android.widget.TextView;
import com.bytedance.android.livesdk.chatroom.api.DecorationApi;
import com.bytedance.android.livesdk.model.OrganizationModel;
import com.bytedance.android.livesdk.model.RoomDecoration;
import com.bytedance.android.livesdk.model.message.DonationInfoMessage;
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.widgets.LiveRecyclableWidget;

public final class DonationStickerAnchorWidget extends LiveRecyclableWidget implements C2427Gc0, 6Is {
    public RoomDecoration LIZ;
    public final Mjy LIZIZ = new Mjy();
    public C2428Gc1 LIZJ;
    public TextView LIZLLL;
    public TextView LJ;
    public TextView LJFF;
    public View LJI;
    public 2cN LJII;

    static {
        Covode.recordClassIndex(14541);
    }

    public final void LIZ(Throwable th) {
        C2429Gc2.LIZ(this, th);
    }

    public final int getLayoutId() {
        return 2131562037;
    }

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

    public final String LJIIL() {
        return getClass().getName();
    }

    public final void onUnload() {
        this.LIZ = null;
        C2428Gc1 gc1 = this.LIZJ;
        if (gc1 != null) {
            gc1.f_();
        }
        this.LIZIZ.LIZ();
        2cN r0 = this.LJII;
        if (r0 != null) {
            r0.dispose();
        }
    }

    public final void LIZ(DonationInfoMessage donationInfoMessage) {
        M12.LIZ(donationInfoMessage);
        LIZ(donationInfoMessage.LIZJ, donationInfoMessage.LIZ, donationInfoMessage.LIZIZ);
    }

    public final void onInit(Object[] objArr) {
        this.LIZLLL = (TextView) findViewById(2131369711);
        this.LJ = (TextView) findViewById(2131369712);
        this.LJFF = (TextView) findViewById(2131369709);
        this.LJI = findViewById(2131369713);
    }

    public final void onLoad(Object[] objArr) {
        int i;
        hide();
        if (15V.LIZ(getContext())) {
            i = 8388629;
        } else {
            i = 8388627;
        }
        TextView textView = this.LIZLLL;
        if (textView != null) {
            textView.setGravity(i);
        }
        TextView textView2 = this.LJ;
        if (textView2 != null) {
            textView2.setGravity(i);
        }
        C2428Gc1 gc1 = new C2428Gc1();
        this.LIZJ = gc1;
        gc1.LIZ((C2427Gc0) this);
        this.LIZIZ.LIZ(C2675Gg0.LIZ().LIZ(G97.class).LIZ(getAutoUnbindTransformer()).LIZLLL(new C2426Gbz(this)));
        View view = getView();
        if (view != null) {
            view.setOnClickListener(new GM2(this));
        }
    }

    public final void onEvent(G97 g97) {
        Room room;
        String str;
        OrganizationModel organizationModel = null;
        if (g97 != null && g97.LIZ != null) {
            if (g97.LIZIZ) {
                show();
                RoomDecoration roomDecoration = this.LIZ;
                if (roomDecoration == null || roomDecoration.LJIIL != g97.LIZ.LJIIL) {
                    RoomDecoration roomDecoration2 = g97.LIZ;
                    this.LIZ = roomDecoration2;
                    if (roomDecoration2 != null) {
                        organizationModel = roomDecoration2.LIZ();
                    }
                    TextView textView = this.LIZLLL;
                    if (textView != null) {
                        if (organizationModel == null || (str = organizationModel.LIZ) == null) {
                            str = "";
                        }
                        textView.setText(str);
                    }
                    TextView textView2 = this.LJFF;
                    if (textView2 != null) {
                        textView2.setVisibility(8);
                    }
                    TextView textView3 = this.LJ;
                    if (textView3 != null) {
                        textView3.setVisibility(8);
                    }
                    View view = this.LJI;
                    if (view != null) {
                        view.setVisibility(8);
                    }
                    2cN r0 = this.LJII;
                    if (r0 != null) {
                        r0.dispose();
                    }
                    DataChannel dataChannel = this.dataChannel;
                    if (dataChannel != null && (room = (Room) dataChannel.LIZIZ(C1064Fv7.class)) != null) {
                        this.LJII = ((DecorationApi) 0yx.LIZ().LIZ(DecorationApi.class)).getRoomDonationInfo(LWw.LIZ(new Cwu[]{CwZ.LIZ("room_id", Long.valueOf(room.getId())), CwZ.LIZ("anchor_id", Long.valueOf(room.getOwnerUserId())), CwZ.LIZ("donation_entrance", 1L)})).LIZ(new C6455Hzs()).LIZ(new C2424Gbx(this), C2425Gby.LIZ);
                        return;
                    }
                    return;
                }
                return;
            }
            2cN r02 = this.LJII;
            if (r02 != null) {
                r02.dispose();
            }
            hide();
        }
    }

    public final void LIZ(String str, String str2, long j) {
        if (this.LIZ != null && isShowing()) {
            2cN r0 = this.LJII;
            if (r0 != null) {
                r0.dispose();
            }
            TextView textView = this.LJFF;
            if (textView != null) {
                textView.setVisibility(0);
            }
            TextView textView2 = this.LJ;
            if (textView2 != null) {
                textView2.setVisibility(0);
            }
            View view = this.LJI;
            if (view != null) {
                view.setVisibility(0);
            }
            TextView textView3 = this.LIZLLL;
            if (textView3 != null) {
                StringBuilder sb = new StringBuilder();
                if (str == null) {
                    str = "";
                }
                sb.append(str);
                if (str2 == null) {
                    str2 = "";
                }
                sb.append(str2);
                textView3.setText(sb);
            }
            TextView textView4 = this.LJ;
            if (textView4 != null) {
                textView4.setText(3Vj.LIZ(j));
            }
        }
    }
}
