package com.bytedance.android.livesdk.interaction.poll.ui.progresseffect.widget;

import X.0CB;
import X.0CH;
import X.0HH;
import X.0b0;
import X.0bX;
import X.0cm;
import X.1jk;
import X.1sP;
import X.6Is;
import X.C1193FxC;
import X.C1430G2l;
import X.C2205GWg;
import X.C2434Gc7;
import X.C2675Gg0;
import X.GTD;
import X.GTR;
import X.GTV;
import X.GW9;
import X.GWE;
import X.GWH;
import X.Mjy;
import X.NuT;
import X.NuV;
import X.QxX;
import android.content.Context;
import android.content.res.Configuration;
import android.content.res.Resources;
import android.text.TextUtils;
import androidx.constraintlayout.widget.ConstraintLayout;
import com.bytedance.android.live.base.model.ImageModel;
import com.bytedance.android.live.gift.IGiftService;
import com.bytedance.android.livesdk.model.Gift;
import com.bytedance.android.livesdk.model.message.PollOptionInfo;
import com.bytedance.covode.number.Covode;
import com.bytedance.ies.sdk.datachannel.DataChannel;
import java.util.Arrays;
import java.util.List;
import java.util.Locale;
import java.util.Objects;
import kotlin.h.b.n;
import kotlin.o.y;

public final class LiveGiftPollEffectWidget extends LiveAbsPollEffectWidget implements 6Is {
    public 1sP LJIILLIIL;
    public 1sP LJIIZILJ;
    public final int LJIJ;
    public final int LJIJI;
    public final int LJIJJ;
    public 1jk LJIJJLI;
    public 1jk LJIL;
    public final Mjy LJJ;
    public ConstraintLayout LJJI;

    static {
        Covode.recordClassIndex(17305);
    }

    public LiveGiftPollEffectWidget(byte b) {
        this();
    }

    public final void LIZ(int i) {
    }

    public final int getLayoutId() {
        return 2131561790;
    }

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

    public /* synthetic */ LiveGiftPollEffectWidget() {
        this(0);
    }

    public final void onUnload() {
        super.onUnload();
        this.LJJ.LIZ();
    }

    public final void LJIILIIL() {
        if (!this.LJII) {
            this.LJII = true;
            GTR.LIZIZ.LIZ(this.LJ, this.dataChannel, this.LJIIL, GTD.GIFT);
        }
    }

    public final void hide() {
        DataChannel dataChannel;
        super.hide();
        if (this.LJIJ == 257 && (dataChannel = this.dataChannel) != null) {
            dataChannel.LIZIZ(C1193FxC.class, false);
        }
    }

    public final void show() {
        DataChannel dataChannel;
        super.show();
        if (this.LJIJ == 257 && (dataChannel = this.dataChannel) != null) {
            dataChannel.LIZIZ(C1193FxC.class, true);
        }
    }

    /* JADX WARNING: Code restructure failed: missing block: B:25:0x004d, code lost:
        if ((true ^ kotlin.h.b.n.LIZ(r2, true)) != false) goto L_0x0027;
     */
    /* Code decompiled incorrectly, please refer to instructions dump. */
    public final void LJ() {
        /*
            r4 = this;
            super.LJ()
            int r1 = r4.LJIJ
            r0 = 257(0x101, float:3.6E-43)
            if (r1 != r0) goto L_0x0052
            java.util.List<com.bytedance.android.livesdk.model.message.PollOptionInfo> r0 = r4.LIZLLL
            if (r0 == 0) goto L_0x0027
            java.util.List<com.bytedance.android.livesdk.model.message.PollOptionInfo> r0 = r4.LIZLLL
            if (r0 == 0) goto L_0x0027
            int r1 = r0.size()
            r0 = 2
            if (r1 < r0) goto L_0x0027
            com.bytedance.android.livesdk.model.message.PollMessage r0 = r4.LJ
            r2 = 0
            if (r0 == 0) goto L_0x0050
            java.lang.Integer r3 = r0.LJFF
        L_0x001f:
            X.GTD r0 = X.GTD.GIFT
            int r1 = r0.ordinal()
            if (r3 != 0) goto L_0x002b
        L_0x0027:
            r4.hide()
            return
        L_0x002b:
            int r0 = r3.intValue()
            if (r0 != r1) goto L_0x0027
            com.bytedance.android.livesdkapi.depend.model.live.Room r0 = r4.LJI
            if (r0 == 0) goto L_0x0052
            boolean r0 = r0.giftPollVoteEnabled
            if (r0 != 0) goto L_0x0052
            com.bytedance.ies.sdk.datachannel.DataChannel r1 = r4.dataChannel
            if (r1 == 0) goto L_0x0043
            java.lang.Class<X.Fv2> r0 = X.C1059Fv2.class
            java.lang.Object r2 = r1.LIZIZ(r0)
        L_0x0043:
            r1 = 1
            java.lang.Boolean r0 = java.lang.Boolean.valueOf(r1)
            boolean r0 = kotlin.h.b.n.LIZ(r2, r0)
            r1 = r1 ^ r0
            if (r1 == 0) goto L_0x0052
            goto L_0x0027
        L_0x0050:
            r3 = r2
            goto L_0x001f
        L_0x0052:
            r4.show()
            r4.LJFF()
            r4.LJIIJJI()
            return
        */
        throw new UnsupportedOperationException("Method not decompiled: com.bytedance.android.livesdk.interaction.poll.ui.progresseffect.widget.LiveGiftPollEffectWidget.LJ():void");
    }

