package com.bytedance.android.livesdk.widget;

import X.0CB;
import X.0CH;
import X.0UO;
import X.0aP;
import X.6Is;
import X.C3023Glc;
import X.C3373GrG;
import X.C3705Gwc;
import X.C3807GyG;
import android.text.TextUtils;
import android.view.View;
import com.bytedance.android.live.base.model.feed.FeedExtra;
import com.bytedance.android.livesdk.chatroom.ui.LivePlayFragment;
import com.bytedance.android.livesdk.livesetting.watchlive.player.EnablePreDownloadLive;
import com.bytedance.android.livesdk.model.FeedItem;
import com.bytedance.android.livesdkapi.depend.model.live.Room;
import com.bytedance.android.livesdkapi.session.EnterRoomConfig;
import com.bytedance.covode.number.Covode;
import com.bytedance.ies.sdk.widgets.LiveRecyclableWidget;
import java.util.Objects;
import kotlin.h.b.n;
import org.json.JSONObject;

public final class RecommendButtonWidget extends LiveRecyclableWidget implements View.OnClickListener, 6Is {
    public LivePlayFragment LIZ;
    public View LIZIZ;
    public View LIZJ;
    public View LIZLLL;

    static {
        Covode.recordClassIndex(21668);
    }

    public final int getLayoutId() {
        return 2131562034;
    }

    public final void onLoad(Object[] objArr) {
    }

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

    public final void onUnload() {
    }

    public final void LIZ() {
        this.dataChannel.LIZJ(C3705Gwc.class, new C3373GrG(true));
    }

    public final void onInit(Object[] objArr) {
        View findViewById = findViewById(2131369337);
        n.LIZIZ(findViewById, "");
        this.LIZIZ = findViewById;
        View findViewById2 = findViewById(2131369348);
        n.LIZIZ(findViewById2, "");
        this.LIZJ = findViewById2;
        View findViewById3 = findViewById(2131369336);
        n.LIZIZ(findViewById3, "");
        this.LIZLLL = findViewById3;
        View view = this.LIZIZ;
        if (view == null) {
            n.LIZ("");
        }
        view.setOnClickListener(this);
        View view2 = this.LIZLLL;
        if (view2 == null) {
            n.LIZ("");
        }
        view2.setOnClickListener(this);
    }

