package com.bytedance.android.livesdk;

import X.0CB;
import X.0CH;
import X.0HH;
import X.0yx;
import X.341;
import X.6Is;
import X.C1059Fv2;
import X.C2272GYv;
import X.C2835Gia;
import X.C2844Gij;
import X.C3975H2i;
import X.C4100H7d;
import X.C4200HAz;
import X.C4815HYq;
import X.C4816HYr;
import X.C4818HYt;
import X.GVK;
import X.GZI;
import X.GZU;
import android.content.Context;
import android.graphics.Bitmap;
import android.view.ViewGroup;
import androidx.fragment.app.Fragment;
import com.bytedance.android.livesdk.like.LikeApi;
import com.bytedance.android.livesdk.like.widget.LikeUserInfoAnimWidget;
import com.bytedance.android.livesdk.like.widget.OthersLikeViewOptimizedWidget;
import com.bytedance.android.livesdk.like.widget.OthersLikeWidget;
import com.bytedance.android.livesdk.like.widget.SelfLikeViewOptimizedWidget;
import com.bytedance.android.livesdk.like.widget.SelfLikeWidget;
import com.bytedance.android.livesdk.livesetting.barrage.DiggParamsSetting;
import com.bytedance.android.livesdk.model.AbsBarrageWidget;
import com.bytedance.android.livesdk.widget.BarrageWidget;
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;
import java.util.HashMap;
import java.util.Locale;
import java.util.Map;

public class BarrageServiceImpl implements IBarrageService, 6Is {
    public final Map<Long, C2272GYv> likeHelperMap = new HashMap();

    static {
        Covode.recordClassIndex(11211);
    }

    public void onInit() {
    }

    public void onStateChanged(0CH r1, 0CB r2) {
    }

    public AbsBarrageWidget getBarrageWidget() {
        return new BarrageWidget();
    }

    public void preloadApi() {
        ((LikeApi) 0yx.LIZ().LIZ(LikeApi.class)).getIcons(0, 0);
    }

    public Class<? extends LiveRecyclableWidget> getLikeUserInfoAnimWidgetClass(C2272GYv gYv) {
        return LikeUserInfoAnimWidget.class;
    }

    public C2272GYv getLikeHelper(long j) {
        return this.likeHelperMap.get(Long.valueOf(j));
    }

    public Class<? extends LiveRecyclableWidget> getSelfLikeWidgetClass(C2272GYv gYv) {
        if (!gYv.LJIILIIL()) {
            return SelfLikeWidget.class;
        }
        return SelfLikeViewOptimizedWidget.class;
    }

    public void releaseLikeHelper(long j) {
        this.likeHelperMap.remove(Long.valueOf(j));
    }

    public Class<? extends LiveRecyclableWidget> getOthersLikeWidgetClass(C2272GYv gYv) {
        if (!gYv.LJIILIIL()) {
            C3975H2i.LJIIIZ.LIZ("OthersLikeWidget");
            return OthersLikeWidget.class;
        }
        C3975H2i.LJIIIZ.LIZ("OthersLikeViewOptimizedWidget");
        return OthersLikeViewOptimizedWidget.class;
    }

    public String formatLikeNumber(long j) {
        if (j < 0) {
            return "";
        }
        if (j < 1000) {
            return String.valueOf(j);
        }
        if (j < 1000000) {
            return 0HH.LIZ(Locale.US, "%.1f", new Object[]{Float.valueOf(((float) (j / 100)) / 10.0f)}) + 'K';
        } else if (j < 1000000000) {
            return 0HH.LIZ(Locale.US, "%.1f", new Object[]{Float.valueOf(((float) (j / 100000)) / 10.0f)}) + 'M';
        } else {
            return 0HH.LIZ(Locale.US, "%.1f", new Object[]{Float.valueOf(((float) (j / 100000000)) / 10.0f)}) + 'B';
        }
    }

    public GZI getBarrageLauncher(Context context, ViewGroup viewGroup) {
        return new C2835Gia(context, viewGroup);
    }

    public C4815HYq getDiggController(C4200HAz hAz, int i) {
        return new C2844Gij(hAz, i);
    }

    public C4816HYr getDiggBarrage(Bitmap bitmap, Double d) {
        return new C4818HYt(bitmap, d.doubleValue());
    }

    public void configInteractionHelper(Fragment fragment, DataChannel dataChannel, GVK gvk) {
        new GZU(fragment, dataChannel, gvk);
    }

