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

import X.0CH;
import X.0HH;
import X.0cm;
import X.1Mn;
import X.29X;
import X.29n;
import X.2Pr;
import X.2cN;
import X.C1183Fx2;
import X.C1670GBr;
import X.C1671GBs;
import X.C1675GBw;
import X.C1781GFy;
import X.C2435Gc8;
import X.C2436Gc9;
import X.C2447GcK;
import X.C2489Gd0;
import X.C2675Gg0;
import X.C3394Grb;
import X.C3491GtA;
import X.C4049H5e;
import X.C4366HHj;
import X.DEF;
import X.GC3;
import X.GCF;
import X.GCG;
import X.GCH;
import X.GCI;
import X.GCJ;
import X.GCK;
import X.GCL;
import X.GCM;
import X.GCN;
import X.GCO;
import X.GCP;
import X.GCR;
import X.GXG;
import X.M12;
import X.Mk2;
import X.Mk3;
import X.PgU;
import X.PhE;
import X.PlI;
import android.os.Bundle;
import android.util.SparseBooleanArray;
import android.view.LayoutInflater;
import android.view.MotionEvent;
import android.view.View;
import android.view.ViewGroup;
import com.bytedance.android.live.share.IShareService;
import com.bytedance.android.livesdk.chatroom.ui.landscape.LandscapeLayeredElementManager;
import com.bytedance.android.livesdk.chatroom.widget.DefinitionSelectionWidget;
import com.bytedance.android.livesdk.chatroom.widget.LiveTopShareWidget;
import com.bytedance.android.livesdk.chatroom.widget.LockScreenWidget;
import com.bytedance.android.livesdk.chatroom.widget.MessageBlockWidget;
import com.bytedance.android.livesdk.chatroom.widget.OrientationChangeWidget;
import com.bytedance.android.livesdk.chatroom.widget.SwitchDefinitionTipsWidget;
import com.bytedance.android.livesdk.livesetting.watchlive.LiveUnionPraiseGiftInToolBarSetting;
import com.bytedance.android.livesdk.livesetting.watchlive.ShowAudienceDefinitionSelectionSetting;
import com.bytedance.covode.number.Covode;
import com.bytedance.ies.sdk.datachannel.DataChannel;
import com.bytedance.ies.sdk.widgets.LayeredWidgetManager;
import com.bytedance.ies.sdk.widgets.LiveWidgetProvider;
import com.bytedance.ies.sdk.widgets.RecyclableWidgetManager;
import java.util.HashMap;
import java.util.Map;
import java.util.concurrent.TimeUnit;

public class LandscapeAudienceInteractionFragment extends AbsAudienceInteractionFragment {
    public boolean LJJIIZ;
    public boolean LJJIIZI = ((Boolean) C1781GFy.LLIZ.LIZ()).booleanValue();
    public View LJJIJ;
    public long LJJIJIIJI;
    public 2cN LJJIJIIJIL;
    public boolean LJJIJIL;
    public SwitchDefinitionTipsWidget LJJIJL;

    static {
        Covode.recordClassIndex(13951);
    }

    public final boolean LJFF() {
        return false;
    }

    public final boolean LIZLLL() {
        LJJIJLIJ();
        return true;
    }

    public void onPause() {
        LJJIJL();
        super.onPause();
    }

    public final void LJJIJL() {
        2cN r0 = this.LJJIJIIJIL;
        if (r0 != null && !r0.isDisposed()) {
            this.LJJIJIIJIL.dispose();
        }
    }

    public final void LIZIZ() {
        super.LIZIZ();
        ((C4366HHj) C2675Gg0.LIZ().LIZ(C1671GBs.class).LIZ(DEF.LIZ(this))).LIZ(new C1670GBr(this));
    }

    public final void LJJIJLIJ() {
        boolean z = !this.LJJIIZ;
        this.LJJIIZ = z;
        if (!z) {
            LIZ();
        } else {
            LJJIJL();
        }
        LIZIZ(0);
    }

    public void onResume() {
        LIZ();
        LIZIZ(1);
        View view = this.LJJIJ;
        if (view != null) {
            view.postDelayed(new GCI(this), 300);
        }
        super.onResume();
    }

    public final void LIZ() {
        LJJIJL();
        this.LJJIJIIJIL = PgU.LIZIZ(5000, TimeUnit.MILLISECONDS).LIZIZ(PhE.LIZIZ(PlI.LIZJ)).LIZ(Mk2.LIZ(Mk3.LIZ)).LIZ(new GCO(this), GCR.LIZ);
    }

    public final RecyclableWidgetManager LIZJ() {
        return LayeredWidgetManager.Companion.of(this, this.LIZIZ, false, LiveWidgetProvider.getInstance(), 1Mn.LIZ, new LandscapeLayeredElementManager(getContext(), this, (C4049H5e) getView().findViewById(2131368358), this.LJII));
    }

    public final /* synthetic */ 2Pr LJJIL() {
        String str;
        this.LJJIJIL = !this.LJJIJIL;
        LIZ();
        LIZIZ(2);
        DataChannel dataChannel = this.LJII;
        boolean z = this.LJJIJIL;
        C3491GtA LIZ = C3491GtA.LJFF.LIZ("livesdk_lock_screen_click");
        LIZ.LIZ(dataChannel);
        if (z) {
            str = "lock";
        } else {
            str = "unlock";
        }
        LIZ.LIZ("purpose", str);
        LIZ.LIZLLL();
        return 2Pr.LIZ;
    }

