package com.ss.android.ugc.aweme.viewmodel;

import X.2K7;
import X.4HR;
import X.4r1;
import X.A4l;
import X.Ak5;
import X.AqM;
import X.C6191FMd;
import X.C6205FMr;
import X.C6207FMt;
import X.Cc1;
import X.DWM;
import X.M12;
import android.os.Bundle;
import android.view.View;
import androidx.fragment.app.Fragment;
import com.bytedance.covode.number.Covode;
import com.bytedance.router.SmartRoute;
import com.bytedance.router.SmartRouter;
import com.ss.android.ugc.aweme.feed.model.Aweme;
import com.ss.android.ugc.aweme.fragments.MentionVideoListFragment;
import kotlin.h.b.n;

public final class MentionMusicVideoVM extends BaseVideoListVM<AqM, Ak5, Long> {
    public String LJFF;
    public final int LJI;

    static {
        Covode.recordClassIndex(123624);
    }

    public final /* synthetic */ 4HR defaultState() {
        return new AqM();
    }

    public static boolean LJII() {
        try {
            return 2K7.LIZ.LIZJ();
        } catch (Exception unused) {
            return false;
        }
    }

    public final void manualListRefresh() {
        withState(new C6191FMd(this));
        super.manualListRefresh();
    }

    public final void newState(DWM<Ak5> dwm) {
        M12.LIZ(dwm);
        setState(new C6207FMt(dwm));
    }

    public final Object onRefresh(4r1<? super A4l<Long>> r8) {
        this.LIZJ = true;
        String str = this.LJFF;
        if (str == null) {
            n.LIZ("");
        }
        return LIZ(str, 0, this.LJ, this.LJI, r8);
    }

    public final /* synthetic */ Object onLoadMore(Object obj, 4r1 r9) {
        long longValue = ((Number) obj).longValue();
        String str = this.LJFF;
        if (str == null) {
            n.LIZ("");
        }
        return LIZ(str, longValue, this.LJ, this.LJI, r9);
    }

    public final void LIZ(View view, Aweme aweme) {
        Fragment fragment;
        if (!Cc1.LIZ(view, 1200) && aweme != null && (fragment = this.LIZIZ) != null && fragment.getActivity() != null && LIZ(this.LIZIZ)) {
            Fragment fragment2 = this.LIZIZ;
            if ((fragment2 instanceof MentionVideoListFragment) && fragment2 != null) {
                MentionVideoListFragment.LJIIIIZZ = new C6205FMr(this.LIZ, aweme);
            }
            Bundle bundle = new Bundle();
            bundle.putString("id", aweme.getAid());
            bundle.putString("refer", "publish_page");
            bundle.putString("previous_page", (String) null);
            bundle.putString("extra_previous_page_position", (String) null);
            bundle.putString("com.ss.android.ugc.aweme.intent.extra.EVENT_TYPE", "");
            bundle.putString("video_from", "from_publish_add_video");
            bundle.putString("video_challenge_profile_from", "");
            bundle.putInt("video_type", 0);
            bundle.putInt("profile_enterprise_type", aweme.getEnterpriseType());
            bundle.putString("process_id", (String) null);
            bundle.putString("duo_type", "duo_detail");
            bundle.putString("extra_parent_tag_id", (String) null);
            String str = this.LJFF;
            if (str == null) {
                n.LIZ("");
            }
            bundle.putString("music_id", str);
            bundle.putString("from_group_id", (String) null);
            bundle.putString("mention_video_author_uid", aweme.getAuthorUid());
            SmartRoute buildFragmentRoute = SmartRouter.buildFragmentRoute(this.LIZIZ, "aweme://aweme/detail/");
            buildFragmentRoute.withParam(bundle);
            buildFragmentRoute.withParam("activity_has_activity_options", true);
            buildFragmentRoute.open(9);
        }
    }