    public final void LJIIIIZZ() {
        ImageModel imageModel;
        Gift gift;
        Gift gift2;
        super.LJIIIIZZ();
        IGiftService LIZ = 0cm.LIZ(IGiftService.class);
        n.LIZIZ(LIZ, "");
        GWE pollGifts = LIZ.getPollGifts();
        if (this.LJIJ != 257) {
            1sP r1 = this.LJIILLIIL;
            ImageModel imageModel2 = null;
            if (pollGifts == null || (gift2 = pollGifts.LIZ) == null) {
                imageModel = null;
            } else {
                imageModel = gift2.LIZIZ;
            }
            0bX.LIZIZ(r1, imageModel);
            1sP r12 = this.LJIIZILJ;
            if (!(pollGifts == null || (gift = pollGifts.LIZIZ) == null)) {
                imageModel2 = gift.LIZIZ;
            }
            0bX.LIZIZ(r12, imageModel2);
        }
        1sP r0 = this.LJIILLIIL;
        if (r0 != null) {
            r0.setAlpha(1.0f);
        }
        1sP r02 = this.LJIIZILJ;
        if (r02 != null) {
            r02.setAlpha(1.0f);
        }
    }

    public final void LJIIIZ() {
        1sP r0;
        ImageModel imageModel;
        super.LJIIIZ();
        IGiftService LIZ = 0cm.LIZ(IGiftService.class);
        n.LIZIZ(LIZ, "");
        GWE pollGifts = LIZ.getPollGifts();
        if (this.LJIJ != 257) {
            1sP r2 = this.LJIILLIIL;
            ImageModel imageModel2 = null;
            if (pollGifts != null) {
                imageModel = pollGifts.LIZJ;
            } else {
                imageModel = null;
            }
            0bX.LIZIZ(r2, imageModel);
            1sP r02 = this.LJIIZILJ;
            if (pollGifts != null) {
                imageModel2 = pollGifts.LIZLLL;
            }
            0bX.LIZIZ(r02, imageModel2);
        }
        if (this.LJIJ == 257) {
            int i = this.LJIIJJI;
            if (i == 1) {
                1sP r03 = this.LJIIZILJ;
                if (r03 != null) {
                    r03.setAlpha(0.4f);
                }
            } else if (i == 2 && (r0 = this.LJIILLIIL) != null) {
                r0.setAlpha(0.4f);
            }
        }
    }

