package com.strmr.ps.ui.mobile.settings;

import android.widget.Toast;
import com.strmr.ps.data.model.trakt.TraktPublicList;
import com.strmr.ps.data.model.trakt.TraktUserList;
import defpackage.ak1;
import defpackage.ck1;
import defpackage.e6a;
import defpackage.gr3;
import defpackage.m02;
import defpackage.m12;
import defpackage.n41;
import defpackage.s38;
import defpackage.sc2;
import defpackage.vx8;
import defpackage.wj0;
import java.util.ArrayList;
import java.util.Iterator;
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.mobile.settings.MobileLayoutRowsFragment$loadAndShowPopularLists$1", f = "MobileLayoutRowsFragment.kt", i = {}, l = {623}, m = "invokeSuspend", n = {}, s = {})
@vx8
final class at extends SuspendLambda implements gr3<ak1, Continuation<? super e6a>, Object> {
    public int a;
    public final /* synthetic */ MobileLayoutRowsFragment b;

    /* JADX WARN: 'super' call moved to the top of the method (can break code semantics) */
    public at(MobileLayoutRowsFragment mobileLayoutRowsFragment, Continuation continuation) {
        super(2, continuation);
        this.b = mobileLayoutRowsFragment;
    }

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

    @Override // defpackage.gr3
    public final Object invoke(Object obj, Object obj2) {
        return ((at) 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;
        e6a e6aVar = e6a.a;
        MobileLayoutRowsFragment mobileLayoutRowsFragment = this.b;
        try {
            if (i == 0) {
                s38.b(obj);
                Toast.makeText(mobileLayoutRowsFragment.requireContext(), "Loading popular lists...", 0).show();
                m12 m12Var = sc2.a;
                m02 m02Var = m02.c;
                as asVar = new as(mobileLayoutRowsFragment, null);
                this.a = 1;
                obj = wj0.f(m02Var, asVar, this);
                if (obj == ck1Var) {
                    return ck1Var;
                }
            } else {
                if (i != 1) {
                    throw new IllegalStateException("call to 'resume' before 'invoke' with coroutine");
                }
                s38.b(obj);
            }
            ArrayList arrayList = new ArrayList();
            Iterator it = ((List) obj).iterator();
            while (it.hasNext()) {
                TraktUserList list = ((TraktPublicList) it.next()).getList();
                if (list != null) {
                    arrayList.add(list);
                }
            }
            if (arrayList.isEmpty()) {
                Toast.makeText(mobileLayoutRowsFragment.requireContext(), "No popular lists found", 0).show();
                return e6aVar;
            }
            MobileLayoutRowsFragment.n(mobileLayoutRowsFragment, "Add from Popular Lists", arrayList);
            return e6aVar;
        } catch (Exception e) {
            n41.aa(mobileLayoutRowsFragment.requireContext(), "Failed to load popular lists: ", 1, e.getMessage());
            return e6aVar;
        }
    }
}
