package com.bytedance.android.livesdk.like;

import X.0CB;
import X.0CH;
import X.0CN;
import X.0UM;
import X.0Ur;
import X.0b0;
import X.0cm;
import X.0yx;
import X.1Ol;
import X.1c5;
import X.1hK;
import X.2Pr;
import X.2Tc;
import X.2cN;
import X.6Is;
import X.86a;
import X.8uQ;
import X.C1059Fv2;
import X.C1064Fv7;
import X.C1856GIv;
import X.C2154GUh;
import X.C2272GYv;
import X.C2402Gbb;
import X.C3278Gpj;
import X.C3441GsM;
import X.C3491GtA;
import X.C3499GtI;
import X.C3975H2i;
import X.C3981H2o;
import X.C3982H2p;
import X.C3984H2r;
import X.C3985H2s;
import X.C3986H2t;
import X.C3987H2u;
import X.C3988H2v;
import X.C4100H7d;
import X.C4345HGo;
import X.C4366HHj;
import X.D4n;
import X.DEF;
import X.G0S;
import X.G3X;
import X.GMD;
import X.GPI;
import X.GZH;
import X.H31;
import X.H32;
import X.H34;
import X.H38;
import X.H3A;
import X.H3B;
import X.H3C;
import X.H3F;
import X.H3G;
import X.H3L;
import X.H3M;
import X.HEP;
import X.HER;
import X.HI6;
import X.Mk2;
import X.Mk3;
import X.Per;
import X.PgU;
import X.PhE;
import X.PlI;
import android.content.res.TypedArray;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.os.Handler;
import android.os.Message;
import android.os.SystemClock;
import android.text.TextUtils;
import android.util.SparseArray;
import android.view.GestureDetector;
import android.view.MotionEvent;
import android.view.View;
import com.bytedance.android.live.base.model.ImageModel;
import com.bytedance.android.live.base.model.user.User;
import com.bytedance.android.live.liveinteract.api.IInteractService;
import com.bytedance.android.live.microom.IMicRoomService;
import com.bytedance.android.livesdk.BarrageServiceImpl;
import com.bytedance.android.livesdk.livesetting.barrage.DiggParamsSetting;
import com.bytedance.android.livesdk.livesetting.performance.degrade.LiveLikeDegradeSettings;
import com.bytedance.android.livesdk.livesetting.watchlive.LivePreloadInteractionLayerSetting;
import com.bytedance.android.livesdk.model.message.LikeMessage;
import com.bytedance.android.livesdkapi.depend.model.live.Room;
import com.bytedance.android.livesdkapi.message.CommonMessageData;
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.datachannel.DataChannelGlobal;
import com.ss.ugc.live.sdk.message.interfaces.IMessageManager;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Random;
import org.json.JSONException;
import org.json.JSONObject;

public class LikeHelper implements C2272GYv, 6Is {
    public final 0CH LIZ;
    public final 1hK LIZIZ;
    public Room LIZJ;
    public final List<H3C> LIZLLL;
    public int LJ;
    public int LJFF;
    public final int LJI;
    public final int LJII;
    public final long LJIIIIZZ;
    public boolean LJIIIZ;
    public int LJIIJ;
    public final String LJIIJJI;
    public final boolean LJIIL;
    public boolean LJIILIIL;
    public final SparseArray<Bitmap> LJIILJJIL = new SparseArray<>();
    public final List<Bitmap> LJIILL = new ArrayList();
    public final BitmapFactory.Options LJIILLIIL;
    public final DataChannel LJIIZILJ;
    public View LJIJ;
    public final Map<String, 2cN> LJIJI;
    public final List<Bitmap> LJIJJ;
    public final Map<String, Bitmap> LJIJJLI;
    public final List<Bitmap> LJIL;
    public H3M LJJ;
    public H3L LJJI;
    public List<2Tc> LJJIFFI;
    public final View.OnTouchListener LJJII;
    public final long LJJIII;
    public final boolean LJJIIJ;
    public float LJJIIJZLJL;
    public float LJJIIZ;
    public final int LJJIIZI;
    public final int LJJIJ;
    public boolean LJJIJIIJI;
    public final boolean LJJIJIIJIL;
    public boolean LJJIJIL;
    public View LJJIJL;
    public int[] LJJIJLIJ;
    public final SparseArray<Bitmap> LJJIL;
    public final Random LJJIZ;
    public final List<Bitmap> LJJJ;
    public List<GZH> LJJJI;
    public int LJJJIL;
    public int LJJJJ;
    public boolean LJJJJI;
    public final Handler LJJJJIZL;

