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

import X.0HH;
import X.0VW;
import X.0Zq;
import X.0cm;
import X.13y;
import X.142;
import X.14D;
import X.154;
import X.158;
import X.1Mn;
import X.1ex;
import X.1hK;
import X.28M;
import X.2HN;
import X.C1064Fv7;
import X.C1430G2l;
import X.C1612G9l;
import X.C1856GIv;
import X.C1U;
import X.C2675Gg0;
import X.C4049H5e;
import X.C4307HFc;
import X.C4366HHj;
import X.DEF;
import X.GRR;
import X.GRS;
import X.GRT;
import X.GRU;
import X.GYM;
import X.HEP;
import X.Led;
import X.LsC;
import X.M12;
import X.Mk2;
import X.Mk3;
import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.os.SystemClock;
import android.view.LayoutInflater;
import android.view.MotionEvent;
import android.view.View;
import android.view.ViewGroup;
import androidx.fragment.app.Fragment;
import com.bytedance.android.live.base.model.user.User;
import com.bytedance.android.live.broadcast.api.IBroadcastService;
import com.bytedance.android.live.function.IRoomFunctionService;
import com.bytedance.android.live.gift.IGiftService;
import com.bytedance.android.live.share.IShareService;
import com.bytedance.android.live.toolbar.IToolbarService;
import com.bytedance.android.livesdk.chatroom.layer.GameLayeredElementManager;
import com.bytedance.android.livesdk.chatroom.widget.ScreenRecordStatusWidget;
import com.bytedance.android.livesdk.livesetting.broadcast.BroadcastInteractionLibraSetting;
import com.bytedance.android.livesdk.livesetting.broadcast.LiveEnableExtendedScreenSetting;
import com.bytedance.android.livesdk.model.message.RemindMessage;
import com.bytedance.android.livesdk.ui.BaseFragment;
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.LayeredWidgetManager;
import com.bytedance.ies.sdk.widgets.LiveRecyclableWidget;
import com.bytedance.ies.sdk.widgets.LiveWidgetProvider;
import com.bytedance.ies.sdk.widgets.RecyclableWidgetManager;
import com.bytedance.ies.sdk.widgets.WidgetCreateTimeUtil;
import java.util.ArrayList;
import java.util.HashMap;
import kotlin.h.b.n;

public final class GameBroadcastInteractionFragment extends BaseFragment implements 1ex, 142, C1U {
    public RecyclableWidgetManager LIZ;
    public int LIZIZ = -1;
    public ScreenRecordStatusWidget LIZJ;
    public DataChannel LIZLLL;
    public 13y LJ;
    public final WidgetCreateTimeUtil LJFF = new WidgetCreateTimeUtil((LsC) null, 1, (2HN) null);
    public 0VW LJI;
    public Room LJII;
    public 14D LJIIIIZZ;
    public LiveRecyclableWidget LJIIIZ;
    public Runnable LJIIJ;
    public HashMap LJIIJJI;

    static {
        Covode.recordClassIndex(13945);
    }

    private View LIZIZ(int i) {
        if (this.LJIIJJI == null) {
            this.LJIIJJI = new HashMap();
        }
        View view = (View) this.LJIIJJI.get(Integer.valueOf(i));
        if (view != null) {
            return view;
        }
        View view2 = getView();
        if (view2 == null) {
            return null;
        }
        View findViewById = view2.findViewById(i);
        this.LJIIJJI.put(Integer.valueOf(i), findViewById);
        return findViewById;
    }

    public final Fragment LIZIZ() {
        return this;
    }

    public final void LIZLLL() {
        LIZ(this.LJIIJ);
    }

    public final void LIZ() {
        13y r1 = this.LJ;
        if (r1 == null) {
            n.LIZ("");
        }
        r1.LIZIZ();
    }

    public final void LJ() {
        0VW r1 = this.LJI;
        if (r1 == null) {
            n.LIZ("");
        }
        r1.LIZIZ();
    }

    public final boolean LJIIIIZZ() {
        13y r1 = this.LJ;
        if (r1 == null) {
            n.LIZ("");
        }
        return r1.LJIIIIZZ();
    }