    public final void LIZIZ() {
        ImageModel imageModel;
        Gift gift;
        Gift gift2;
        super.LIZIZ();
        IGiftService LIZ = 0cm.LIZ(IGiftService.class);
        n.LIZIZ(LIZ, "");
        GWE pollGifts = LIZ.getPollGifts();
        QxX findViewById = findViewById(2131367197);
        n.LIZIZ(findViewById, "");
        LIZ(findViewById);
        this.LJIILLIIL = this.contentView.findViewById(2131368644);
        this.LJIIZILJ = this.contentView.findViewById(2131368650);
        this.LJIJJLI = this.contentView.findViewById(2131368653);
        this.LJIL = this.contentView.findViewById(2131368647);
        if (!LIZ(this.context)) {
            1jk r2 = this.LJIL;
            if (r2 != null) {
                r2.setTypeface(NuT.LIZ().LIZ(NuV.LIZIZ), 2);
            }
            1jk r22 = this.LJIJJLI;
            if (r22 != null) {
                r22.setTypeface(NuT.LIZ().LIZ(NuV.LIZIZ), 2);
            }
        }
        this.LJJI = this.contentView.findViewById(2131365348);
        1sP r1 = this.LJIILLIIL;
        ImageModel imageModel2 = null;
        if (pollGifts == null || (gift2 = pollGifts.LIZ) == null) {
            imageModel = null;
        } else {
            imageModel = gift2.LJJ;
        }
        0bX.LIZIZ(r1, imageModel);
        1sP r12 = this.LJIIZILJ;
        if (!(pollGifts == null || (gift = pollGifts.LIZIZ) == null)) {
            imageModel2 = gift.LJJ;
        }
        0bX.LIZIZ(r12, imageModel2);
        this.LJJ.LIZ(C2675Gg0.LIZ().LIZ(C2205GWg.class).LIZLLL(new GW9(this)));
        DataChannel dataChannel = this.dataChannel;
        if (dataChannel != null) {
            dataChannel.LIZ((0CH) this, C2434Gc7.class, new GTV(this));
        }
    }

    /* JADX DEBUG: Multi-variable search result rejected for TypeSearchVarInfo{r3v1, resolved type: com.bytedance.android.livesdk.model.message.PollStartContent} */
    /* JADX WARNING: type inference failed for: r3v0 */
    /* JADX WARNING: type inference failed for: r3v3, types: [android.view.ViewGroup$LayoutParams] */
    /* JADX WARNING: type inference failed for: r3v5 */
    /* JADX WARNING: type inference failed for: r3v6 */
    /* JADX WARNING: type inference failed for: r3v7 */
    /* JADX WARNING: Multi-variable type inference failed */
    /* Code decompiled incorrectly, please refer to instructions dump. */
    public final void LIZJ() {
        /*
            r5 = this;
            super.LIZJ()
            int r0 = r5.LJIJ
            r3 = 0
            switch(r0) {
                case 257: goto L_0x0010;
                case 258: goto L_0x0095;
                case 259: goto L_0x000a;
                default: goto L_0x0009;
            }
        L_0x0009:
            return
        L_0x000a:
            X.GTD r0 = X.GTD.GIFT
            r5.LIZ((X.GTD) r0)
            goto L_0x0009
        L_0x0010:
            X.1sP r0 = r5.LJIILLIIL
            if (r0 == 0) goto L_0x0093
            android.view.ViewGroup$LayoutParams r4 = r0.getLayoutParams()
        L_0x0018:
            X.1sP r1 = r5.LJIILLIIL
            r0 = 1105723392(0x41e80000, float:29.0)
            int r0 = X.0b0.LIZ(r0)
            X.C1430G2l.LJII(r1, r0)
            r2 = 1103101952(0x41c00000, float:24.0)
            if (r4 == 0) goto L_0x0033
            int r0 = X.0b0.LIZ(r2)
            r4.height = r0
            int r0 = X.0b0.LIZ(r2)
            r4.width = r0
        L_0x0033:
            X.1sP r0 = r5.LJIILLIIL
            if (r0 == 0) goto L_0x003a
            r0.setLayoutParams(r4)
        L_0x003a:
            X.1sP r0 = r5.LJIIZILJ
            if (r0 == 0) goto L_0x0091
            android.view.ViewGroup$LayoutParams r1 = r0.getLayoutParams()
            if (r1 == 0) goto L_0x0050
            int r0 = X.0b0.LIZ(r2)
            r1.height = r0
            int r0 = X.0b0.LIZ(r2)
            r1.width = r0
        L_0x0050:
            X.1sP r0 = r5.LJIIZILJ
            if (r0 == 0) goto L_0x0057
            r0.setLayoutParams(r1)
        L_0x0057:
            X.1jk r0 = r5.LJIJJLI
            if (r0 == 0) goto L_0x008f
            android.view.ViewGroup$LayoutParams r2 = r0.getLayoutParams()
        L_0x005f:
            X.1jk r1 = r5.LJIJJLI
            r0 = 1106247680(0x41f00000, float:30.0)
            int r0 = X.0b0.LIZ(r0)
            X.C1430G2l.LJIIIIZZ(r1, r0)
            X.1jk r0 = r5.LJIJJLI
            if (r0 == 0) goto L_0x0071
            r0.setLayoutParams(r2)
        L_0x0071:
            androidx.constraintlayout.widget.ConstraintLayout r0 = r5.LJJI
            if (r0 == 0) goto L_0x0083
            android.view.ViewGroup$LayoutParams r3 = r0.getLayoutParams()
            if (r3 == 0) goto L_0x0083
            r0 = 1129709568(0x43560000, float:214.0)
            int r0 = X.0b0.LIZ(r0)
            r3.width = r0
        L_0x0083:
            androidx.constraintlayout.widget.ConstraintLayout r0 = r5.LJJI
            if (r0 == 0) goto L_0x008a
            r0.setLayoutParams(r3)
        L_0x008a:
            r5.LIZLLL()
            goto L_0x0009
        L_0x008f:
            r2 = r3
            goto L_0x005f
        L_0x0091:
            r1 = r3
            goto L_0x0050
        L_0x0093:
            r4 = r3
            goto L_0x0018
        L_0x0095:
            X.H7O r0 = X.H7O.INSTANCE
            com.bytedance.android.livesdk.model.message.PollMessage r0 = r0.pollMessage
            r5.LJ = r0
            com.bytedance.android.livesdk.model.message.PollMessage r0 = r5.LJ
            if (r0 == 0) goto L_0x00a1
            com.bytedance.android.livesdk.model.message.PollStartContent r3 = r0.LIZJ
        L_0x00a1:
            r5.LIZJ = r3
            return
        */
        throw new UnsupportedOperationException("Method not decompiled: com.bytedance.android.livesdk.interaction.poll.ui.progresseffect.widget.LiveGiftPollEffectWidget.LIZJ():void");
    }