    static {
        Covode.recordClassIndex(17367);
    }

    public boolean LJIILIIL() {
        return false;
    }

    public void onStateChanged(0CH r2, 0CB r3) {
        if (r3 == 0CB.ON_DESTROY) {
            onDestroy();
        }
    }

    public final View.OnTouchListener LIZ() {
        return this.LJJII;
    }

    public final View LIZIZ() {
        return this.LJJIJL;
    }

    public final int LIZJ() {
        return this.LJJIIZI;
    }

    public final int LIZLLL() {
        return this.LJJIJ;
    }

    public final int LJ() {
        return this.LJIIJ;
    }

    public final boolean LJIIIIZZ() {
        return this.LJJIJIIJI;
    }

    public final boolean LJIIIZ() {
        return this.LJIIL;
    }

    public final boolean LJIIJ() {
        return this.LJJIJIIJIL;
    }

    public final boolean LJIIJJI() {
        return this.LJIILIIL;
    }

    public final boolean LJIIL() {
        return this.LJJIJIL;
    }

    public final void LIZ(List<2Tc> list) {
        for (2Tc next : list) {
            if (next != null) {
                this.LJJIFFI.add(next);
            }
        }
    }

    public final /* synthetic */ void LIZ(String str, Throwable th) {
        this.LJIJI.remove(str);
        if (th instanceof 0UM) {
            C3975H2i.LJIIIZ.LIZ(0, ((0UM) th).getErrorCode());
        }
    }

    public final /* synthetic */ void LIZ(String str) {
        this.LJIJI.remove(str);
    }

    public final void LIZ(boolean z) {
        this.LJJIJIIJI = z;
    }

    public final void LIZ(View view) {
        this.LJJIJL = view;
        this.LJJIIJZLJL = 0.0f;
        this.LJJIIZ = 0.0f;
    }

    public final boolean LIZ(float f, float f2) {
        View view;
        View view2;
        if (this.LJIIZILJ.LIZIZ(GPI.class) != C2154GUh.DISMISS || !this.LJIILIIL || this.LJJIJIIJI || !this.LJIIIZ) {
            return false;
        }
        this.LJFF++;
        this.LJIIJ++;
        if (!(this.LJJIIJZLJL > 0.0f || this.LJJIIZ > 0.0f || (view = this.LJJIJL) == null || view.getMeasuredWidth() == 0 || this.LJJIJL.getMeasuredHeight() == 0 || (view2 = this.LJIJ) == null || view2.getMeasuredWidth() == 0 || this.LJIJ.getMeasuredHeight() == 0)) {
            int[] iArr = new int[2];
            this.LJJIJL.getLocationInWindow(iArr);
            int[] iArr2 = new int[2];
            this.LJIJ.getLocationInWindow(iArr2);
            int i = iArr[0] - iArr2[0];
            int i2 = iArr[1] - iArr2[1];
            this.LJJIIJZLJL = ((float) i) + (((float) this.LJJIJL.getMeasuredWidth()) / 2.0f);
            this.LJJIIZ = ((float) i2) + (((float) this.LJJIJL.getMeasuredHeight()) / 2.0f);
        }
        int i3 = this.LJ;
        int i4 = this.LJFF;
        int i5 = this.LJIIJ;
        float f3 = this.LJJIIJZLJL;
        float f4 = this.LJJIIZ;
        float f5 = f;
        float f6 = f2;
        LIZ(i3, i4, i5, f5, f6, f3, f4);
        for (H3C LIZ2 : this.LIZLLL) {
            LIZ2.LIZ(this, i3, i4, f5, f6, f3, f4);
        }
        this.LJJJJIZL.removeMessages(1);
        this.LJJJJIZL.sendEmptyMessageDelayed(1, this.LJJIII);
        return true;
    }

    public final boolean LJIILJJIL() {
        if (!LiveLikeDegradeSettings.INSTANCE.disableLottieAnim(this.LJIIZILJ)) {
            return true;
        }
        return false;
    }

    public final void LJIILL() {
        H3M h3m = this.LJJ;
        if (h3m != null) {
            h3m.LIZ(LIZLLL(2131235192));
        }
    }

    public final void LJIILLIIL() {
        H3L h3l = this.LJJI;
        if (h3l != null) {
            h3l.LIZ(LIZLLL(2131235192));
        }
    }

    public final boolean LJIIZILJ() {
        return LiveLikeDegradeSettings.INSTANCE.disableEasterEggs(this.LJIIZILJ);
    }