    /* JADX WARNING: Code restructure failed: missing block: B:82:0x0164, code lost:
        if (r3 != null) goto L_0x00ed;
     */
    /* Code decompiled incorrectly, please refer to instructions dump. */
    public final void onClick(android.view.View r14) {
        /*
            r13 = this;
            r12 = 0
            if (r14 == 0) goto L_0x000d
            int r0 = r14.getId()
            java.lang.Integer r2 = java.lang.Integer.valueOf(r0)
            if (r2 != 0) goto L_0x000e
        L_0x000d:
            return
        L_0x000e:
            int r1 = r2.intValue()
            r0 = 2131369337(0x7f0a1d79, float:1.835865E38)
            if (r1 != r0) goto L_0x001e
            r13.hide()
            r13.LIZ()
            return
        L_0x001e:
            int r1 = r2.intValue()
            r0 = 2131369336(0x7f0a1d78, float:1.8358647E38)
            if (r1 != r0) goto L_0x00c0
            X.GsQ r0 = X.C3445GsQ.LJIILL
            java.lang.String r8 = "click"
            r0.LIZJ(r8)
            com.bytedance.android.livesdk.chatroom.ui.LivePlayFragment r0 = r13.LIZ
            if (r0 == 0) goto L_0x003b
            X.1hK r0 = r0.getActivity()
            if (r0 == 0) goto L_0x003b
            r0.finish()
        L_0x003b:
            java.util.ArrayList<com.bytedance.android.livesdk.model.FeedItem> r7 = X.C3445GsQ.LIZ
            com.bytedance.android.live.base.model.feed.FeedExtra r5 = X.C3445GsQ.LIZLLL
            java.lang.String r10 = X.C3445GsQ.LJFF
            long r0 = X.C3445GsQ.LJ
            boolean r2 = r7.isEmpty()
            java.lang.String r4 = ""
            if (r2 == 0) goto L_0x00c3
        L_0x004b:
            java.lang.String r5 = X.C3445GsQ.LJIIIIZZ
            java.lang.String r3 = X.C3445GsQ.LJIIIZ
            X.Gpb r0 = X.C3270Gpb.LJIILJJIL
            r0.LIZ((java.lang.String) r3, (java.lang.String) r5)
            com.bytedance.ies.sdk.datachannel.DataChannelGlobal r1 = com.bytedance.ies.sdk.datachannel.DataChannelGlobal.LIZLLL
            java.lang.Class<X.HEd> r0 = X.C4282HEd.class
            java.lang.Object r2 = r1.LIZIZ(r0)
            X.GqP r2 = (X.C3320GqP) r2
            if (r2 == 0) goto L_0x0064
            r2.LIZIZ = r5
            r2.LIZ = r3
        L_0x0064:
            com.bytedance.ies.sdk.datachannel.DataChannelGlobal r1 = com.bytedance.ies.sdk.datachannel.DataChannelGlobal.LIZLLL
            java.lang.Class<X.HEd> r0 = X.C4282HEd.class
            r1.LIZ(r0, r2)
            com.bytedance.ies.sdk.datachannel.DataChannelGlobal r1 = com.bytedance.ies.sdk.datachannel.DataChannelGlobal.LIZLLL
            java.lang.Class<X.HEY> r0 = X.HEY.class
            java.lang.Object r2 = r1.LIZIZ(r0)
            X.GqN r2 = (X.C3318GqN) r2
            if (r2 == 0) goto L_0x0083
            X.GqP r0 = r2.LJFF
            if (r0 == 0) goto L_0x007d
            r0.LIZIZ = r5
        L_0x007d:
            X.GqP r0 = r2.LJFF
            if (r0 == 0) goto L_0x0083
            r0.LIZ = r3
        L_0x0083:
            com.bytedance.ies.sdk.datachannel.DataChannelGlobal r1 = com.bytedance.ies.sdk.datachannel.DataChannelGlobal.LIZLLL
            java.lang.Class<X.HEY> r0 = X.HEY.class
            r1.LIZ(r0, r2)
            com.bytedance.ies.sdk.datachannel.DataChannel r1 = r13.dataChannel
            if (r1 == 0) goto L_0x00c1
            java.lang.Class<X.HGa> r0 = X.C4331HGa.class
            java.lang.Object r2 = r1.LIZIZ(r0)
            X.GqN r2 = (X.C3318GqN) r2
            if (r2 == 0) goto L_0x00a4
            X.GqP r0 = r2.LJFF
            if (r0 == 0) goto L_0x009e
            r0.LIZIZ = r5
        L_0x009e:
            X.GqP r0 = r2.LJFF
            if (r0 == 0) goto L_0x00a4
            r0.LIZ = r3
        L_0x00a4:
            com.bytedance.ies.sdk.datachannel.DataChannel r1 = r13.dataChannel
            if (r1 == 0) goto L_0x00ad
            java.lang.Class<X.HGa> r0 = X.C4331HGa.class
            r1.LIZ(r0, r2)
        L_0x00ad:
            java.util.ArrayList<com.bytedance.android.livesdk.model.FeedItem> r0 = X.C3445GsQ.LIZ
            r0.clear()
            X.C3445GsQ.LIZLLL = r12
            X.GsQ r0 = X.C3445GsQ.LJIILL
            r0.LIZ((java.lang.String) r4)
            r0 = 0
            X.C3445GsQ.LJ = r0
            r13.hide()
        L_0x00c0:
            return
        L_0x00c1:
            r2 = r12
            goto L_0x00a4
        L_0x00c3:
            r2 = 0
            java.lang.Object r11 = r7.get(r2)
            com.bytedance.android.livesdk.model.FeedItem r11 = (com.bytedance.android.livesdk.model.FeedItem) r11
            X.GyG r3 = r11.item
            boolean r3 = r3 instanceof com.bytedance.android.livesdkapi.depend.model.live.Room
            if (r3 == 0) goto L_0x0167
            com.bytedance.android.livesdkapi.session.EnterRoomConfig r3 = r13.LIZIZ(r11, r5)
        L_0x00d4:
            com.bytedance.android.livesdk.model.FlareInfo r6 = r11.flareInfo
            if (r6 == 0) goto L_0x0164
            if (r3 != 0) goto L_0x00dd
            kotlin.h.b.n.LIZIZ()
        L_0x00dd:
            com.bytedance.android.livesdkapi.session.EnterRoomConfig$RoomsData r9 = r3.LIZLLL
            com.bytedance.android.livesdk.model.FlareInfo r6 = r11.flareInfo
            boolean r6 = r6.isFlare
            r9.LJJIIJZLJL = r6
            com.bytedance.android.livesdkapi.session.EnterRoomConfig$RoomsData r9 = r3.LIZLLL
            com.bytedance.android.livesdk.model.FlareInfo r6 = r11.flareInfo
            java.lang.String r6 = r6.taskId
            r9.LJJIIZ = r6
        L_0x00ed:
            com.bytedance.android.livesdkapi.session.EnterRoomConfig$RoomsData r6 = r3.LIZLLL
            if (r6 == 0) goto L_0x00f3
            r6.LJJIIJ = r10
        L_0x00f3:
            r6 = 1
            if (r3 == 0) goto L_0x016e
            com.bytedance.android.livesdkapi.session.EnterRoomConfig$RoomsData r9 = r3.LIZLLL
            if (r9 == 0) goto L_0x00fc
            r9.LJJJJLI = r6
        L_0x00fc:
            com.bytedance.android.livesdkapi.session.EnterRoomConfig$LogData r9 = r3.LIZJ
            if (r9 == 0) goto L_0x0102
            r9.LJIL = r0
        L_0x0102:
            com.bytedance.android.livesdkapi.session.EnterRoomConfig$RoomsData r1 = r3.LIZLLL
            if (r1 == 0) goto L_0x010a
            java.lang.String r0 = "jump_source_recommend_end_at_follow_button_style"
            r1.LJLJI = r0
        L_0x010a:
            com.bytedance.android.livesdkapi.session.EnterRoomConfig$RoomsData r1 = r3.LIZLLL
            if (r1 == 0) goto L_0x0112
            java.lang.String r0 = X.C3445GsQ.LJIIIIZZ
            r1.LJJJJI = r0
        L_0x0112:
            com.bytedance.android.livesdkapi.session.EnterRoomConfig$RoomsData r1 = r3.LIZLLL
            if (r1 == 0) goto L_0x011a
            java.lang.String r0 = X.C3445GsQ.LJIIIZ
            r1.LJJJJJ = r0
        L_0x011a:
            com.bytedance.android.livesdkapi.session.EnterRoomConfig$RoomsData r0 = r3.LIZLLL
            if (r0 == 0) goto L_0x0120
            r0.LJJLIIIJJI = r8
        L_0x0120:
            java.lang.Class<com.bytedance.android.livesdkapi.host.IHostContext> r0 = com.bytedance.android.livesdkapi.host.IHostContext.class
            X.0UT r0 = X.0cm.LIZ(r0)
            kotlin.h.b.n.LIZIZ(r0, r4)
            com.bytedance.android.livesdkapi.host.IHostContext r0 = (com.bytedance.android.livesdkapi.host.IHostContext) r0
            boolean r0 = r0.isOffline()
            if (r0 == 0) goto L_0x016e
            java.util.HashMap r8 = new java.util.HashMap
            r8.<init>()
            int r9 = r7.size()
        L_0x013a:
            if (r2 >= r9) goto L_0x016a
            java.lang.Object r10 = r7.get(r2)
            com.bytedance.android.livesdk.model.FeedItem r10 = (com.bytedance.android.livesdk.model.FeedItem) r10
            java.lang.String r0 = r10.debugInfo
            boolean r0 = android.text.TextUtils.isEmpty(r0)
            if (r0 != 0) goto L_0x0161
            com.bytedance.android.livesdkapi.depend.model.live.Room r0 = r10.getRoom()
            kotlin.h.b.n.LIZIZ(r0, r4)
            long r0 = r0.getId()
            java.lang.Long r1 = java.lang.Long.valueOf(r0)
            java.lang.String r0 = r10.debugInfo
            kotlin.h.b.n.LIZIZ(r0, r4)
            r8.put(r1, r0)
        L_0x0161:
            int r2 = r2 + 1
            goto L_0x013a
        L_0x0164:
            if (r3 == 0) goto L_0x00f3
            goto L_0x00ed
        L_0x0167:
            r3 = r12
            goto L_0x00d4
        L_0x016a:
            com.bytedance.android.livesdkapi.session.EnterRoomConfig$RoomsData r0 = r3.LIZLLL
            r0.LJLL = r8
        L_0x016e:
            android.util.SparseArray r2 = new android.util.SparseArray
            int r0 = r7.size()
            r2.<init>(r0)
            int r1 = r7.size()
        L_0x017b:
            if (r6 >= r1) goto L_0x018f
            java.lang.Object r0 = r7.get(r6)
            com.bytedance.android.livesdk.model.FeedItem r0 = (com.bytedance.android.livesdk.model.FeedItem) r0
            com.bytedance.android.livesdkapi.session.EnterRoomConfig r0 = r13.LIZ(r0, r5)
            if (r0 == 0) goto L_0x018c
            r2.put(r6, r0)
        L_0x018c:
            int r6 = r6 + 1
            goto L_0x017b
        L_0x018f:
            if (r3 == 0) goto L_0x0197
            com.bytedance.android.livesdkapi.session.EnterRoomConfig$RoomsData r0 = r3.LIZLLL
            if (r0 == 0) goto L_0x0197
            r0.LJJIIZI = r2
        L_0x0197:
            if (r5 == 0) goto L_0x01b7
            if (r3 == 0) goto L_0x01b7
            com.bytedance.android.livesdkapi.session.EnterRoomConfig$RoomsData r1 = r3.LIZLLL
            if (r1 == 0) goto L_0x01a7
            boolean r0 = r5.hasMore
            java.lang.Boolean r0 = java.lang.Boolean.valueOf(r0)
            r1.LJJIFFI = r0
        L_0x01a7:
            com.bytedance.android.livesdkapi.session.EnterRoomConfig$RoomsData r2 = r3.LIZLLL
            if (r2 == 0) goto L_0x01af
            long r0 = r5.LIZLLL
            r2.LJJI = r0
        L_0x01af:
            com.bytedance.android.livesdkapi.session.EnterRoomConfig$RoomsData r1 = r3.LIZLLL
            if (r1 == 0) goto L_0x01b7
            java.lang.String r0 = r5.LIZIZ
            r1.LJJ = r0
        L_0x01b7:
            X.Glf r1 = X.GAX.LIZ
            kotlin.h.b.n.LIZIZ(r1, r4)
            com.bytedance.android.livesdkapi.session.EnterRoomLinkSession r0 = new com.bytedance.android.livesdkapi.session.EnterRoomLinkSession
            r0.<init>((com.bytedance.android.livesdkapi.session.EnterRoomConfig) r3)
            r1.LIZ((com.bytedance.android.livesdkapi.session.EnterRoomLinkSession) r0)
            if (r3 == 0) goto L_0x004b
            java.lang.Class<com.bytedance.android.livesdkapi.host.IHostStartLiveManager> r0 = com.bytedance.android.livesdkapi.host.IHostStartLiveManager.class
            X.0UT r1 = X.0cm.LIZ(r0)
            com.bytedance.android.livesdkapi.host.IHostStartLiveManager r1 = (com.bytedance.android.livesdkapi.host.IHostStartLiveManager) r1
            android.content.Context r0 = X.0b0.LJ()
            kotlin.h.b.n.LIZIZ(r0, r4)
            r1.LIZIZ(r0, r3)
            goto L_0x004b
        */
        throw new UnsupportedOperationException("Method not decompiled: com.bytedance.android.livesdk.widget.RecommendButtonWidget.onClick(android.view.View):void");
    }

