package com.bytedance.android.livesdk.like.widget;

import X.0CB;
import X.0CH;
import X.0Ur;
import X.0b0;
import X.0bQ;
import X.0cm;
import X.1Fq;
import X.6Is;
import X.7vl;
import X.C1059Fv2;
import X.C1064Fv7;
import X.C2272GYv;
import X.C3028Glh;
import X.C4079H6i;
import X.C4081H6k;
import X.C4082H6l;
import X.C4088H6r;
import X.C4092H6v;
import X.C4095H6y;
import X.C4100H7d;
import X.C4345HGo;
import X.C4366HHj;
import X.Crj;
import X.H3C;
import X.H3M;
import X.H3O;
import X.H6U;
import X.H6V;
import X.HFX;
import X.HYX;
import X.Lea;
import X.M12;
import X.Mk2;
import X.Mk3;
import X.PhE;
import X.PlI;
import X.T6L;
import X.T6R;
import android.graphics.Bitmap;
import android.graphics.PointF;
import android.view.View;
import android.view.ViewGroup;
import android.widget.FrameLayout;
import com.bytedance.android.live.base.model.user.User;
import com.bytedance.android.livesdk.IBarrageService;
import com.bytedance.android.livesdk.like.LikeHelper;
import com.bytedance.android.livesdk.livesetting.performance.LikeClickVibrationSetting;
import com.bytedance.android.livesdk.livesetting.performance.degrade.LiveLikeDegradeSettings;
import com.bytedance.android.livesdk.model.RoomAuthStatus;
import com.bytedance.android.livesdkapi.depend.model.live.Room;
import com.bytedance.covode.number.Covode;
import com.bytedance.frameworks.apm.trace.MethodCollector;
import com.bytedance.ies.sdk.datachannel.DataChannel;
import com.bytedance.ies.sdk.widgets.LiveRecyclableWidget;
import com.bytedance.ies.sdk.widgets.WidgetExtendsKt;
import com.ss.ugc.live.sdk.message.interfaces.IMessageManager;
import java.util.HashSet;
import kotlin.h.b.n;

public final class SelfLikeWidget extends LiveRecyclableWidget implements H3M, H3C, 6Is {
    public static final int LJI = 0b0.LIZ(85.0f);
    public static final int LJII = 0b0.LIZ(32.0f);
    public static final H3O LJIIIIZZ = new H3O((byte) 0);
    public FrameLayout LIZ;
    public T6L LIZIZ;
    public HYX LIZJ;
    public 1Fq LIZLLL;
    public User LJ;
    public LikeHelper LJFF;
    public final Crj LJIIIZ = 7vl.LIZ(new C4092H6v(this));
    public H6U LJIIJ;
    public long LJIIJJI;
    public Room LJIIL;
    public boolean LJIILIIL;
    public boolean LJIILJJIL;
    public IMessageManager LJIILL;
    public boolean LJIILLIIL;
    public boolean LJIIZILJ;

    private final H6V LIZ() {
        return (H6V) this.LJIIIZ.getValue();
    }

    public final int getLayoutId() {
        return 2131561939;
    }

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

    static {
        Covode.recordClassIndex(17430);
    }

    public final void onUnload() {
        LIZ().LIZIZ();
        H6U h6u = this.LJIIJ;
        if (h6u != null) {
            h6u.LIZIZ();
        }
        1Fq r1 = this.LIZLLL;
        if (r1 == null) {
            n.LIZ("");
        }
        r1.LJII();
        1Fq r12 = this.LIZLLL;
        if (r12 == null) {
            n.LIZ("");
        }
        r12.setVisibility(8);
        LikeHelper likeHelper = this.LJFF;
        if (likeHelper != null && likeHelper.LJIILIIL && likeHelper.LJIIIZ()) {
            likeHelper.LIZIZ((H3C) this);
            likeHelper.LJIJ = null;
            likeHelper.LJJ = null;
        }
        for (Bitmap recycle : LIZ().LIZIZ) {
            recycle.recycle();
        }
        H6U h6u2 = this.LJIIJ;
    }

    public static final /* synthetic */ FrameLayout LIZIZ(SelfLikeWidget selfLikeWidget) {
        FrameLayout frameLayout = selfLikeWidget.LIZ;
        if (frameLayout == null) {
            n.LIZ("");
        }
        return frameLayout;
    }

    public static final /* synthetic */ HYX LIZJ(SelfLikeWidget selfLikeWidget) {
        HYX hyx = selfLikeWidget.LIZJ;
        if (hyx == null) {
            n.LIZ("");
        }
        return hyx;
    }

    public static final /* synthetic */ T6L LIZ(SelfLikeWidget selfLikeWidget) {
        T6L t6l = selfLikeWidget.LIZIZ;
        if (t6l == null) {
            n.LIZ("");
        }
        return t6l;
    }

    public final void LIZ(Bitmap bitmap) {
        H6U h6u;
        if (bitmap != null && !bitmap.isRecycled() && isViewValid() && (h6u = this.LJIIJ) != null) {
            h6u.LIZ(bitmap);
        }
    }