    public final int LJIJ() {
        int i = this.LJJJIL;
        if (i > 0) {
            return i;
        }
        int LIZLLL2 = 0b0.LIZLLL(2131166033);
        this.LJJJIL = LIZLLL2;
        return LIZLLL2;
    }

    public final int LJIJI() {
        int i = this.LJJJJ;
        if (i >= 0) {
            return i;
        }
        int LIZLLL2 = 0b0.LIZLLL(2131166159);
        this.LJJJJ = LIZLLL2;
        return LIZLLL2;
    }

    public final void LJI() {
        Bitmap bitmap = this.LJIILJJIL.get(2131234135);
        if (bitmap != null) {
            this.LJIILJJIL.remove(2131234135);
            this.LJIILL.remove(bitmap);
        }
    }

    private void LJIJJLI() {
        if (this.LJJIJLIJ == null) {
            TypedArray obtainTypedArray = this.LIZIZ.getResources().obtainTypedArray(2130903099);
            if (obtainTypedArray.length() > 0) {
                this.LJJIJLIJ = new int[obtainTypedArray.length()];
                for (int i = 0; i < obtainTypedArray.length(); i++) {
                    this.LJJIJLIJ[i] = obtainTypedArray.getResourceId(i, 0);
                }
            }
            obtainTypedArray.recycle();
        }
    }

    public final void LJFF() {
        MethodCollector.i(16368);
        if (this.LJIILJJIL.get(2131234135) != null) {
            MethodCollector.o(16368);
            return;
        }
        Bitmap decodeResource = BitmapFactory.decodeResource(this.LIZIZ.getResources(), 2131234135, this.LJIILLIIL);
        if (decodeResource != null) {
            this.LJIILJJIL.put(2131234135, decodeResource);
            this.LJIILL.add(decodeResource);
        }
        MethodCollector.o(16368);
    }

    public final boolean LJIJJ() {
        if (this.LJIIZILJ.LIZIZ(GPI.class) == C2154GUh.DISMISS && this.LJIILIIL && !this.LJJIJIIJI) {
            for (2Tc next : this.LJJIFFI) {
                if (next != null) {
                    next.setVisibility(0);
                }
            }
            if (!this.LJIIIZ) {
                this.LJ++;
                this.LJFF = 0;
                this.LJIIIZ = true;
                return true;
            }
        }
        return false;
    }

    private Bitmap LJIL() {
        Bitmap LIZLLL2;
        if (!this.LJIJJ.isEmpty()) {
            List<Bitmap> list = this.LJIJJ;
            LIZLLL2 = list.get(this.LJJIZ.nextInt(list.size()));
        } else if (this.LJJIIJ) {
            LIZLLL2 = LIZLLL(2131234944);
        } else {
            int[] iArr = this.LJJIJLIJ;
            if (iArr != null && iArr.length > 0) {
                LIZLLL2 = LIZLLL(iArr[this.LJJIZ.nextInt(iArr.length)]);
            }
            return null;
        }
        if (LIZLLL2 == null || LIZLLL2.isRecycled()) {
            return null;
        }
        return LIZLLL2;
    }

    private boolean LJJ() {
        boolean z;
        boolean z2;
        if (this.LJIIZILJ.LIZIZ(C1059Fv2.class) != null) {
            z = ((Boolean) this.LJIIZILJ.LIZIZ(C1059Fv2.class)).booleanValue();
        } else {
            z = false;
        }
        if (!z || DiggParamsSetting.INSTANCE.getValue().LIZ == 1) {
            z2 = true;
        } else {
            z2 = false;
        }
        Room room = this.LIZJ;
        if ((room == null || room.getRoomAuthStatus() == null || this.LIZJ.getRoomAuthStatus().isEnableDigg()) && z2 && C4100H7d.LIZ().LIZIZ().LJ()) {
            return true;
        }
        return false;
    }

    public final Bitmap LJII() {
        if (!this.LJIILL.isEmpty()) {
            List<Bitmap> list = this.LJIILL;
            Bitmap bitmap = list.get(this.LJJIZ.nextInt(list.size()));
            if (bitmap != null && !bitmap.isRecycled()) {
                return bitmap;
            }
        }
        if (!this.LJIL.isEmpty()) {
            List<Bitmap> list2 = this.LJIL;
            Bitmap bitmap2 = list2.get(this.LJJIZ.nextInt(list2.size()));
            if (bitmap2 != null) {
                return bitmap2;
            }
        }
        return LJIL();
    }

