package com.ss.android.ugc.aweme.choosemusic.widgets;

import X.0Bs;
import X.0Bv;
import X.0Bx;
import X.0By;
import X.0CB;
import X.0CH;
import X.0CM;
import X.1hK;
import X.2GD;
import X.33g;
import X.5Fn;
import X.6Is;
import X.6ZR;
import X.7eA;
import X.7eB;
import X.C5238ONt;
import X.C5345ORw;
import X.C5348ORz;
import X.C5371OSw;
import X.C5378OTd;
import X.C5397OTw;
import X.C5415OUo;
import X.C5464OWl;
import X.C5502OXx;
import X.C5503OXy;
import X.C5504OXz;
import X.C5530OYz;
import X.OGV;
import X.OSU;
import X.OSX;
import X.OTM;
import X.OVT;
import X.OWZ;
import X.OX0;
import X.OX4;
import X.OYQ;
import X.OYR;
import android.util.Pair;
import androidx.fragment.app.Fragment;
import com.bytedance.covode.number.Covode;
import com.ss.android.ugc.aweme.arch.widgets.ListItemWidget;
import com.ss.android.ugc.aweme.arch.widgets.base.DataCenter;
import com.ss.android.ugc.aweme.music.model.Music;
import com.ss.android.ugc.aweme.shortvideo.model.MusicModel;
import com.ss.android.ugc.aweme.shortvideo.model.MusicWaveBean;
import java.util.List;

public class StickerMusicWidget extends ListItemWidget<OX4> implements 0CM<33g>, 6Is {
    public Fragment LJII;
    public OTM LJIIIIZZ = OTM.LJIILL;
    public C5415OUo LJIIIZ;
    public int LJIIJ;
    public int LJIIJJI;
    public OSX LJIIL;
    public C5397OTw<OVT> LJIILIIL;
    public C5530OYz LJIILJJIL;
    public long LJIILL;
    public long LJIILLIIL;
    public int LJIIZILJ = -1;
    public int LJIJ;
    public List<Music> LJIJI;

    static {
        Covode.recordClassIndex(56541);
    }

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

    public final void LJ() {
        this.LJIIIZ.LIZ((MusicModel) null);
    }

    private boolean LJI() {
        if (this.LJIILL == 0 && this.LJIILLIIL == 0) {
            return false;
        }
        return true;
    }

    private void LJFF() {
        if (5Fn.LIZ(this.LJIJI)) {
            this.LIZ.itemView.setVisibility(8);
            return;
        }
        List<MusicModel> LIZ = C5348ORz.LIZ(this.LJIJI);
        this.LIZ.itemView.setVisibility(0);
        ((C5464OWl) this.LIZ).LIZ(LIZ, ((Integer) this.LJ.LIZIZ("music_position", -1)).intValue(), this.LJIIZILJ, ((Boolean) this.LJ.LIZIZ("data_sticker_music_from_video", false)).booleanValue(), (String) this.LJ.LIZIZ("sticker_id", (Object) null), new OWZ(this), this.LJIILIIL, new OYR() {
            static {
                Covode.recordClassIndex(56542);
            }

            public final int LIZ() {
                return StickerMusicWidget.this.LJIIIZ.LJI();
            }

            public final void LIZ(MusicModel musicModel, int i) {
                String str;
                if (StickerMusicWidget.this.LJIIIZ != null) {
                    int LJI = (int) ((((double) i) / 100.0d) * ((double) StickerMusicWidget.this.LJIIIZ.LJI()));
                    int LJII = StickerMusicWidget.this.LJIIIZ.LJII();
                    StickerMusicWidget.this.LJIIIZ.LIZ(LJI, (7eB) null);
                    if (LJI > LJII) {
                        str = "right";
                    } else {
                        str = "left";
                    }
                    if (musicModel != null) {
                        C5371OSw.LIZ.LIZ(C5371OSw.LIZIZ.LIZ(StickerMusicWidget.this.LJIIL, musicModel.getMusicId()), musicModel.getDuration(), str);
                    }
                }
            }
        }, LJI());
    }

    public void onCreate() {
        DataCenter dataCenter = this.LJ;
        dataCenter.LIZ("data_sticker", this);
        dataCenter.LIZ("music_index", this);
        dataCenter.LIZ("music_collect_status", this);
        dataCenter.LIZ("music_loading", this);
        dataCenter.LIZ("music_reset_play_start", this);
        this.LJIJ = ((Integer) this.LJ.LIZ("key_choose_music_type")).intValue();
        StickerMusicWidget.super.onCreate();
        OSX osx = new OSX("change_music_page", "attached_song", "", OSU.LIZ);
        this.LJIIL = osx;
        osx.LIZIZ = "prop";
        this.LJIIL.LJFF = (String) this.LJ.LIZIZ("sticker_id", (Object) null);
    }