    private final EnterRoomConfig LIZIZ(FeedItem feedItem, FeedExtra feedExtra) {
        String str = null;
        if (feedItem == null || !(feedItem.item instanceof Room)) {
            return null;
        }
        C3807GyG gyG = feedItem.item;
        Objects.requireNonNull(gyG, "null cannot be cast to non-null type com.bytedance.android.livesdkapi.depend.model.live.Room");
        EnterRoomConfig enterRoomConfig = new EnterRoomConfig();
        C3023Glc.LIZ((Room) gyG, enterRoomConfig);
        if (feedExtra != null) {
            try {
                enterRoomConfig.LIZJ.LJI = feedExtra.LIZ().toString();
                if (TextUtils.isEmpty(feedExtra.LJFF) && !TextUtils.isEmpty(feedExtra.LIZ().toString())) {
                    feedExtra.LJFF = new JSONObject(feedExtra.LIZ().toString()).getString("impr_id");
                }
                enterRoomConfig.LIZJ.LIZ = feedExtra.LJFF;
                EnterRoomConfig.RoomsData roomsData = enterRoomConfig.LIZLLL;
                if (feedItem.isRecommendCard) {
                    str = "pop_card";
                }
                roomsData.LJJLIIIJ = str;
            } catch (Exception e) {
                0aP.LIZ("RecommendButtonWidget", e);
            }
        }
        return enterRoomConfig;
    }