    @0CN(LIZ = 0CB.ON_DESTROY)
    public void onDestroy() {
        Long l;
        Long l2;
        String str;
        C1856GIv streamType;
        this.LJJJJIZL.removeMessages(1);
        this.LIZLLL.clear();
        this.LJIILJJIL.clear();
        for (Bitmap next : this.LJIILL) {
            if (!next.isRecycled()) {
                next.recycle();
            }
        }
        this.LJIILL.clear();
        for (int i = 0; i < this.LJJIL.size(); i++) {
            Bitmap bitmap = this.LJJIL.get(i);
            if (bitmap != null && !bitmap.isRecycled()) {
                bitmap.recycle();
            }
        }
        this.LJJIL.clear();
        this.LJJIJLIJ = null;
        for (2cN next2 : this.LJIJI.values()) {
            if (next2 != null && !next2.isDisposed()) {
                next2.dispose();
            }
        }
        List<GZH> list = this.LJJJI;
        if (list != null) {
            list.clear();
            this.LJJJI = null;
        }
        this.LIZ.getLifecycle().LIZIZ(this);
        JSONObject jSONObject = new JSONObject();
        try {
            jSONObject.put("bottom_right_anim_total_amount", C3975H2i.LIZ);
            jSONObject.put("bottom_right_anim_display_amount", C3975H2i.LIZIZ);
            jSONObject.put("watch_live_duration", SystemClock.uptimeMillis() - C3975H2i.LJIIIIZZ);
            jSONObject.put("widget", C3975H2i.LIZJ);
            if (C3975H2i.LIZLLL >= 0) {
                jSONObject.put("default_icon_show_count", C3975H2i.LIZLLL);
            }
            jSONObject.put("top_left_anim_like_count", C3975H2i.LJ);
            jSONObject.put("full_progress_anim_like_count", C3975H2i.LJFF);
            jSONObject.put("like_total_count", C3975H2i.LJI);
            Room room = C3975H2i.LJII;
            if (room != null) {
                l = Long.valueOf(room.getOwnerUserId());
            } else {
                l = null;
            }
            jSONObject.put("anchor_id", l);
            Room room2 = C3975H2i.LJII;
            if (room2 != null) {
                l2 = Long.valueOf(room2.getId());
            } else {
                l2 = null;
            }
            jSONObject.put("room_id", l2);
            Room room3 = C3975H2i.LJII;
            if (room3 == null || (streamType = room3.getStreamType()) == null) {
                str = null;
            } else {
                str = streamType.logStreamingType;
            }
            jSONObject.put("room_type", str);
        } catch (JSONException unused) {
        }
        GMD.LIZ("ttlive_like_tap_count", (JSONObject) null, (JSONObject) null, jSONObject);
        C3975H2i.LIZ = 0;
        C3975H2i.LIZIZ = 0;
        C3975H2i.LIZLLL = -1;
        C3975H2i.LJ = 0;
        C3975H2i.LJFF = 0;
        C3975H2i.LJI = 0;
        C3975H2i.LJII = null;
        C3975H2i.LJIIIIZZ = 0;
    }

    public float LIZ(MotionEvent motionEvent) {
        return motionEvent.getRawX();
    }

    public float LIZIZ(MotionEvent motionEvent) {
        return motionEvent.getRawY();
    }

    public final /* synthetic */ void LIZJ(String str) {
        this.LJIJI.remove(str);
    }

    public final void LIZ(H3C h3c) {
        if (h3c != null && !this.LIZLLL.contains(h3c)) {
            this.LIZLLL.add(h3c);
        }
    }

    public final void LIZIZ(GZH gzh) {
        List<GZH> list = this.LJJJI;
        if (list != null) {
            list.remove(gzh);
        }
    }

    public final void LIZ(int i) {
        List<GZH> list = this.LJJJI;
        if (list != null) {
            for (GZH LIZ2 : list) {
                LIZ2.LIZ(i);
            }
        }
    }

    public final void LIZIZ(H3C h3c) {
        this.LIZLLL.remove(h3c);
    }

    private Bitmap LIZLLL(int i) {
        MethodCollector.i(16495);
        Bitmap bitmap = this.LJJIL.get(i);
        if (bitmap == null) {
            bitmap = BitmapFactory.decodeResource(this.LIZIZ.getResources(), i, this.LJIILLIIL);
            this.LJJIL.put(i, bitmap);
        }
        MethodCollector.o(16495);
        return bitmap;
    }