    public final void onInit(Object[] objArr) {
        H6U h6u;
        View findViewById = findViewById(2131371040);
        n.LIZIZ(findViewById, "");
        this.LIZ = (FrameLayout) findViewById;
        T6L findViewById2 = findViewById(2131371044);
        n.LIZIZ(findViewById2, "");
        this.LIZIZ = findViewById2;
        View findViewById3 = findViewById(2131370075);
        n.LIZIZ(findViewById3, "");
        this.LIZJ = (HYX) findViewById3;
        1Fq findViewById4 = findViewById(2131365077);
        n.LIZIZ(findViewById4, "");
        this.LIZLLL = findViewById4;
        if (!LiveLikeDegradeSettings.INSTANCE.disableEasterEggs(this.dataChannel)) {
            1Fq r1 = this.LIZLLL;
            if (r1 == null) {
                n.LIZ("");
            }
            r1.LIZ(new C4079H6i(this));
        }
        if (LiveLikeDegradeSettings.INSTANCE.disableAvatarAnim(this.dataChannel)) {
            h6u = null;
        } else {
            h6u = new H6U(this);
        }
        this.LJIIJ = h6u;
        LIZ().LIZ();
        H6U h6u2 = this.LJIIJ;
        if (h6u2 != null) {
            h6u2.LIZ();
        }
    }

    public final void onLoad(Object[] objArr) {
        Room room;
        boolean z;
        boolean z2;
        long j;
        IMessageManager iMessageManager;
        int LIZLLL2;
        Boolean bool;
        Boolean bool2;
        this.LJIILLIIL = false;
        this.LJIIZILJ = false;
        DataChannel dataChannel = this.dataChannel;
        LikeHelper likeHelper = null;
        if (dataChannel != null) {
            room = (Room) dataChannel.LIZIZ(C1064Fv7.class);
        } else {
            room = null;
        }
        this.LJIIL = room;
        DataChannel dataChannel2 = this.dataChannel;
        if (dataChannel2 == null || (bool2 = (Boolean) dataChannel2.LIZIZ(HFX.class)) == null) {
            z = true;
        } else {
            z = bool2.booleanValue();
        }
        this.LJIILIIL = z;
        DataChannel dataChannel3 = this.dataChannel;
        if (dataChannel3 == null || (bool = (Boolean) dataChannel3.LIZIZ(C1059Fv2.class)) == null) {
            z2 = false;
        } else {
            z2 = bool.booleanValue();
        }
        this.LJIILJJIL = z2;
        this.LJ = 0Ur.LIZ.LIZ();
        Room room2 = this.LJIIL;
        if (room2 != null) {
            j = room2.getId();
        } else {
            j = 0;
        }
        this.LJIIJJI = j;
        DataChannel dataChannel4 = this.dataChannel;
        if (dataChannel4 != null) {
            iMessageManager = (IMessageManager) dataChannel4.LIZIZ(C4345HGo.class);
        } else {
            iMessageManager = null;
        }
        this.LJIILL = iMessageManager;
        LIZ();
        H6U h6u = this.LJIIJ;
        if (h6u != null) {
            ((C4366HHj) C4100H7d.LIZ().LIZIZ().LJIIIZ().LIZ(C4081H6k.LIZ, false).LIZ(PhE.LIZIZ(PlI.LIZJ)).LIZLLL(C4082H6l.LIZ).LIZ(Mk2.LIZ(Mk3.LIZ)).LIZ(WidgetExtendsKt.autoDispose(h6u.LIZJ))).LIZ(new C4088H6r(h6u), C4095H6y.LIZ);
        }
        1Fq r1 = this.LIZLLL;
        if (r1 == null) {
            n.LIZ("");
        }
        r1.setVisibility(8);
        C2272GYv likeHelper2 = 0cm.LIZ(IBarrageService.class).getLikeHelper(this.LJIIJJI);
        if (likeHelper2 instanceof LikeHelper) {
            likeHelper = likeHelper2;
        }
        LikeHelper likeHelper3 = likeHelper;
        this.LJFF = likeHelper3;
        if (likeHelper3 != null && likeHelper3.LJIILIIL && likeHelper3.LJIIIZ()) {
            likeHelper3.LIZ((H3C) this);
            T6L t6l = this.LIZIZ;
            if (t6l == null) {
                n.LIZ("");
            }
            likeHelper3.LJIJ = t6l;
            likeHelper3.LJJ = this;
        }
        HYX hyx = this.LIZJ;
        if (hyx == null) {
            n.LIZ("");
        }
        ViewGroup.LayoutParams layoutParams = hyx.getLayoutParams();
        LikeHelper likeHelper4 = this.LJFF;
        if (likeHelper4 != null) {
            LIZLLL2 = likeHelper4.LJIJ();
        } else {
            LIZLLL2 = 0b0.LIZLLL(2131166032);
        }
        layoutParams.width = LIZLLL2;
        HYX hyx2 = this.LIZJ;
        if (hyx2 == null) {
            n.LIZ("");
        }
        HYX hyx3 = this.LIZJ;
        if (hyx3 == null) {
            n.LIZ("");
        }
        hyx2.setLayoutParams(hyx3.getLayoutParams());
        T6L t6l2 = this.LIZIZ;
        if (t6l2 == null) {
            n.LIZ("");
        } else {
            t6l2.setDataChannel(this.dataChannel);
        }
    }