    public static 0Bx LIZ(1hK r2) {
        0Bx LIZ = 0By.LIZ(r2, (0Bv) null);
        if (2GD.LIZ) {
            0Bs.LIZ(LIZ, r2);
        }
        return LIZ;
    }

    public final void LIZ(OYQ oyq) {
        super.LIZ(oyq);
        this.LJIJI = (List) this.LJ.LIZIZ("data_sticker", (Object) null);
        LJFF();
    }

    /* JADX WARNING: Can't fix incorrect switch cases order */
    /* Code decompiled incorrectly, please refer to instructions dump. */
    public /* synthetic */ void onChanged(java.lang.Object r9) {
        /*
            r8 = this;
            X.33g r9 = (X.33g) r9
            if (r9 == 0) goto L_0x001f
            java.lang.String r7 = r9.LIZ
            r7.hashCode()
            int r0 = r7.hashCode()
            java.lang.String r4 = "music_loading"
            java.lang.String r1 = "music_reset_play_start"
            java.lang.String r2 = "music_index"
            r6 = 0
            r3 = 1
            r5 = -1
            switch(r0) {
                case -1635157503: goto L_0x0141;
                case 199458657: goto L_0x0136;
                case 502104354: goto L_0x012b;
                case 1579846200: goto L_0x0120;
                case 1730565544: goto L_0x0113;
                default: goto L_0x0019;
            }
        L_0x0019:
            r0 = -1
        L_0x001a:
            java.lang.String r7 = "music_position"
            switch(r0) {
                case 0: goto L_0x00a8;
                case 1: goto L_0x006a;
                case 2: goto L_0x0020;
                case 3: goto L_0x015a;
                case 4: goto L_0x014e;
                default: goto L_0x001f;
            }
        L_0x001f:
            return
        L_0x0020:
            X.OYQ r0 = r8.LIZ
            if (r0 == 0) goto L_0x001f
            com.ss.android.ugc.aweme.arch.widgets.base.DataCenter r0 = r8.LJ
            java.lang.Object r0 = r0.LIZ(r7)
            java.lang.Integer r0 = (java.lang.Integer) r0
            if (r0 != 0) goto L_0x0065
        L_0x002e:
            int r0 = r8.LJIIJ
            if (r0 != r5) goto L_0x0058
            X.OYQ r5 = r8.LIZ
            X.OWl r5 = (X.C5464OWl) r5
            com.ss.android.ugc.aweme.arch.widgets.base.DataCenter r0 = r8.LJ
            java.lang.Object r0 = r0.LIZ(r2)
            java.lang.Integer r0 = (java.lang.Integer) r0
            int r2 = r0.intValue()
            com.ss.android.ugc.aweme.arch.widgets.base.DataCenter r0 = r8.LJ
            java.lang.Object r0 = r0.LIZ(r4)
            java.lang.Boolean r0 = (java.lang.Boolean) r0
            boolean r1 = r0.booleanValue()
            if (r2 < 0) goto L_0x0058
            java.util.List<X.OX0> r0 = r5.LIZJ
            int r0 = r0.size()
            if (r2 < r0) goto L_0x0059
        L_0x0058:
            return
        L_0x0059:
            java.util.List<X.OX0> r0 = r5.LIZJ
            java.lang.Object r0 = r0.get(r2)
            X.OWq r0 = (X.C5469OWq) r0
            r0.LIZ((boolean) r1, (boolean) r3)
            goto L_0x0058
        L_0x0065:
            int r5 = r0.intValue()
            goto L_0x002e
        L_0x006a:
            X.OYQ r0 = r8.LIZ
            if (r0 == 0) goto L_0x001f
            X.OYQ r3 = r8.LIZ
            X.OWl r3 = (X.C5464OWl) r3
            int r2 = r8.LJIIZILJ
            com.ss.android.ugc.aweme.arch.widgets.base.DataCenter r0 = r8.LJ
            java.lang.Object r1 = r0.LIZ(r1)
            android.util.Pair r1 = (android.util.Pair) r1
            if (r2 < 0) goto L_0x0086
            java.util.List<X.OX0> r0 = r3.LIZJ
            int r0 = r0.size()
            if (r2 < r0) goto L_0x0087
        L_0x0086:
            return
        L_0x0087:
            java.util.List<X.OX0> r0 = r3.LIZJ
            java.lang.Object r3 = r0.get(r2)
            X.OX0 r3 = (X.OX0) r3
            java.lang.Object r0 = r1.first
            java.lang.Integer r0 = (java.lang.Integer) r0
            int r2 = r0.intValue()
            java.lang.Object r0 = r1.second
            java.lang.Float r0 = (java.lang.Float) r0
            float r1 = r0.floatValue()
            r0 = 1120403456(0x42c80000, float:100.0)
            float r1 = r1 * r0
            int r0 = (int) r1
            r3.LIZ(r2, r0)
            goto L_0x001f
        L_0x00a8:
            java.lang.Object r5 = r9.LIZ()
            X.OVS r5 = (X.OVS) r5
            int r0 = r5.LIZ
            if (r0 != r3) goto L_0x00b8
            int r1 = r8.LJIIJ
            int r0 = r5.LIZIZ
            if (r1 == r0) goto L_0x00bc
        L_0x00b8:
            int r0 = r5.LIZ
            if (r0 != 0) goto L_0x001f
        L_0x00bc:
            X.OYQ r0 = r8.LIZ
            if (r0 == 0) goto L_0x001f
            X.OYQ r1 = r8.LIZ
            X.OWl r1 = (X.C5464OWl) r1
            java.util.List<X.OX0> r0 = r1.LIZJ
            boolean r0 = X.878.LIZ(r0)
            if (r0 != 0) goto L_0x001f
            java.util.List<X.OX0> r0 = r1.LIZJ
            java.util.Iterator r4 = r0.iterator()
        L_0x00d2:
            boolean r0 = r4.hasNext()
            if (r0 == 0) goto L_0x001f
            java.lang.Object r2 = r4.next()
            X.OWq r2 = (X.C5469OWq) r2
            com.ss.android.ugc.aweme.shortvideo.model.MusicModel r1 = r5.LJ
            if (r1 == 0) goto L_0x00d2
            java.lang.String r0 = r1.getMusicId()
            boolean r0 = android.text.TextUtils.isEmpty(r0)
            if (r0 != 0) goto L_0x00d2
            com.ss.android.ugc.aweme.shortvideo.model.MusicModel r0 = r2.LJJIFFI
            if (r0 == 0) goto L_0x00d2
            java.lang.String r1 = r1.getMusicId()
            com.ss.android.ugc.aweme.shortvideo.model.MusicModel r0 = r2.LJJIFFI
            java.lang.String r0 = r0.getMusicId()
            boolean r0 = r1.equals(r0)
            if (r0 == 0) goto L_0x00d2
            com.ss.android.ugc.aweme.shortvideo.model.MusicModel r1 = r2.LJJIFFI
            int r0 = r5.LIZLLL
            if (r0 != r3) goto L_0x0110
            com.ss.android.ugc.aweme.shortvideo.model.MusicModel$CollectionType r0 = com.ss.android.ugc.aweme.shortvideo.model.MusicModel.CollectionType.COLLECTED
        L_0x0108:
            r1.setCollectionType(r0)
            r2.LJ()
            goto L_0x001f
        L_0x0110:
            com.ss.android.ugc.aweme.shortvideo.model.MusicModel$CollectionType r0 = com.ss.android.ugc.aweme.shortvideo.model.MusicModel.CollectionType.NOT_COLLECTED
            goto L_0x0108
        L_0x0113:
            java.lang.String r0 = "data_sticker"
            boolean r0 = r7.equals(r0)
            if (r0 != 0) goto L_0x011d
            goto L_0x0019
        L_0x011d:
            r0 = 4
            goto L_0x001a
        L_0x0120:
            boolean r0 = r7.equals(r2)
            if (r0 != 0) goto L_0x0128
            goto L_0x0019
        L_0x0128:
            r0 = 3
            goto L_0x001a
        L_0x012b:
            boolean r0 = r7.equals(r4)
            if (r0 != 0) goto L_0x0133
            goto L_0x0019
        L_0x0133:
            r0 = 2
            goto L_0x001a
        L_0x0136:
            boolean r0 = r7.equals(r1)
            if (r0 != 0) goto L_0x013e
            goto L_0x0019
        L_0x013e:
            r0 = 1
            goto L_0x001a
        L_0x0141:
            java.lang.String r0 = "music_collect_status"
            boolean r0 = r7.equals(r0)
            if (r0 != 0) goto L_0x014b
            goto L_0x0019
        L_0x014b:
            r0 = 0
            goto L_0x001a
        L_0x014e:
            java.lang.Object r0 = r9.LIZ()
            java.util.List r0 = (java.util.List) r0
            r8.LJIJI = r0
            r8.LJFF()
            return
        L_0x015a:
            com.ss.android.ugc.aweme.arch.widgets.base.DataCenter r1 = r8.LJ
            java.lang.Integer r0 = java.lang.Integer.valueOf(r5)
            java.lang.Object r0 = r1.LIZIZ(r7, r0)
            java.lang.Integer r0 = (java.lang.Integer) r0
            int r4 = r0.intValue()
            com.ss.android.ugc.aweme.arch.widgets.base.DataCenter r1 = r8.LJ
            java.lang.Integer r0 = java.lang.Integer.valueOf(r5)
            java.lang.Object r0 = r1.LIZIZ(r2, r0)
            java.lang.Integer r0 = (java.lang.Integer) r0
            int r3 = r0.intValue()
            boolean r0 = r8.bl_()
            if (r0 == 0) goto L_0x01af
            X.OYQ r2 = r8.LIZ
            X.OWl r2 = (X.C5464OWl) r2
            int r1 = r8.LJIIZILJ
            if (r1 < 0) goto L_0x0190
            java.util.List<X.OX0> r0 = r2.LIZJ
            int r0 = r0.size()
            if (r1 < r0) goto L_0x0196
        L_0x0190:
            r0 = -2
            if (r4 == r0) goto L_0x01a2
            r8.LJIIZILJ = r5
            return
        L_0x0196:
            java.util.List<X.OX0> r0 = r2.LIZJ
            java.lang.Object r0 = r0.get(r1)
            X.OWq r0 = (X.C5469OWq) r0
            r0.LIZ((boolean) r6, (boolean) r6)
            goto L_0x0190
        L_0x01a2:
            int r0 = r8.LJIIZILJ
            if (r0 != r3) goto L_0x01ad
            X.OUo r1 = r8.LJIIIZ
            r0 = 0
            r1.LIZ((com.ss.android.ugc.aweme.shortvideo.model.MusicModel) r0)
            return
        L_0x01ad:
            r8.LJIIZILJ = r3
        L_0x01af:
            return
        */
        throw new UnsupportedOperationException("Method not decompiled: com.ss.android.ugc.aweme.choosemusic.widgets.StickerMusicWidget.onChanged(java.lang.Object):void");
    }