    public void LIZIZ(int i) {
        long uptimeMillis = SystemClock.uptimeMillis();
        ((C4366HHj) ((LikeApi) 0yx.LIZ().LIZ(LikeApi.class)).like(this.LIZJ.getId(), (long) i, (String) DataChannelGlobal.LIZLLL.LIZIZ(HER.class)).LIZ(DEF.LIZ(this.LIZ))).LIZ(new H3F(this, i, uptimeMillis), new H3A(this, i));
    }

    public final /* synthetic */ void LIZIZ(String str) {
        this.LJIJI.remove(str);
    }

    /* JADX WARNING: Code restructure failed: missing block: B:17:0x00a0, code lost:
        if (r4 == null) goto L_0x00a2;
     */
    /* Code decompiled incorrectly, please refer to instructions dump. */
    public final android.graphics.Bitmap LIZIZ(java.util.List<com.bytedance.android.live.base.model.ImageModel> r8) {
        /*
            r7 = this;
            r4 = 0
            if (r8 == 0) goto L_0x00a2
            boolean r0 = r8.isEmpty()
            if (r0 != 0) goto L_0x00a2
            java.util.ArrayList r3 = new java.util.ArrayList
            r3.<init>()
            java.util.Iterator r6 = r8.iterator()
        L_0x0012:
            boolean r0 = r6.hasNext()
            if (r0 == 0) goto L_0x0047
            java.lang.Object r5 = r6.next()
            com.bytedance.android.live.base.model.ImageModel r5 = (com.bytedance.android.live.base.model.ImageModel) r5
            java.util.Map<java.lang.String, android.graphics.Bitmap> r1 = r7.LJIJJLI
            java.lang.String r0 = r5.mUri
            boolean r0 = r1.containsKey(r0)
            if (r0 == 0) goto L_0x0036
            java.util.List<android.graphics.Bitmap> r2 = r7.LJJJ
            java.util.Map<java.lang.String, android.graphics.Bitmap> r1 = r7.LJIJJLI
            java.lang.String r0 = r5.mUri
            java.lang.Object r0 = r1.get(r0)
            r2.add(r0)
            goto L_0x0012
        L_0x0036:
            X.PgU r1 = X.HI6.LIZ((com.bytedance.android.live.base.model.ImageModel) r5)
            X.H2w r0 = new X.H2w
            r0.<init>(r5)
            X.PgU r0 = r1.LIZLLL(r0)
            r3.add(r0)
            goto L_0x0012
        L_0x0047:
            java.util.List<android.graphics.Bitmap> r0 = r7.LJJJ
            boolean r0 = r0.isEmpty()
            if (r0 != 0) goto L_0x0066
            java.util.List<android.graphics.Bitmap> r2 = r7.LJJJ
            java.util.Random r1 = r7.LJJIZ
            int r0 = r2.size()
            int r0 = r1.nextInt(r0)
            java.lang.Object r4 = r2.get(r0)
            android.graphics.Bitmap r4 = (android.graphics.Bitmap) r4
            java.util.List<android.graphics.Bitmap> r0 = r7.LJJJ
            r0.clear()
        L_0x0066:
            boolean r0 = r3.isEmpty()
            if (r0 != 0) goto L_0x00a0
            long r0 = android.os.SystemClock.uptimeMillis()
            java.lang.String r5 = java.lang.String.valueOf(r0)
            X.PgU r1 = X.PgU.LIZJ(r3)
            X.PgC r0 = X.H35.LIZ
            X.PgU r1 = r1.LIZ(r0)
            X.PlG r0 = X.Mk3.LIZ
            X.PlG r0 = X.Mk2.LIZ(r0)
            X.PgU r3 = r1.LIZ(r0)
            X.H2q r2 = new X.H2q
            r2.<init>(r7)
            X.H3D r1 = new X.H3D
            r1.<init>(r7, r5)
            X.H3E r0 = new X.H3E
            r0.<init>(r7, r5)
            X.2cN r1 = r3.LIZ(r2, r1, r0)
            java.util.Map<java.lang.String, X.2cN> r0 = r7.LJIJI
            r0.put(r5, r1)
        L_0x00a0:
            if (r4 != 0) goto L_0x00b0
        L_0x00a2:
            android.graphics.Bitmap r4 = r7.LJIL()
            int r0 = X.C3975H2i.LIZLLL
            if (r0 < 0) goto L_0x00b0
            int r0 = X.C3975H2i.LIZLLL
            int r0 = r0 + 1
            X.C3975H2i.LIZLLL = r0
        L_0x00b0:
            return r4
        */
        throw new UnsupportedOperationException("Method not decompiled: com.bytedance.android.livesdk.like.LikeHelper.LIZIZ(java.util.List):android.graphics.Bitmap");
    }