    public static void addALogTrace(Room room, boolean z, boolean z2, boolean z3, DataChannel dataChannel, C2272GYv gYv) {
        String str;
        String str2;
        String str3;
        String str4 = "enabled";
        String str5 = null;
        if (gYv.LJIIJJI()) {
            str2 = "disabled_due_to_landscape_mode";
            if (z) {
                str = str4;
            } else {
                str = str2;
            }
            if (z2) {
                str2 = str4;
            }
            if (z3) {
                str3 = str4;
            } else {
                str3 = "disabled_due_to_being_audience_and_mic_room";
            }
        } else {
            if (!room.getRoomAuthStatus().isEnableDigg()) {
                str4 = "disabled_by_room_auth";
            } else if (!C4100H7d.LIZ().LIZIZ().LJ()) {
                str4 = "disabled_due_to_unlogin";
            } else if (!((Boolean) dataChannel.LIZIZ(C1059Fv2.class)).booleanValue() || DiggParamsSetting.INSTANCE.getValue().LIZ == 1) {
                str4 = null;
                str5 = null;
            } else {
                str4 = "disabled_due_to_being_anchor_and_ab";
            }
            str2 = str;
            str3 = str2;
        }
        341.LIZ(room.getId(), C4100H7d.LIZ().LIZIZ().LIZJ(), room.getOwnerUserId(), str4, str, str2, str3);
    }

    /*  JADX ERROR: JadxRuntimeException in pass: CodeShrinkVisitor
        jadx.core.utils.exceptions.JadxRuntimeException: Don't wrap MOVE or CONST insns: 0x0004: MOVE  (r5v0 X.0CH) = (r14v0 X.0CH)
        	at jadx.core.dex.instructions.args.InsnArg.wrapArg(InsnArg.java:164)
        	at jadx.core.dex.visitors.shrink.CodeShrinkVisitor.assignInline(CodeShrinkVisitor.java:133)
        	at jadx.core.dex.visitors.shrink.CodeShrinkVisitor.checkInline(CodeShrinkVisitor.java:118)
        	at jadx.core.dex.visitors.shrink.CodeShrinkVisitor.shrinkBlock(CodeShrinkVisitor.java:65)
        	at jadx.core.dex.visitors.shrink.CodeShrinkVisitor.shrinkMethod(CodeShrinkVisitor.java:43)
        	at jadx.core.dex.visitors.shrink.CodeShrinkVisitor.visit(CodeShrinkVisitor.java:35)
        */
    public void configLikeHelper(X.1hK r13, X.0CH r14, com.bytedance.android.livesdkapi.depend.model.live.Room r15, X.GZX r16, boolean r17, boolean r18, boolean r19, com.bytedance.ies.sdk.datachannel.DataChannel r20) {
        /*
            r12 = this;
            r1 = r12
            r4 = r13
            if (r4 == 0) goto L_0x000e
            r5 = r14
            if (r5 == 0) goto L_0x000e
            r6 = r15
            if (r6 == 0) goto L_0x000e
            r10 = r20
            if (r10 != 0) goto L_0x000f
        L_0x000e:
            return
        L_0x000f:
            com.bytedance.android.livesdk.model.RoomAuthStatus r0 = r6.getRoomAuthStatus()
            if (r0 != 0) goto L_0x0032
            long r1 = r6.getId()
            X.H7d r0 = X.C4100H7d.LIZ()
            X.Glh r0 = r0.LIZIZ()
            long r3 = r0.LIZJ()
            long r5 = r6.getOwnerUserId()
            r8 = 0
            r9 = 0
            r10 = 0
            java.lang.String r7 = "disabled_due_to_empty_room_auth"
            X.341.LIZ(r1, r3, r5, r7, r8, r9, r10)
            return
        L_0x0032:
            X.0CD r0 = r4.getLifecycle()
            r0.LIZ(r12)
            com.bytedance.android.livesdk.livesetting.performance.LiveOptimizedLikeSetting r0 = com.bytedance.android.livesdk.livesetting.performance.LiveOptimizedLikeSetting.INSTANCE
            boolean r0 = r0.getValue()
            r9 = r19
            r7 = r17
            r8 = r18
            if (r0 != 0) goto L_0x0073
            com.bytedance.android.livesdk.like.LikeHelper r3 = new com.bytedance.android.livesdk.like.LikeHelper
            r3.<init>(r4, r5, r6, r7, r8, r9, r10)
        L_0x004c:
            r11 = r3
            addALogTrace(r6, r7, r8, r9, r10, r11)
            java.util.Map<java.lang.Long, X.GYv> r2 = r1.likeHelperMap
            long r0 = r6.getId()
            java.lang.Long r0 = java.lang.Long.valueOf(r0)
            r2.put(r0, r3)
            if (r7 == 0) goto L_0x000e
            if (r16 == 0) goto L_0x000e
            X.GVK r0 = r16.LIZ()
            if (r0 == 0) goto L_0x000e
            X.GVK r1 = r16.LIZ()
            android.view.View$OnTouchListener r0 = r3.LIZ()
            r1.LIZ(r0)
            goto L_0x000e
        L_0x0073:
            com.bytedance.android.livesdk.like.OptimizedLikeHelper r3 = new com.bytedance.android.livesdk.like.OptimizedLikeHelper
            r3.<init>(r4, r5, r6, r7, r8, r9, r10)
            goto L_0x004c
        */
        throw new UnsupportedOperationException("Method not decompiled: com.bytedance.android.livesdk.BarrageServiceImpl.configLikeHelper(X.1hK, X.0CH, com.bytedance.android.livesdkapi.depend.model.live.Room, X.GZX, boolean, boolean, boolean, com.bytedance.ies.sdk.datachannel.DataChannel):void");
    }
}