    public final void onDestroy() {
        super.onDestroy();
        13y r1 = this.LJ;
        if (r1 == null) {
            n.LIZ("");
        }
        r1.LIZLLL();
    }

    private final void LJI() {
        C1612G9l g9l = (C1612G9l) LIZIZ(2131367422);
        n.LIZIZ(g9l, "");
        g9l.setVisibility(0);
    }

    private final void LJII() {
        C1612G9l g9l = (C1612G9l) LIZIZ(2131367422);
        n.LIZIZ(g9l, "");
        g9l.setVisibility(8);
    }

    private final void LJIIIZ() {
        ScreenRecordStatusWidget screenRecordStatusWidget = this.LIZJ;
        if (screenRecordStatusWidget != null) {
            screenRecordStatusWidget.LIZ(true);
        } else {
            C1430G2l.LIZIZ(LIZIZ(2131367229));
        }
    }

    private final void LJIIJ() {
        ScreenRecordStatusWidget screenRecordStatusWidget = this.LIZJ;
        if (screenRecordStatusWidget != null) {
            screenRecordStatusWidget.LIZ(false);
        } else {
            C1430G2l.LIZ(LIZIZ(2131367229));
        }
    }

    public final void onDestroyView() {
        super.onDestroyView();
        0VW r0 = this.LJI;
        if (r0 == null) {
            n.LIZ("");
        }
        r0.LIZJ();
        13y r02 = this.LJ;
        if (r02 == null) {
            n.LIZ("");
        }
        r02.LIZJ();
        this.LJIIJ = null;
        HashMap hashMap = this.LJIIJJI;
        if (hashMap != null) {
            hashMap.clear();
        }
    }

    public final void LJFF() {
        1hK activity = getActivity();
        if (activity != null) {
            158 r5 = 158.SHARE;
            DataChannel dataChannel = this.LIZLLL;
            if (dataChannel == null) {
                n.LIZ("");
            }
            154 shareBehavior = 0cm.LIZ(IShareService.class).getShareBehavior(activity, getContext(), C1856GIv.SCREEN_RECORD, this);
            n.LIZIZ(shareBehavior, "");
            r5.load(dataChannel, shareBehavior);
        }
        IBroadcastService LIZ2 = 0cm.LIZ(IBroadcastService.class);
        DataChannel dataChannel2 = this.LIZLLL;
        if (dataChannel2 == null) {
            n.LIZ("");
        }
        LIZ2.loadPauseLiveButton(dataChannel2);
        IRoomFunctionService LIZ3 = 0cm.LIZ(IRoomFunctionService.class);
        DataChannel dataChannel3 = this.LIZLLL;
        if (dataChannel3 == null) {
            n.LIZ("");
        }
        LIZ3.loadCustomPollBehavior(dataChannel3);
    }