    public void LIZJ(int i) {
        HashMap hashMap = new HashMap();
        hashMap.put("live_source", this.LJIIJJI);
        hashMap.put("request_id", this.LIZJ.getRequestId());
        hashMap.put("log_pb", this.LIZJ.getLog_pb());
        hashMap.put("like_amount", String.valueOf(i));
        StringBuilder sb = new StringBuilder();
        sb.append(this.LIZJ.getUserFrom());
        hashMap.put("source", sb.toString());
        if (!86a.LIZ(C3499GtI.LIZ().LJ())) {
            hashMap.put("enter_live_method", C3499GtI.LIZ().LJ());
        }
        String LJI2 = C2402Gbb.LIZ.LJI();
        String str = "1";
        if (TextUtils.isEmpty(LJI2) || !"click_push_live_cd_user".equals(LJI2)) {
            hashMap.put("is_subscribe", "0");
        } else {
            hashMap.put("is_subscribe", str);
        }
        if (0b0.LJFF()) {
            hashMap.put("room_orientation", "portrait");
        } else {
            hashMap.put("room_orientation", "landscape");
        }
        long j = 0;
        if (DataChannelGlobal.LIZLLL.LIZIZ(HEP.class) != null) {
            j = ((Room) DataChannelGlobal.LIZLLL.LIZIZ(HEP.class)).getOwnerUserId();
        }
        long j2 = 1Ol.LLFII.LIZ().LJFF;
        if (0cm.LIZ(IInteractService.class).isInCoHost()) {
            hashMap.put("connection_type", "anchor");
            hashMap.put("channel_id", String.valueOf(1Ol.LLFII.LIZ().LJ));
            List multiCoHostLinkedUserList = 0cm.LIZ(IInteractService.class).getMultiCoHostLinkedUserList();
            if (multiCoHostLinkedUserList.size() <= 2) {
                str = "0";
            }
            hashMap.put("is_multi", str);
            if (multiCoHostLinkedUserList.size() <= 2) {
                hashMap.put("invitee_list", 0cm.LIZ(IInteractService.class).getCurrentInviteeList());
            }
            if (1Ol.LLFII.LIZ().LJIILLIIL) {
                hashMap.put("connection_inviter_id", String.valueOf(j));
                hashMap.put("connection_invitee_id", String.valueOf(j2));
            } else {
                hashMap.put("connection_invitee_id", String.valueOf(j));
                hashMap.put("connection_inviter_id", String.valueOf(j2));
            }
        }
        if (0cm.LIZ(IInteractService.class).isRoomInBattle()) {
            hashMap.put("connection_type", "manual_pk");
            hashMap.put("pk_id", String.valueOf(1Ol.LLFII.LIZ().LJLILLLLZI));
            if (0cm.LIZ(IInteractService.class).isBattleStarter()) {
                hashMap.put("pk_inviter_id", String.valueOf(j));
                hashMap.put("pk_invitee_id", String.valueOf(j2));
            } else {
                hashMap.put("pk_invitee_id", String.valueOf(j));
                hashMap.put("pk_inviter_id", String.valueOf(j2));
            }
            if (0cm.LIZ(IInteractService.class).isBattling()) {
                hashMap.put("match_status", "pk_phase");
            } else {
                hashMap.put("match_status", "punish");
            }
        }
        if (0cm.LIZ(IInteractService.class).isInMultiGuest()) {
            hashMap.put("connection_type", "audience");
        }
        hashMap.put("admin_type", G3X.LIZ(this.LIZJ, this.LJIIZILJ));
        C3491GtA LIZ2 = C3491GtA.LJFF.LIZ("like");
        LIZ2.LIZ((Map<String, String>) hashMap);
        LIZ2.LIZJ("live_interact");
        LIZ2.LIZ();
        LIZ2.LIZ(new C3441GsM(this.LJIIZILJ, "user_live_like"));
        LIZ2.LIZLLL();
        if (C3278Gpj.LIZ(this.LJIIZILJ)) {
            HashMap hashMap2 = new HashMap();
            hashMap2.put("room_id", String.valueOf(this.LIZJ.getId()));
            hashMap2.put("anchor_id", String.valueOf(this.LIZJ.getOwnerUserId()));
            C3278Gpj.LIZIZ.LIZ("live_ad", "like", (Map<String, ? extends Object>) null, hashMap2);
        }
    }