    public final void LIZ(OX0 ox0, final MusicModel musicModel) {
        if (this.LJIIZILJ == ox0.LJJII && ((Integer) this.LJ.LIZIZ("music_position", -1)).intValue() == -2) {
            this.LJ.LIZ("music_position", -1);
            this.LJ.LIZ("music_index", -1);
            LJ();
            return;
        }
        if (this.LJIIIZ != null) {
            LJ();
            OSU.LIZJ = ox0.LJJII;
            final OSX osx = new OSX("change_music_page", "prop", "", OSU.LIZ);
            osx.LJFF = (String) this.LJ.LIZIZ("sticker_id", (Object) null);
            int LIZLLL = C5238ONt.LIZ.LIZLLL();
            if (LIZLLL == 0) {
                this.LJIIIZ.LIZ((C5345ORw) new C5502OXx(this));
                this.LJIIIZ.LIZ(musicModel, osx);
            } else if (LIZLLL != 1) {
                if (LIZLLL == 2) {
                    this.LJIIIZ.LIZ((7eA) new 7eA() {
                        static {
                            Covode.recordClassIndex(56544);
                        }

                        public final void LIZ(int i, float f) {
                            StickerMusicWidget.this.LJIIIIZZ.LIZ(f);
                        }
                    });
                    this.LJIIIZ.LIZ((C5345ORw) new C5504OXz(this));
                    if (OTM.LJIIJ == ox0.LJJIFFI) {
                        this.LJIIIZ.LIZ(musicModel, osx);
                    } else {
                        this.LJIIIIZZ.LIZ(this.LJIIIZ);
                        this.LJIIIIZZ.LIZ();
                        this.LJIIIIZZ.LIZ(ox0.itemView, ox0.LJJIFFI);
                        C5378OTd oTd = new C5378OTd();
                        oTd.LIZJ = 20.0f;
                        oTd.LIZLLL = 3.0f;
                        oTd.LJI = 104.0f;
                        this.LJIIIIZZ.LIZ(oTd);
                        OTM.LIZIZ = new OGV() {
                            static {
                                Covode.recordClassIndex(56545);
                            }

                            public final void LIZ(MusicWaveBean musicWaveBean) {
                                StickerMusicWidget.this.LJIIIZ.LIZ(musicModel, osx);
                            }
                        };
                        this.LJIIIIZZ.LIZJ(musicModel);
                    }
                }
            }
            this.LJIIIZ.LIZ((C5345ORw) new C5503OXy(this));
            this.LJIIIZ.LIZ((7eA) new 7eA() {
                static {
                    Covode.recordClassIndex(56543);
                }

                public final void LIZ(int i, float f) {
                    6ZR.LIZ("current Play Time:" + i + " progress:" + f);
                    StickerMusicWidget.this.LJ.LIZ("music_reset_play_start", new Pair(Integer.valueOf(i), Float.valueOf(f)));
                }
            });
            this.LJIIIZ.LIZ(musicModel, osx);
        }
        this.LJ.LIZ("music_position", -2);
        this.LJ.LIZ("music_index", Integer.valueOf(ox0.LJJII));
        this.LJ.LIZ("music_loading", true);
    }
}