    private final EnterRoomConfig LIZ(FeedItem feedItem, FeedExtra feedExtra) {
        String str = null;
        if (feedItem == null || !(feedItem.item instanceof Room)) {
            return null;
        }
        C3807GyG gyG = feedItem.item;
        Objects.requireNonNull(gyG, "null cannot be cast to non-null type com.bytedance.android.livesdkapi.depend.model.live.Room");
        Room room = (Room) gyG;
        EnterRoomConfig LIZ2 = C3023Glc.LIZ(room, true);
        if (feedItem.flareInfo != null) {
            LIZ2.LIZLLL.LJJIIJZLJL = feedItem.flareInfo.isFlare;
            LIZ2.LIZLLL.LJJIIZ = feedItem.flareInfo.taskId;
        }
        if (EnablePreDownloadLive.INSTANCE.isEnable()) {
            LIZ2.LIZLLL.LIZIZ = room.getCommerceStruct();
            EnterRoomConfig.RoomsData roomsData = LIZ2.LIZLLL;
            String LIZIZ2 = 0UO.LIZIZ.LIZIZ(room);
            n.LIZIZ(LIZIZ2, "");
            roomsData.LIZ = LIZIZ2;
        }
        if (feedExtra != null) {
            try {
                LIZ2.LIZJ.LJI = feedExtra.LIZ().toString();
                if (TextUtils.isEmpty(feedExtra.LJFF) && !TextUtils.isEmpty(feedExtra.LIZ().toString())) {
                    feedExtra.LJFF = new JSONObject(feedExtra.LIZ().toString()).getString("impr_id");
                }
                LIZ2.LIZJ.LIZ = feedExtra.LJFF;
                EnterRoomConfig.RoomsData roomsData2 = LIZ2.LIZLLL;
                if (feedItem.isRecommendCard) {
                    str = "pop_card";
                }
                roomsData2.LJJLIIIJ = str;
            } catch (Exception e) {
                0aP.LIZ("NewFeedStyleEntranceUtils", e);
            }
        }
        return LIZ2;
    }
}