    public final void LIZ(GZH gzh) {
        if (this.LJJJI == null) {
            this.LJJJI = new ArrayList();
        }
        if (gzh != null && !this.LJJJI.contains(gzh)) {
            this.LJJJI.add(gzh);
        }
    }

    public static final /* synthetic */ D4n LIZ(long j, 1c5 r5) {
        C3975H2i.LJIIIZ.LIZ(j, 0);
        if (r5 == null || r5.data == null) {
            return PhE.LIZ(Per.LIZ);
        }
        ArrayList arrayList = new ArrayList();
        if (!((C3984H2r) r5.data).LIZ().isEmpty()) {
            for (ImageModel next : ((C3984H2r) r5.data).LIZ()) {
                arrayList.add(HI6.LIZ(next).LIZLLL(new C3987H2u(next)));
            }
        }
        if (!((C3984H2r) r5.data).LIZIZ().isEmpty()) {
            for (ImageModel next2 : ((C3984H2r) r5.data).LIZIZ()) {
                arrayList.add(HI6.LIZ(next2).LIZLLL(new C3988H2v(next2)));
            }
        }
        return PgU.LIZJ(arrayList);
    }

    public final /* synthetic */ void LIZ(int i, long j) {
        C3975H2i h2i = C3975H2i.LJIIIZ;
        Room room = this.LIZJ;
        h2i.LIZ(i, room, String.valueOf(room.getOwnerUserId()), j);
    }

    public final /* synthetic */ void LIZ(int i, Throwable th) {
        1hK r0 = this.LIZIZ;
        if (r0 == null || r0.isFinishing()) {
            G0S.LIZ(0b0.LJ(), th);
        } else {
            G0S.LIZ(this.LIZIZ, th);
        }
        if (th instanceof 0UM) {
            C3975H2i h2i = C3975H2i.LJIIIZ;
            Room room = this.LIZJ;
            h2i.LIZ(i, room, String.valueOf(room.getOwnerUserId()), 0);
        }
    }

    public final /* synthetic */ 2Pr LIZ(DataChannel dataChannel, Room room, boolean z, boolean z2, boolean z3, Room room2) {
        boolean z4;
        DataChannel dataChannel2 = dataChannel;
        if (LivePreloadInteractionLayerSetting.INSTANCE.isDisablePreload(dataChannel2)) {
            return 2Pr.LIZ;
        }
        this.LIZJ = room2;
        this.LJIILIIL = LJJ();
        if (((Boolean) dataChannel2.LIZIZ(C1059Fv2.class)).booleanValue() || !0cm.LIZ(IMicRoomService.class).isMicRoomForCurrentRoom()) {
            z4 = true;
        } else {
            z4 = false;
        }
        this.LJJIJIL = z4;
        boolean z5 = z2;
        BarrageServiceImpl.addALogTrace(room, z, z5, z3, dataChannel2, this);
        return 2Pr.LIZ;
    }

    public void LIZ(int i, int i2, int i3, float f, float f2, float f3, float f4) {
        if (!this.LJJJJI) {
            IMessageManager iMessageManager = (IMessageManager) this.LJIIZILJ.LIZIZ(C4345HGo.class);
            User LIZ2 = 0Ur.LIZ.LIZ();
            if (iMessageManager != null && LIZ2 != null && !LiveLikeDegradeSettings.INSTANCE.disableAvatarAnim(this.LJIIZILJ)) {
                long id = this.LIZJ.getId();
                CommonMessageData commonMessageData = new CommonMessageData();
                commonMessageData.LIZJ = id;
                commonMessageData.LJI = true;
                LikeMessage likeMessage = new LikeMessage(true, LIZ2);
                likeMessage.LJJJJ = commonMessageData;
                iMessageManager.insertMessage(likeMessage, true);
                this.LJJJJI = true;
            }
        }
    }

