package xyz.stream.api.live;

import java.util.ArrayList;
import java.util.Iterator;
import java.util.LinkedHashMap;
import java.util.List;
import xyz.stream.api.entity.BaseEntity;
import xyz.stream.api.entity.LiveCategoryEntity;
import xyz.stream.api.entity.LiveChannelEntity;
import xyz.stream.utils.h;
import xyz.stream.utils.m;

/* JADX INFO: loaded from: classes3.dex */
public final class d implements xyz.stream.api.e {

    /* JADX INFO: renamed from: a, reason: collision with root package name */
    public final /* synthetic */ List f35890a;

    /* JADX INFO: renamed from: b, reason: collision with root package name */
    public final /* synthetic */ boolean f35891b;

    /* JADX INFO: renamed from: c, reason: collision with root package name */
    public final /* synthetic */ g f35892c;

    public d(ArrayList arrayList, g gVar, boolean z10) {
        this.f35892c = gVar;
        this.f35890a = arrayList;
        this.f35891b = z10;
    }

    @Override // xyz.stream.api.e
    public final void a(String str) {
        g gVar = this.f35892c;
        List list = this.f35890a;
        gVar.getClass();
        gVar.f35898a = g.c(list);
        this.f35892c.f35902e = false;
        this.f35892c.p();
    }

    @Override // xyz.stream.api.e
    public final void onSuccess(Object obj) {
        LiveCategoryEntity liveCategoryEntity;
        BaseEntity baseEntity = (BaseEntity) obj;
        if (baseEntity != null && baseEntity.getCode() == 200 && baseEntity.getData() != null) {
            List<LiveChannelEntity> list = (List) m.f36162a.fromJson(baseEntity.getData(), new BaseLiveManager$3$1().getType());
            if (list != null && !list.isEmpty()) {
                h.b("getChannelsFromServer success: " + list.size());
                g gVar = this.f35892c;
                List list2 = this.f35890a;
                gVar.getClass();
                if (list2 != null && !list2.isEmpty() && !list.isEmpty()) {
                    LinkedHashMap linkedHashMapB = g.b(list2);
                    Iterator it = linkedHashMapB.values().iterator();
                    while (it.hasNext()) {
                        ((LiveCategoryEntity) it.next()).setChannels(new ArrayList());
                    }
                    for (LiveChannelEntity liveChannelEntity : list) {
                        if (liveChannelEntity != null && liveChannelEntity.getCategoryId() != null && (liveCategoryEntity = (LiveCategoryEntity) linkedHashMapB.get(liveChannelEntity.getCategoryId())) != null) {
                            g.a(liveCategoryEntity, liveChannelEntity);
                        }
                    }
                }
                g gVar2 = this.f35892c;
                List list3 = this.f35890a;
                gVar2.getClass();
                gVar2.f35898a = g.c(list3);
                this.f35892c.f35902e = false;
                this.f35892c.getClass();
                this.f35892c.d(this.f35891b);
                return;
            }
        }
        g gVar3 = this.f35892c;
        List list4 = this.f35890a;
        gVar3.getClass();
        gVar3.f35898a = g.c(list4);
        this.f35892c.f35902e = false;
        this.f35892c.p();
    }
}
