package com.strmr.ps.ui.grid;

import android.content.Context;
import android.widget.Toast;
import com.strmr.ps.R;
import com.strmr.ps.ui.grid.GridViewModel;
import defpackage.ak1;
import defpackage.ck1;
import defpackage.e6a;
import defpackage.gr3;
import defpackage.m02;
import defpackage.m12;
import defpackage.s38;
import defpackage.sc2;
import defpackage.wj0;
import java.util.List;
import kotlin.Metadata;
import kotlin.coroutines.Continuation;
import kotlin.coroutines.jvm.internal.DebugMetadata;
import kotlin.coroutines.jvm.internal.SuspendLambda;

/* JADX INFO: loaded from: classes3.dex */
@Metadata(d1 = {"\u0000\f\n\u0002\u0018\u0002\n\u0002\u0018\u0002\n\u0002\b\u0002\u0010\u0002\u001a\u00020\u0001*\u00020\u0000H\n¢\u0006\u0004\b\u0002\u0010\u0003"}, d2 = {"Lak1;", "Le6a;", "<anonymous>", "(Lak1;)V"}, k = 3, mv = {2, 0, 0})
@DebugMetadata(c = "com.strmr.ps.ui.grid.GridFragment$playDebridFile$1", f = "GridFragment.kt", i = {}, l = {605}, m = "invokeSuspend", n = {}, s = {})
final class d extends SuspendLambda implements gr3<ak1, Continuation<? super e6a>, Object> {
    public int a;
    public final /* synthetic */ a b;
    public final /* synthetic */ String c;
    public final /* synthetic */ String d;
    public final /* synthetic */ String e;

    /* JADX WARN: 'super' call moved to the top of the method (can break code semantics) */
    public d(a aVar, String str, String str2, String str3, Continuation continuation) {
        super(2, continuation);
        this.b = aVar;
        this.c = str;
        this.d = str2;
        this.e = str3;
    }

    @Override // kotlin.coroutines.jvm.internal.BaseContinuationImpl
    public final Continuation create(Object obj, Continuation continuation) {
        return new d(this.b, this.c, this.d, this.e, continuation);
    }

    @Override // defpackage.gr3
    public final Object invoke(Object obj, Object obj2) {
        return ((d) create((ak1) obj, (Continuation) obj2)).invokeSuspend(e6a.a);
    }

    @Override // kotlin.coroutines.jvm.internal.BaseContinuationImpl
    public final Object invokeSuspend(Object obj) throws Throwable {
        ck1 ck1Var = ck1.a;
        int i = this.a;
        String str = this.e;
        String str2 = this.c;
        a aVar = this.b;
        try {
            if (i == 0) {
                s38.b(obj);
                Toast.makeText(aVar.requireContext(), aVar.getString(R.string.toast_loading_title, str2), 0).show();
                GridViewModel gridViewModelM = aVar.m();
                String str3 = this.d;
                this.a = 1;
                m12 m12Var = sc2.a;
                obj = wj0.f(m02.c, new j(gridViewModelM, str3, str, null), this);
                if (obj == ck1Var) {
                    return ck1Var;
                }
            } else {
                if (i != 1) {
                    throw new IllegalStateException("call to 'resume' before 'invoke' with coroutine");
                }
                s38.b(obj);
            }
            List list = (List) obj;
            if (list == null) {
                Toast.makeText(aVar.requireContext(), aVar.getString(R.string.toast_failed_to_load_content), 0).show();
            } else if (list.isEmpty()) {
                Toast.makeText(aVar.requireContext(), aVar.getString(R.string.toast_no_playable_files), 0).show();
            } else if (list.size() == 1) {
                GridViewModel.c cVar = (GridViewModel.c) list.get(0);
                String str4 = cVar.c;
                String str5 = cVar.b;
                if (str5 != null) {
                    str2 = str5;
                }
                aVar.n(str2, str4);
            } else {
                a.l(aVar, str2, list, str);
            }
        } catch (Exception e) {
            Context contextRequireContext = aVar.requireContext();
            String message = e.getMessage();
            if (message == null) {
                message = "";
            }
            Toast.makeText(contextRequireContext, aVar.getString(R.string.toast_error, message), 0).show();
        }
        return e6a.a;
    }
}