    public final void LJII() {
        long j;
        long j2;
        long j3;
        PollOptionInfo pollOptionInfo;
        PollOptionInfo pollOptionInfo2;
        PollOptionInfo pollOptionInfo3;
        PollOptionInfo pollOptionInfo4;
        super.LJII();
        List<PollOptionInfo> list = this.LIZLLL;
        int i = 0;
        if (list == null || list.size() != 0) {
            List<PollOptionInfo> list2 = this.LIZLLL;
            long j4 = 0;
            if (list2 == null || (pollOptionInfo4 = list2.get(0)) == null) {
                j = 0;
            } else {
                j = pollOptionInfo4.LIZ;
            }
            List<PollOptionInfo> list3 = this.LIZLLL;
            if (list3 == null || (pollOptionInfo3 = list3.get(1)) == null) {
                j2 = 0;
            } else {
                j2 = pollOptionInfo3.LIZ;
            }
            if (j > j2) {
                i = 1;
            } else {
                List<PollOptionInfo> list4 = this.LIZLLL;
                if (list4 == null || (pollOptionInfo2 = list4.get(0)) == null) {
                    j3 = 0;
                } else {
                    j3 = pollOptionInfo2.LIZ;
                }
                List<PollOptionInfo> list5 = this.LIZLLL;
                if (!(list5 == null || (pollOptionInfo = list5.get(1)) == null)) {
                    j4 = pollOptionInfo.LIZ;
                }
                if (j3 < j4) {
                    i = 2;
                }
            }
            this.LJIIJJI = i;
        } else {
            this.LJIIJJI = 0;
        }
        if (this.LJIJ == 257) {
            int i2 = this.LJIIJJI;
            if (i2 == 1) {
                C1430G2l.LJII(this.LJIILLIIL, 0b0.LIZ(39.0f));
                C1430G2l.LJIIIIZZ(this.LJIJJLI, 0b0.LIZ(16.0f));
            } else if (i2 != 2) {
                C1430G2l.LJII(this.LJIILLIIL, 0b0.LIZ(29.0f));
                C1430G2l.LJIIIIZZ(this.LJIJJLI, 0b0.LIZ(30.0f));
            } else {
                C1430G2l.LJII(this.LJIILLIIL, 0b0.LIZ(16.0f));
                C1430G2l.LJIIIIZZ(this.LJIJJLI, 0b0.LIZ(39.0f));
            }
        }
    }

