package xyz.stream.api.viewmodel;

import com.google.gson.Gson;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import xyz.stream.api.entity.BaseEntity;
import xyz.stream.api.entity.LeagueEntity;

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

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

    /* JADX INFO: renamed from: b, reason: collision with root package name */
    public final /* synthetic */ androidx.lifecycle.w f35984b;

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

    public /* synthetic */ l(BaseSportsViewModel baseSportsViewModel, androidx.lifecycle.w wVar, int i10) {
        this.f35983a = i10;
        this.f35985c = baseSportsViewModel;
        this.f35984b = wVar;
    }

    @Override // xyz.stream.api.e
    public final void a(String str) {
        int i10 = this.f35983a;
        androidx.lifecycle.w wVar = this.f35984b;
        switch (i10) {
            case 0:
                xyz.stream.utils.h.c("Get match list failed: " + str);
                wVar.j(null);
                break;
            case 1:
                xyz.stream.utils.h.c("Get match list failed: " + str);
                wVar.j(null);
                break;
            default:
                wVar.j(null);
                break;
        }
    }

    public final void b(BaseEntity baseEntity) {
        int i10 = this.f35983a;
        BaseSportsViewModel baseSportsViewModel = this.f35985c;
        androidx.lifecycle.w wVar = this.f35984b;
        switch (i10) {
            case 0:
                if (baseEntity != null) {
                    try {
                        if (baseEntity.getData() != null) {
                            List<Map> list = (List) xyz.stream.utils.m.f36162a.fromJson(baseEntity.getData(), new BaseSportsViewModel$1$1().getType());
                            HashMap map = new HashMap();
                            for (Map map2 : list) {
                                String str = (String) map2.get("date");
                                Object obj = map2.get("matches");
                                Gson gson = xyz.stream.utils.m.f36162a;
                                map.put(str, (List) gson.fromJson(gson.toJsonTree(obj), new BaseSportsViewModel$1$2().getType()));
                            }
                            wVar.j(baseSportsViewModel.sortMatchMapByDate(map));
                        }
                    } catch (Exception e10) {
                        u.a.g(e10, new StringBuilder("Get match list error: "));
                    }
                }
                wVar.j(null);
                break;
            case 1:
                if (baseEntity != null) {
                    try {
                        if (baseEntity.getData() != null) {
                            wVar.j(baseSportsViewModel.sortMatchMapByDate((Map) xyz.stream.utils.m.f36162a.fromJson(baseEntity.getData(), new BaseSportsViewModel$3$1().getType())));
                        }
                    } catch (Exception e11) {
                        u.a.g(e11, new StringBuilder("Get match list error: "));
                    }
                }
                wVar.j(null);
                break;
            default:
                if (baseEntity != null) {
                    try {
                        if (baseEntity.getData() != null) {
                            List<LeagueEntity> arrayList = (List) xyz.stream.utils.m.f36162a.fromJson(baseEntity.getData(), new BaseSportsViewModel$4$1().getType());
                            if (arrayList == null) {
                                arrayList = new ArrayList<>();
                            }
                            for (LeagueEntity leagueEntity : arrayList) {
                                leagueEntity.setIcon(Integer.valueOf(baseSportsViewModel.getLeagueIcon(leagueEntity.getId().intValue())));
                            }
                            baseSportsViewModel.cacheLeagueList = baseSportsViewModel.applySavedLeagueOrder(arrayList);
                            xyz.stream.api.r.a().b(baseSportsViewModel.cacheLeagueList);
                            baseSportsViewModel.buildCollectionLeagueMap(baseSportsViewModel.cacheLeagueList);
                            wVar.j(baseSportsViewModel.cacheLeagueList);
                        }
                    } catch (Exception e12) {
                        u.a.g(e12, new StringBuilder("Get league list error: "));
                    }
                }
                wVar.j(null);
                break;
        }
    }

    @Override // xyz.stream.api.e
    public final /* bridge */ /* synthetic */ void onSuccess(Object obj) {
        switch (this.f35983a) {
            case 0:
                b((BaseEntity) obj);
                break;
            case 1:
                b((BaseEntity) obj);
                break;
            default:
                b((BaseEntity) obj);
                break;
        }
    }
}