    public LikeHelper(1hK r17, 0CH r18, Room room, boolean z, boolean z2, boolean z3, DataChannel dataChannel) {
        long j;
        int i;
        int i2;
        boolean z4;
        int i3;
        long j2;
        String str;
        BitmapFactory.Options options = new BitmapFactory.Options();
        this.LJIILLIIL = options;
        this.LJIJ = null;
        this.LJJIJL = null;
        HashMap hashMap = new HashMap();
        this.LJIJI = hashMap;
        this.LJJIL = new SparseArray<>();
        this.LJJIZ = new Random();
        this.LJIJJ = new ArrayList();
        this.LJIJJLI = new HashMap();
        this.LJIL = new ArrayList();
        this.LJJJ = new ArrayList();
        this.LJJJIL = -1;
        this.LJJJJ = -1;
        this.LJJIFFI = new ArrayList();
        this.LJJJJIZL = new Handler(new Handler.Callback() {
            static {
                Covode.recordClassIndex(17368);
            }

            public final boolean handleMessage(Message message) {
                if (message.what != 1) {
                    return false;
                }
                LikeHelper.this.LJIIIZ = false;
                LikeHelper likeHelper = LikeHelper.this;
                int i = likeHelper.LJFF;
                for (2Tc next : likeHelper.LJJIFFI) {
                    if (next != null) {
                        next.setVisibility(8);
                    }
                }
                for (H3C LIZ2 : likeHelper.LIZLLL) {
                    LIZ2.LIZ(likeHelper, i);
                }
                return true;
            }
        });
        boolean z5 = z;
        this.LJIIL = z5;
        boolean z6 = z2;
        this.LJJIJIIJIL = z6;
        boolean z7 = z3;
        this.LJJIJIL = z7;
        C3985H2s value = DiggParamsSetting.INSTANCE.getValue();
        if (value == null || value.LIZIZ <= 0) {
            j = 500;
        } else {
            j = value.LIZIZ;
        }
        this.LJJIII = j;
        int i4 = 15;
        Room room2 = room;
        if (room2 != null && room2.likeInfo != null && room2.likeInfo.LIZ.intValue() > 0) {
            i = room2.likeInfo.LIZ.intValue();
        } else if (value == null || value.LIZLLL <= 0) {
            i = 15;
        } else {
            i = value.LIZLLL;
        }
        this.LJI = i;
        if (room2 != null && room2.likeInfo != null && room2.likeInfo.LIZIZ.intValue() > 0) {
            i2 = room2.likeInfo.LIZIZ.intValue();
        } else if (value == null || value.LJFF <= 0) {
            i2 = 1;
        } else {
            i2 = value.LJFF;
        }
        this.LJII = i2;
        if (value != null) {
            z4 = value.LJI;
        } else {
            z4 = false;
        }
        this.LJJIIJ = z4;
        if (value != null && value.LIZLLL > 0) {
            i4 = value.LIZLLL;
        }
        this.LJJIIZI = i4;
        if (value == null || value.LJ <= 0) {
            i3 = 80;
        } else {
            i3 = value.LJ;
        }
        this.LJJIJ = i3;
        if (value == null || value.LJII == 0) {
            j2 = 300;
        } else {
            j2 = value.LJII;
        }
        this.LJIIIIZZ = j2;
        1hK r4 = r17;
        this.LIZIZ = r4;
        0CH r0 = r18;
        this.LIZ = r0;
        r0.getLifecycle().LIZ(this);
        this.LJJII = new H38(new GestureDetector(r4, new C3981H2o(this, (byte) 0)));
        ArrayList arrayList = new ArrayList();
        this.LIZLLL = arrayList;
        arrayList.add(new C3986H2t(this, (byte) 0));
        this.LIZJ = room2;
        if (8uQ.LIZ(r4, "feed_live_span", 0).getInt("span_count", 0) > 1) {
            str = "live_small_picture";
        } else {
            str = "live_big_picture";
        }
        this.LJIIJJI = str;
        options.inPreferredConfig = Bitmap.Config.ARGB_8888;
        DataChannel dataChannel2 = dataChannel;
        this.LJIIZILJ = dataChannel2;
        this.LJIILIIL = LJJ();
        dataChannel2.LIZ(dataChannel2.LIZIZ(), C1064Fv7.class, new H31(this, dataChannel2, room2, z5, z6, z7));
        String valueOf = String.valueOf(SystemClock.uptimeMillis());
        hashMap.put(valueOf, ((LikeApi) 0yx.LIZ().LIZ(LikeApi.class)).getIcons(this.LIZJ.getId(), this.LIZJ.getOwnerUserId()).LIZIZ(PhE.LIZIZ(PlI.LIZJ)).LIZ(new H32(SystemClock.uptimeMillis()), false).LIZ(H34.LIZ).LIZ(Mk2.LIZ(Mk3.LIZ)).LIZ(new C3982H2p(this), new H3B(this, valueOf), new H3G(this, valueOf)));
        LJIJJLI();
        C3975H2i.LJII = room2;
        C3975H2i.LJIIIIZZ = SystemClock.uptimeMillis();
    }
}