    public final void LIZ(float f) {
        super.LIZ(f);
    }

    public LiveGiftPollEffectWidget(int i) {
        super(i);
        this.LJIJ = i;
        this.LJIJI = 1000000;
        this.LJIJJ = 1000;
        this.LJJ = new Mjy();
    }

    private final String LIZ(String str) {
        if (TextUtils.isEmpty(str) || str.length() <= 3) {
            return str;
        }
        Objects.requireNonNull(str, "null cannot be cast to non-null type java.lang.String");
        String substring = str.substring(0, 4);
        n.LIZIZ(substring, "");
        if (!y.LIZJ(substring, ".", false)) {
            return substring;
        }
        Objects.requireNonNull(substring, "null cannot be cast to non-null type java.lang.String");
        String substring2 = substring.substring(0, 3);
        n.LIZIZ(substring2, "");
        return substring2;
    }

    private final boolean LIZ(Context context) {
        if (context == null) {
            return false;
        }
        Resources resources = context.getResources();
        n.LIZIZ(resources, "");
        Locale locale = resources.getConfiguration().locale;
        n.LIZIZ(locale, "");
        if (!n.LIZ(locale.getLanguage(), "ar")) {
            Resources resources2 = context.getResources();
            n.LIZIZ(resources2, "");
            Configuration configuration = resources2.getConfiguration();
            n.LIZIZ(configuration, "");
            if (configuration.getLayoutDirection() == 1) {
                return true;
            }
            return false;
        }
        return true;
    }

    private final String LIZ(long j) {
        int i = this.LJIJI;
        long j2 = j;
        if (j2 >= ((long) i)) {
            long j3 = j2 * 1;
            if (j2 > ((long) (i * 999))) {
                j3 = ((long) (i * 999)) * 1;
            }
            String LIZ = 0HH.LIZ("%.3f", Arrays.copyOf(new Object[]{Double.valueOf((((double) j3) * 1.0d) / ((double) i))}, 1));
            n.LIZIZ(LIZ, "");
            if (LIZ(this.context)) {
                return LIZ(LIZ) + "m x";
            }
            return "x " + LIZ(LIZ) + "m";
        }
        int i2 = this.LJIJJ;
        if (j2 >= ((long) i2)) {
            String LIZ2 = 0HH.LIZ("%.3f", Arrays.copyOf(new Object[]{Double.valueOf((((double) j2) * 1.0d) / ((double) i2))}, 1));
            n.LIZIZ(LIZ2, "");
            if (LIZ(this.context)) {
                return LIZ(LIZ2) + "k x";
            }
            return "x " + LIZ(LIZ2) + "k";
        } else if (!LIZ(this.context)) {
            return "x ".concat(String.valueOf(j2));
        } else {
            return j2 + " x";
        }
    }

    public final void LIZ(long j, long j2) {
        long j3 = j;
        long j4 = j2;
        if (j3 > this.LJIIIIZZ || j4 > this.LJIIIZ) {
            this.LJIIIIZZ = j3;
            this.LJIIIZ = j4;
            LIZ().LIZ(j3, j4);
            1jk findViewById = this.contentView.findViewById(2131368647);
            1jk findViewById2 = this.contentView.findViewById(2131368653);
            if (LIZ(this.context)) {
                n.LIZIZ(findViewById, "");
                findViewById.setText(LIZ(j3));
                n.LIZIZ(findViewById2, "");
                findViewById2.setText(LIZ(j4));
            } else {
                n.LIZIZ(findViewById, "");
                findViewById.setText(LIZ(j3) + " ");
                n.LIZIZ(findViewById2, "");
                findViewById2.setText(LIZ(j4) + " ");
            }
            LIZ().post(new GWH(this, j3, j4));
        }
    }
}