    public void onDestroy() {
        LJJIJL();
        super.onDestroy();
        HashMap hashMap = new HashMap();
        hashMap.put("room_orientation", "landscape");
        hashMap.put("duration", String.valueOf(System.currentTimeMillis() - this.LJJIJIIJI));
        C3491GtA LIZ = C3491GtA.LJFF.LIZ("livesdk_transverse_screen_duration");
        LIZ.LIZ((Map<String, String>) hashMap);
        LIZ.LIZJ("live");
        LIZ.LIZLLL("click");
        LIZ.LJ("live_landscape");
        LIZ.LIZ(this.LJII);
        LIZ.LIZLLL();
    }

    public final Boolean LIZ(int i) {
        boolean z = true;
        if (i != 1 || this.LJJIJIL) {
            z = false;
        }
        return Boolean.valueOf(z);
    }

    public final /* synthetic */ void LIZ(C3394Grb grb) {
        if (isViewValid() && grb.LIZIZ == 3) {
            this.LJII.LIZJ(29X.class);
        }
    }

    public final void LIZIZ(int i) {
        SparseBooleanArray sparseBooleanArray = new SparseBooleanArray(3);
        boolean z = false;
        sparseBooleanArray.put(0, this.LJJIIZ);
        sparseBooleanArray.put(1, this.LJJIIZI);
        sparseBooleanArray.put(2, this.LJJIJIL);
        C1671GBs gBs = new C1671GBs();
        gBs.LIZ = sparseBooleanArray;
        gBs.LIZIZ = i;
        if (i == 1 && this.LJJIIZI) {
            z = true;
        }
        gBs.LIZJ = z;
        C2675Gg0.LIZ().LIZ((Object) gBs);
    }

    public final /* synthetic */ 2Pr LJFF(Boolean bool) {
        boolean booleanValue = bool.booleanValue();
        if (this.LJJIJL == null || booleanValue) {
            this.LJJIJL = (SwitchDefinitionTipsWidget) this.LJIIJJI.load(GXG.LJIIIIZZ, SwitchDefinitionTipsWidget.class, false, new Object[]{Boolean.valueOf(booleanValue)});
        }
        this.LJJIJL.show();
        return 2Pr.LIZ;
    }

    public void onCreate(Bundle bundle) {
        super.onCreate(bundle);
        LIZ();
        this.LJJIJIIJI = System.currentTimeMillis();
        ((C4366HHj) C2675Gg0.LIZ().LIZ(C3394Grb.class).LIZ(Mk2.LIZ(Mk3.LIZ)).LIZ(DEF.LIZ(this))).LIZ(new GCL(this));
    }

    public final void LIZ(View view) {
        super.LIZ(view);
        this.LJIIJJI.load(GCN.LJ, new OrientationChangeWidget(), false);
        this.LJIIJJI.load(GCN.LIZ, new LockScreenWidget(), false);
        if (ShowAudienceDefinitionSelectionSetting.INSTANCE.isEnable()) {
            DefinitionSelectionWidget definitionSelectionWidget = new DefinitionSelectionWidget();
            this.LJIIJJI.load(GCN.LIZJ, definitionSelectionWidget, false);
            definitionSelectionWidget.show();
        }
        if (!LiveUnionPraiseGiftInToolBarSetting.isEnable()) {
            MessageBlockWidget messageBlockWidget = new MessageBlockWidget();
            view.findViewById(GCN.LIZIZ).setVisibility(0);
            this.LJIIJJI.load(GCN.LIZIZ, messageBlockWidget, false);
        }
        if (0cm.LIZ(IShareService.class).shareable(this.LJIIIIZZ)) {
            this.LJIIJJI.load(GCN.LIZLLL, new LiveTopShareWidget(), false);
        }
        if (this.LJII != null) {
            this.LJII.LIZ((0CH) this, 29n.class, new GCK(this));
        }
        if (this.LJII != null) {
            DataChannel dataChannel = this.LJII;
            dataChannel.LIZ((0CH) this, C2436Gc9.class, GC3.LIZ);
            dataChannel.LIZ((0CH) this, C2435Gc8.class, new GCM(this));
            dataChannel.LIZ((0CH) this, C2447GcK.class, new GCF(this));
            dataChannel.LIZ((0CH) this, C2489Gd0.class, new GCJ(this));
        }
    }

    public View onCreateView(LayoutInflater layoutInflater, ViewGroup viewGroup, Bundle bundle) {
        this.LJJIJ = 0HH.LIZ(LayoutInflater.from(getContext()), 2131561748, viewGroup, false);
        if (this.LJII != null) {
            DataChannel dataChannel = this.LJII;
            dataChannel.LIZ((0CH) this, C1183Fx2.class, new GCG(this));
            dataChannel.LIZ((0CH) this, GCP.class, new GCH(this));
        }
        return this.LJJIJ;
    }

    public final boolean LIZ(MotionEvent motionEvent, MotionEvent motionEvent2, float f, float f2) {
        if (!this.LJJIJIL) {
            DataChannel dataChannel = this.LJII;
            View view = this.LJJIJ;
            boolean z = !this.LJJIIZI;
            M12.LIZ(dataChannel, view, motionEvent, motionEvent2);
            if (Math.abs(f) > Math.abs(f2) && motionEvent.getX() > ((float) (view.getWidth() / 2))) {
                if (f > 0.0f && z) {
                    C1675GBw.LIZ.LIZ(dataChannel);
                } else if (f < 0.0f && !z) {
                    C1675GBw.LIZ.LIZ(dataChannel);
                }
                return true;
            }
        }
        return false;
    }
}