    public final void LIZ(C2272GYv gYv, int i) {
        M12.LIZ(gYv);
        if (!gYv.LJIIZILJ() && gYv.LJIIL() && i >= gYv.LIZLLL()) {
            1Fq r0 = this.LIZLLL;
            if (r0 == null) {
                n.LIZ("");
            }
            if (!r0.LIZIZ.LJI()) {
                1Fq r1 = this.LIZLLL;
                if (r1 == null) {
                    n.LIZ("");
                }
                r1.setVisibility(0);
                1Fq r12 = this.LIZLLL;
                if (r12 == null) {
                    n.LIZ("");
                }
                0bQ.LIZIZ(r12, "flowers_lottie.zip");
            }
        }
    }

    public final void LIZ(C2272GYv gYv, int i, int i2, float f, float f2, float f3, float f4) {
        int i3;
        1Fq r5;
        View view;
        RoomAuthStatus roomAuthStatus;
        float f5 = f;
        float f6 = f2;
        MethodCollector.i(14736);
        M12.LIZ(gYv);
        C3028Glh LIZIZ2 = C4100H7d.LIZ().LIZIZ();
        n.LIZIZ(LIZIZ2, "");
        if (LIZIZ2.LJ()) {
            Room room = this.LJIIL;
            if (room == null || (roomAuthStatus = room.getRoomAuthStatus()) == null || roomAuthStatus.enableDigg) {
                if (!this.LJIILJJIL) {
                    try {
                        if (!LikeClickVibrationSetting.INSTANCE.getValue() && (view = getView()) != null) {
                            view.performHapticFeedback(1, 2);
                        }
                    } catch (Throwable unused) {
                    }
                }
                Bitmap LJII2 = gYv.LJII();
                if (LJII2 != null) {
                    if (!LJII2.isRecycled()) {
                        H6U h6u = this.LJIIJ;
                        if (h6u != null) {
                            h6u.LIZ(LJII2);
                        }
                        H6V LIZ2 = LIZ();
                        M12.LIZ(LJII2);
                        LikeHelper likeHelper = LIZ2.LIZLLL.LJFF;
                        if (likeHelper != null) {
                            i3 = likeHelper.LJIJI();
                        } else {
                            i3 = 0;
                        }
                        LikeHelper likeHelper2 = LIZ2.LIZLLL.LJFF;
                        if (likeHelper2 == null || likeHelper2.LJIILJJIL()) {
                            int[] iArr = new int[2];
                            LIZIZ(LIZ2.LIZLLL).getLocationOnScreen(iArr);
                            int i4 = LJI;
                            PointF pointF = new PointF((f5 - ((float) iArr[0])) - ((float) (i4 / 2)), ((f6 - ((float) iArr[1])) - ((float) (i4 / 2))) - ((float) i3));
                            HashSet<1Fq> hashSet = LIZ2.LIZJ;
                            if (!(!hashSet.isEmpty()) || hashSet == null || (r5 = (1Fq) Lea.LJ(hashSet)) == null) {
                                r5 = new 1Fq(LIZ2.LIZLLL.context);
                                LIZ2.LIZ(r5, pointF);
                                LIZIZ(LIZ2.LIZLLL).addView(r5, new FrameLayout.LayoutParams(i4, i4));
                                0bQ.LIZ(r5, "digg_tap_lottie.zip");
                            } else {
                                LIZ2.LIZJ.remove(r5);
                                LIZ2.LIZ(r5, pointF);
                            }
                            r5.LIZJ();
                        }
                        int[] iArr2 = new int[2];
                        LIZ(LIZ2.LIZLLL).getLocationOnScreen(iArr2);
                        PointF pointF2 = new PointF(f5 - ((float) iArr2[0]), (f6 - ((float) iArr2[1])) - ((float) i3));
                        float f7 = f3;
                        if (f7 > 0.0f) {
                            float f8 = f4;
                            if (f8 > 0.0f) {
                                PointF pointF3 = new PointF(f7, f8);
                                T6L LIZ3 = LIZ(LIZ2.LIZLLL);
                                M12.LIZ(LJII2, pointF2, pointF3);
                                LIZ3.LIZIZ.add(new T6R(LIZ3, LJII2, pointF2, pointF3));
                            }
                        }
                    }
                    MethodCollector.o(14736);
                    return;
                }
                MethodCollector.o(14736);
                return;
            }
            MethodCollector.o(14736);
            return;
        }
        MethodCollector.o(14736);
    }
}
