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.m;

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

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

    public c(g gVar) {
        this.f35889a = gVar;
    }

    @Override // xyz.stream.api.e
    public final void a(String str) {
        this.f35889a.p();
    }

    @Override // xyz.stream.api.e
    public final void onSuccess(Object obj) {
        BaseEntity baseEntity = (BaseEntity) obj;
        if (baseEntity != null && baseEntity.getCode() == 200) {
            List<LiveCategoryEntity> list = (List) m.f36162a.fromJson(baseEntity.getData(), new BaseLiveManager$2$1().getType());
            if (list != null && !list.isEmpty()) {
                g gVar = this.f35889a;
                ArrayList arrayListC = g.c(g.c(gVar.f35898a));
                LinkedHashMap linkedHashMapB = g.b(arrayListC);
                for (LiveCategoryEntity liveCategoryEntity : list) {
                    if (liveCategoryEntity != null && liveCategoryEntity.getCategoryId() != null && liveCategoryEntity.getChannels() != null && !liveCategoryEntity.getChannels().isEmpty()) {
                        LiveCategoryEntity liveCategoryEntity2 = (LiveCategoryEntity) linkedHashMapB.get(liveCategoryEntity.getCategoryId());
                        if (liveCategoryEntity2 == null) {
                            LiveCategoryEntity liveCategoryEntityClone = liveCategoryEntity.clone();
                            List<LiveChannelEntity> channels = liveCategoryEntity.getChannels();
                            liveCategoryEntityClone.setChannels(channels == null ? null : new ArrayList(channels));
                            arrayListC.add(liveCategoryEntityClone);
                            linkedHashMapB.put(liveCategoryEntityClone.getCategoryId(), liveCategoryEntityClone);
                        } else {
                            List<LiveChannelEntity> channels2 = liveCategoryEntity.getChannels();
                            if (channels2 != null && !channels2.isEmpty()) {
                                Iterator<LiveChannelEntity> it = channels2.iterator();
                                while (it.hasNext()) {
                                    g.a(liveCategoryEntity2, it.next());
                                }
                            }
                        }
                    }
                }
                gVar.f35898a = g.c(arrayListC);
            }
        }
        this.f35889a.p();
    }
}