    public final void LIZJ() {
        Boolean bool;
        User owner;
        0Zq customPollManager;
        long j;
        this.LIZJ = new ScreenRecordStatusWidget();
        RecyclableWidgetManager recyclableWidgetManager = this.LIZ;
        if (recyclableWidgetManager == null) {
            n.LIZ("");
        }
        recyclableWidgetManager.load(2131367229, this.LIZJ);
        RecyclableWidgetManager recyclableWidgetManager2 = this.LIZ;
        if (recyclableWidgetManager2 == null) {
            n.LIZ("");
        }
        recyclableWidgetManager2.load(2131368373, 0cm.LIZ(IBroadcastService.class).createPauseLiveWidget(LIZIZ(2131368370)));
        RecyclableWidgetManager recyclableWidgetManager3 = this.LIZ;
        if (recyclableWidgetManager3 == null) {
            n.LIZ("");
        }
        Class broadcastToolbarWidget = 0cm.LIZ(IToolbarService.class).broadcastToolbarWidget();
        Object[] objArr = new Object[1];
        ArrayList arrayList = new ArrayList();
        arrayList.add(158.SLOT);
        Room room = (Room) DataChannelGlobal.LIZLLL.LIZIZ(HEP.class);
        IRoomFunctionService LIZ2 = 0cm.LIZ(IRoomFunctionService.class);
        Room room2 = null;
        if (LIZ2 == null || (customPollManager = LIZ2.getCustomPollManager()) == null) {
            bool = null;
        } else {
            DataChannel dataChannel = this.LIZLLL;
            if (dataChannel == null) {
                n.LIZ("");
            }
            Room room3 = (Room) dataChannel.LIZIZ(C1064Fv7.class);
            if (room3 != null) {
                j = room3.getId();
            } else {
                j = 0;
            }
            bool = Boolean.valueOf(customPollManager.LIZ(j));
        }
        if (C1430G2l.LIZ(bool)) {
            arrayList.add(158.CUSTOM_POLL);
        }
        if (room == null || (owner = room.getOwner()) == null || owner.getSecret() != 1) {
            arrayList.add(158.SHARE);
        }
        arrayList.add(158.MORE);
        objArr[0] = arrayList;
        recyclableWidgetManager3.load(2131371330, broadcastToolbarWidget, false, Led.LIZ(objArr, new GYM(SystemClock.elapsedRealtime())));
        if (BroadcastInteractionLibraSetting.INSTANCE.isExperimentGroup()) {
            this.LJIIIZ = 0cm.LIZ(IBroadcastService.class).createNetSpeedMonitorWidget(true);
            RecyclableWidgetManager recyclableWidgetManager4 = this.LIZ;
            if (recyclableWidgetManager4 == null) {
                n.LIZ("");
            }
            recyclableWidgetManager4.load(2131367965, this.LJIIIZ);
        }
        LiveEnableExtendedScreenSetting liveEnableExtendedScreenSetting = LiveEnableExtendedScreenSetting.INSTANCE;
        DataChannel dataChannel2 = this.LIZLLL;
        if (dataChannel2 == null) {
            n.LIZ("");
        } else {
            room2 = (Room) dataChannel2.LIZIZ(C1064Fv7.class);
        }
        if (liveEnableExtendedScreenSetting.showTopInfo(room2) && this.LJIIIZ == null) {
            this.LJIIIZ = 0cm.LIZ(IBroadcastService.class).createNetSpeedMonitorWidget(true);
            RecyclableWidgetManager recyclableWidgetManager5 = this.LIZ;
            if (recyclableWidgetManager5 == null) {
                n.LIZ("");
            }
            recyclableWidgetManager5.load(2131367965, this.LJIIIZ);
        }
    }

    public final void LIZ(RemindMessage remindMessage) {
        M12.LIZ(remindMessage);
        M12.LIZ(remindMessage);
    }

    public final boolean LIZIZ(MotionEvent motionEvent) {
        M12.LIZ(motionEvent);
        M12.LIZ(motionEvent);
        return false;
    }

    public final void onActivityCreated(Bundle bundle) {
        GameBroadcastInteractionFragment.super.onActivityCreated(bundle);
        13y r1 = this.LJ;
        if (r1 == null) {
            n.LIZ("");
        }
        r1.LIZ();
    }

    public final void LIZ(int i) {
        DataChannel dataChannel = this.LIZLLL;
        if (dataChannel == null) {
            n.LIZ("");
        }
        dataChannel.LIZIZ(28M.class, Integer.valueOf(i));
    }

    public final void onEvent(GRT grt) {
        int i = grt.LIZ;
        if (i == 0) {
            LJIIJ();
            LJI();
        } else if (i == 1) {
            LJII();
            LJIIIZ();
        }
    }

    public final void LIZ(Runnable runnable) {
        if (getView() == null || runnable == null) {
            this.LJIIJ = runnable;
            return;
        }
        this.LJIIJ = null;
        View view = getView();
        if (view != null) {
            view.post(new GRS(runnable));
        }
    }

    public final boolean LIZ(MotionEvent motionEvent) {
        M12.LIZ(motionEvent);
        M12.LIZ(motionEvent);
        return false;
    }

    public final void LIZ(DataChannel dataChannel, 14D r4) {
        M12.LIZ(dataChannel, r4);
        this.LIZLLL = dataChannel;
        this.LJIIIIZZ = r4;
        Object LIZIZ2 = dataChannel.LIZIZ(C1064Fv7.class);
        if (LIZIZ2 == null) {
            n.LIZIZ();
        }
        this.LJII = (Room) LIZIZ2;
        dataChannel.LIZ(C4307HFc.class, C1856GIv.SCREEN_RECORD);
    }