    /* JADX WARNING: Removed duplicated region for block: B:14:0x0048  */
    /* JADX WARNING: Removed duplicated region for block: B:25:0x00aa A[Catch:{ Exception -> 0x0133 }] */
    /* JADX WARNING: Removed duplicated region for block: B:34:0x00d0 A[Catch:{ Exception -> 0x0140 }] */
    /* JADX WARNING: Removed duplicated region for block: B:39:0x00dd A[Catch:{ Exception -> 0x0140 }] */
    /* JADX WARNING: Removed duplicated region for block: B:54:0x010e A[Catch:{ Exception -> 0x0140 }] */
    /* JADX WARNING: Removed duplicated region for block: B:58:0x011f A[Catch:{ Exception -> 0x0140 }] */
    /* JADX WARNING: Removed duplicated region for block: B:60:0x012b A[Catch:{ Exception -> 0x0140 }] */
    /* JADX WARNING: Removed duplicated region for block: B:72:0x0145  */
    /* JADX WARNING: Removed duplicated region for block: B:7:0x0024  */
    /* Code decompiled incorrectly, please refer to instructions dump. */
    public final java.lang.Object LIZ(java.lang.String r18, long r19, int r21, int r22, X.4r1<? super X.A4l<java.lang.Long>> r23) {
        /*
            r17 = this;
            r3 = r17
            r2 = r23
            boolean r0 = r2 instanceof X.C6197FMj
            if (r0 == 0) goto L_0x0031
            r10 = r2
            X.FMj r10 = (X.C6197FMj) r10
            int r0 = r10.label
            r1 = -2147483648(0xffffffff80000000, float:-0.0)
            r0 = r0 & r1
            if (r0 == 0) goto L_0x0031
            int r0 = r10.label
            int r0 = r0 - r1
            r10.label = r0
        L_0x0017:
            java.lang.Object r8 = r10.result
            X.Cof r9 = X.C0213Cof.COROUTINE_SUSPENDED
            int r0 = r10.label
            r2 = 2
            r4 = 0
            java.lang.String r5 = ""
            r7 = 1
            if (r0 == 0) goto L_0x0048
            if (r0 == r7) goto L_0x003f
            if (r0 != r2) goto L_0x0037
            java.lang.Object r6 = r10.L$1
            java.util.ArrayList r6 = (java.util.ArrayList) r6
            java.lang.Object r3 = r10.L$0
            com.ss.android.ugc.aweme.viewmodel.MentionMusicVideoVM r3 = (com.ss.android.ugc.aweme.viewmodel.MentionMusicVideoVM) r3
            goto L_0x00ac
        L_0x0031:
            X.FMj r10 = new X.FMj
            r10.<init>(r3, r2)
            goto L_0x0017
        L_0x0037:
            java.lang.IllegalStateException r1 = new java.lang.IllegalStateException
            java.lang.String r0 = "call to 'resume' before 'invoke' with coroutine"
            r1.<init>(r0)
            throw r1
        L_0x003f:
            java.lang.Object r6 = r10.L$1
            java.util.ArrayList r6 = (java.util.ArrayList) r6
            java.lang.Object r3 = r10.L$0
            com.ss.android.ugc.aweme.viewmodel.MentionMusicVideoVM r3 = (com.ss.android.ugc.aweme.viewmodel.MentionMusicVideoVM) r3
            goto L_0x0079
        L_0x0048:
            X.2th.LIZ(r8)
            r17.LIZLLL()     // Catch:{ Exception -> 0x013e }
            boolean r0 = LJII()     // Catch:{ Exception -> 0x013e }
            if (r0 == 0) goto L_0x0136
            java.util.ArrayList r6 = new java.util.ArrayList     // Catch:{ Exception -> 0x013e }
            r6.<init>()     // Catch:{ Exception -> 0x013e }
            X.Cw3 r0 = r17.LIZ()     // Catch:{ Exception -> 0x013e }
            X.2eS r11 = r0.getOperator()     // Catch:{ Exception -> 0x013e }
            X.FMb r11 = (X.C6189FMb) r11     // Catch:{ Exception -> 0x013e }
            r10.L$0 = r3     // Catch:{ Exception -> 0x013e }
            r10.L$1 = r6     // Catch:{ Exception -> 0x013e }
            r10.label = r7     // Catch:{ Exception -> 0x013e }
            r13 = r19
            r12 = r18
            r15 = r21
            r16 = r22
            java.lang.Object r8 = r11.LIZ(r12, r13, r15, r16)     // Catch:{ Exception -> 0x013e }
            if (r8 != r9) goto L_0x007c
            goto L_0x0135
        L_0x0079:
            X.2th.LIZ(r8)     // Catch:{ Exception -> 0x0133 }
        L_0x007c:
            X.PgU r8 = (X.PgU) r8     // Catch:{ Exception -> 0x0133 }
            long r0 = r3.LIZLLL     // Catch:{ Exception -> 0x0133 }
            java.util.concurrent.TimeUnit r13 = java.util.concurrent.TimeUnit.SECONDS     // Catch:{ Exception -> 0x0133 }
            java.lang.RuntimeException r12 = new java.lang.RuntimeException     // Catch:{ Exception -> 0x0133 }
            java.lang.String r11 = "time out"
            r12.<init>(r11)     // Catch:{ Exception -> 0x0133 }
            X.PgU r11 = X.PgU.LIZ(r12)     // Catch:{ Exception -> 0x0133 }
            X.PgU r1 = r8.LIZ(r0, r13, r11)     // Catch:{ Exception -> 0x0133 }
            X.PlG r0 = X.PlI.LIZJ     // Catch:{ Exception -> 0x0133 }
            X.PlG r0 = X.PhE.LIZIZ(r0)     // Catch:{ Exception -> 0x0133 }
            X.PgU r0 = r1.LIZIZ(r0)     // Catch:{ Exception -> 0x0133 }
            kotlin.h.b.n.LIZIZ(r0, r5)     // Catch:{ Exception -> 0x0133 }
            r10.L$0 = r3     // Catch:{ Exception -> 0x0133 }
            r10.L$1 = r6     // Catch:{ Exception -> 0x0133 }
            r10.label = r2     // Catch:{ Exception -> 0x0133 }
            java.lang.Object r8 = X.F3Z.LIZ(r0, r10)     // Catch:{ Exception -> 0x0133 }
            if (r8 != r9) goto L_0x00af
            goto L_0x0132
        L_0x00ac:
            X.2th.LIZ(r8)     // Catch:{ Exception -> 0x0140 }
        L_0x00af:
            com.ss.android.ugc.aweme.music.model.MusicAwemeList r8 = (com.ss.android.ugc.aweme.music.model.MusicAwemeList) r8     // Catch:{ Exception -> 0x0140 }
            kotlin.h.b.n.LIZIZ(r8, r5)     // Catch:{ Exception -> 0x0140 }
            java.util.List r1 = r8.items     // Catch:{ Exception -> 0x0140 }
            kotlin.h.b.n.LIZIZ(r1, r5)     // Catch:{ Exception -> 0x0140 }
            r2 = 0
            if (r1 == 0) goto L_0x00c2
            boolean r0 = r1.isEmpty()     // Catch:{ Exception -> 0x0140 }
            if (r0 == 0) goto L_0x00d1
        L_0x00c2:
            X.FMk r0 = new X.FMk     // Catch:{ Exception -> 0x0140 }
            r0.<init>(r3)     // Catch:{ Exception -> 0x0140 }
            r3.withState(r0)     // Catch:{ Exception -> 0x0140 }
            androidx.fragment.app.Fragment r9 = r3.LIZIZ     // Catch:{ Exception -> 0x0140 }
            boolean r0 = r9 instanceof com.ss.android.ugc.aweme.fragments.MentionVideoListFragment     // Catch:{ Exception -> 0x0140 }
            if (r0 != 0) goto L_0x00f2
            goto L_0x00f1
        L_0x00d1:
            if (r1 == 0) goto L_0x00c2
            java.util.Iterator r9 = r1.iterator()     // Catch:{ Exception -> 0x0140 }
        L_0x00d7:
            boolean r0 = r9.hasNext()     // Catch:{ Exception -> 0x0140 }
            if (r0 == 0) goto L_0x00c2
            java.lang.Object r1 = r9.next()     // Catch:{ Exception -> 0x0140 }
            com.ss.android.ugc.aweme.feed.model.Aweme r1 = (com.ss.android.ugc.aweme.feed.model.Aweme) r1     // Catch:{ Exception -> 0x0140 }
            X.Ak5 r0 = new X.Ak5     // Catch:{ Exception -> 0x0140 }
            if (r1 != 0) goto L_0x00ea
            kotlin.h.b.n.LIZIZ()     // Catch:{ Exception -> 0x0140 }
        L_0x00ea:
            r0.<init>(r1)     // Catch:{ Exception -> 0x0140 }
            r6.add(r0)     // Catch:{ Exception -> 0x0140 }
            goto L_0x00d7
        L_0x00f1:
            r9 = r4
        L_0x00f2:
            com.ss.android.ugc.aweme.fragments.MentionVideoListFragment r9 = (com.ss.android.ugc.aweme.fragments.MentionVideoListFragment) r9     // Catch:{ Exception -> 0x0140 }
            if (r9 == 0) goto L_0x0106
            int r1 = r9.LIZ     // Catch:{ Exception -> 0x0140 }
            r0 = 8
            if (r1 != r0) goto L_0x0106
            java.lang.String r0 = r9.LIZJ     // Catch:{ Exception -> 0x0140 }
            if (r0 == 0) goto L_0x0106
            int r0 = r0.length()     // Catch:{ Exception -> 0x0140 }
            if (r0 != 0) goto L_0x011b
        L_0x0106:
            r3.LIZJ = r2     // Catch:{ Exception -> 0x0140 }
            boolean r0 = r8.isHasMore()     // Catch:{ Exception -> 0x0140 }
            if (r0 == 0) goto L_0x012b
            X.A4n r2 = X.A4l.LIZ     // Catch:{ Exception -> 0x0140 }
            long r0 = r8.cursor     // Catch:{ Exception -> 0x0140 }
            java.lang.Long r0 = X.ILJ.LIZ(r0)     // Catch:{ Exception -> 0x0140 }
            X.A4p r0 = X.A4n.LIZ(r2, r4, r0, r6, r7)     // Catch:{ Exception -> 0x0140 }
            return r0
        L_0x011b:
            android.view.ViewGroup r1 = r9.LIZLLL     // Catch:{ Exception -> 0x0140 }
            if (r1 != 0) goto L_0x0122
            kotlin.h.b.n.LIZ(r5)     // Catch:{ Exception -> 0x0140 }
        L_0x0122:
            X.FN8 r0 = new X.FN8     // Catch:{ Exception -> 0x0140 }
            r0.<init>(r9)     // Catch:{ Exception -> 0x0140 }
            r1.post(r0)     // Catch:{ Exception -> 0x0140 }
            goto L_0x0106
        L_0x012b:
            X.A4n r0 = X.A4l.LIZ     // Catch:{ Exception -> 0x0140 }
            X.A4o r0 = r0.LIZ(r6)     // Catch:{ Exception -> 0x0140 }
            return r0
        L_0x0132:
            return r9
        L_0x0133:
            r2 = move-exception
            goto L_0x0141
        L_0x0135:
            return r9
        L_0x0136:
            java.lang.RuntimeException r1 = new java.lang.RuntimeException     // Catch:{ Exception -> 0x013e }
            java.lang.String r0 = "Net Error!"
            r1.<init>(r0)     // Catch:{ Exception -> 0x013e }
            throw r1     // Catch:{ Exception -> 0x013e }
        L_0x013e:
            r2 = move-exception
            goto L_0x0141
        L_0x0140:
            r2 = move-exception
        L_0x0141:
            boolean r0 = r3.LIZJ
            if (r0 == 0) goto L_0x0173
            androidx.fragment.app.Fragment r1 = r3.LIZIZ
            boolean r0 = r1 instanceof com.ss.android.ugc.aweme.fragments.MentionVideoListFragment
            if (r0 != 0) goto L_0x017f
        L_0x014b:
            com.ss.android.ugc.aweme.fragments.MentionVideoListFragment r4 = (com.ss.android.ugc.aweme.fragments.MentionVideoListFragment) r4
            if (r4 == 0) goto L_0x016b
            android.view.ViewGroup r0 = r4.LIZLLL
            if (r0 != 0) goto L_0x0156
            kotlin.h.b.n.LIZ(r5)
        L_0x0156:
            int r0 = r0.getVisibility()
            if (r0 != 0) goto L_0x016b
            android.view.ViewGroup r1 = r4.LIZLLL
            if (r1 != 0) goto L_0x0163
            kotlin.h.b.n.LIZ(r5)
        L_0x0163:
            X.FNB r0 = new X.FNB
            r0.<init>(r4)
            r1.post(r0)
        L_0x016b:
            X.FMl r0 = new X.FMl
            r0.<init>(r3)
            r3.withState(r0)
        L_0x0173:
            X.A4n r1 = X.A4l.LIZ
            java.lang.Exception r0 = new java.lang.Exception
            r0.<init>(r2)
            X.A4m r0 = r1.LIZ(r0)
            return r0
        L_0x017f:
            r4 = r1
            goto L_0x014b
        */
        throw new UnsupportedOperationException("Method not decompiled: com.ss.android.ugc.aweme.viewmodel.MentionMusicVideoVM.LIZ(java.lang.String, long, int, int, X.4r1):java.lang.Object");
    }
}