    /* JADX WARNING: type inference failed for: r9v0, types: [com.bytedance.android.livesdk.chatroom.layer.GameLayeredElementManager, com.bytedance.ies.sdk.widgets.LayeredElementManager] */
    public final void onViewCreated(View view, Bundle bundle) {
        View view2 = view;
        M12.LIZ(view2);
        super.onViewCreated(view2, bundle);
        0cm.LIZ(IGiftService.class).initGiftResourceManager(getContext());
        Context context = getContext();
        C4049H5e h5e = (C4049H5e) view2;
        DataChannel dataChannel = this.LIZLLL;
        if (dataChannel == null) {
            n.LIZ("");
        }
        ? gameLayeredElementManager = new GameLayeredElementManager(context, this, h5e, dataChannel);
        this.LIZ = LayeredWidgetManager.Companion.of(this, view2, false, LiveWidgetProvider.Companion.getInstance(), 1Mn.LIZ, gameLayeredElementManager);
        int i = GRU.LIZ;
        this.LIZIZ = i;
        if (i == 1) {
            LJII();
            LJIIIZ();
        } else {
            LJIIJ();
            LJI();
        }
        ((C4366HHj) C2675Gg0.LIZ().LIZ(GRT.class).LIZ(Mk2.LIZ(Mk3.LIZ)).LIZ(DEF.LIZ(this))).LIZ(new GRR(this));
        IBroadcastService LIZ2 = 0cm.LIZ(IBroadcastService.class);
        Context context2 = getContext();
        RecyclableWidgetManager recyclableWidgetManager = this.LIZ;
        if (recyclableWidgetManager == null) {
            n.LIZ("");
        }
        13y createCommonInteractionFunctionHelper = LIZ2.createCommonInteractionFunctionHelper(context2, this, this, view2, recyclableWidgetManager);
        DataChannel dataChannel2 = this.LIZLLL;
        if (dataChannel2 == null) {
            n.LIZ("");
        }
        14D r0 = this.LJIIIIZZ;
        if (r0 == null) {
            n.LIZ("");
        }
        createCommonInteractionFunctionHelper.LIZ(dataChannel2, r0);
        createCommonInteractionFunctionHelper.LIZ(view2);
        n.LIZIZ(createCommonInteractionFunctionHelper, "");
        this.LJ = createCommonInteractionFunctionHelper;
        IBroadcastService LIZ3 = 0cm.LIZ(IBroadcastService.class);
        Room room = this.LJII;
        if (room == null) {
            n.LIZ("");
        }
        Context context3 = getContext();
        DataChannel dataChannel3 = this.LIZLLL;
        if (dataChannel3 == null) {
            n.LIZ("");
        }
        0VW createLongPressHelper = LIZ3.createLongPressHelper(room, this, view2, context3, dataChannel3);
        createLongPressHelper.LIZ();
        n.LIZIZ(createLongPressHelper, "");
        this.LJI = createLongPressHelper;
    }

    public final boolean LIZ(MotionEvent motionEvent, MotionEvent motionEvent2) {
        M12.LIZ(motionEvent, motionEvent2);
        M12.LIZ(motionEvent, motionEvent2);
        return false;
    }

    public final void onActivityResult(int i, int i2, Intent intent) {
        GameBroadcastInteractionFragment.super.onActivityResult(i, i2, intent);
        13y r1 = this.LJ;
        if (r1 == null) {
            n.LIZ("");
        }
        r1.LIZ(i, i2, intent);
    }

    public final View onCreateView(LayoutInflater layoutInflater, ViewGroup viewGroup, Bundle bundle) {
        M12.LIZ(layoutInflater);
        return 0HH.LIZ(layoutInflater, 2131561736, viewGroup, false);
    }

    public final boolean LIZ(MotionEvent motionEvent, MotionEvent motionEvent2, float f) {
        M12.LIZ(motionEvent, motionEvent2);
        M12.LIZ(motionEvent, motionEvent2);
        return false;
    }
}
