package kf;

import androidx.fragment.app.e0;
import androidx.lifecycle.v;
import androidx.lifecycle.x;
import java.util.ArrayList;
import java.util.List;
import org.drive_hunter.R;
import tv.danmaku.ijk.media.player.IjkEventListener;
import xyz.stream.api.entity.PageInfo;
import xyz.stream.api.entity.TagsEntity;
import xyz.stream.api.entity.VideoCategoryEntity;
import xyz.stream.api.entity.VideoEntity;
import xyz.stream.api.entity.VideoInfoEntity;

/* JADX INFO: loaded from: classes3.dex */
public final /* synthetic */ class g implements x {

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

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

    public /* synthetic */ g(i iVar, int i10) {
        this.f29154a = i10;
        this.f29155b = iVar;
    }

    @Override // androidx.lifecycle.x
    public final void onChanged(Object obj) {
        int i10 = this.f29154a;
        int i11 = 1;
        i iVar = this.f29155b;
        switch (i10) {
            case 0:
                List<VideoInfoEntity> list = (List) obj;
                if (list != null) {
                    iVar.getClass();
                    if (!list.isEmpty()) {
                        ArrayList arrayList = iVar.f29160c;
                        arrayList.clear();
                        ArrayList arrayList2 = iVar.f29159b;
                        arrayList2.clear();
                        for (VideoInfoEntity videoInfoEntity : list) {
                            arrayList.add(new VideoEntity(videoInfoEntity.getId().intValue(), videoInfoEntity.getTitle(), (videoInfoEntity.getWideBackdropPath() == null || videoInfoEntity.getWideBackdropPath().isEmpty()) ? videoInfoEntity.getBackdropPath() : videoInfoEntity.getWideBackdropPath(), videoInfoEntity.getSourceType().intValue(), videoInfoEntity.getUpdatedAt().intValue(), videoInfoEntity.getVoteAverage(), videoInfoEntity.getStatus()));
                            arrayList2.add(videoInfoEntity);
                        }
                        iVar.f29161d.notifyDataSetChanged();
                        iVar.g((VideoInfoEntity) arrayList2.get(0));
                    }
                }
                int i12 = iVar.f29163f;
                e0 e0Var = iVar.f29162e;
                int i13 = 2;
                if (i12 == 2) {
                    iVar.f29165h.getGenreByIds(i12);
                    iVar.f29165h.liveGenre.c(e0Var.getViewLifecycleOwner(), new g(iVar, i11));
                } else {
                    iVar.f29165h.getVideoCategoryConfig(e0Var.getContext());
                    iVar.f29165h.liveVideoCategory.c(e0Var.getViewLifecycleOwner(), new g(iVar, i13));
                }
                iVar.e();
                break;
            case 1:
                List list2 = (List) obj;
                v vVar = iVar.f29165h.liveGenre;
                e0 e0Var2 = iVar.f29162e;
                vVar.h(e0Var2.getViewLifecycleOwner());
                if (list2 != null) {
                    ArrayList arrayList3 = iVar.f29173p;
                    arrayList3.clear();
                    arrayList3.add(new TagsEntity(0, e0Var2.getString(R.string.all), 0, 0, 0, 0, 0));
                    arrayList3.addAll(list2);
                    iVar.f29171n.notifyDataSetChanged();
                }
                break;
            case 2:
                VideoCategoryEntity videoCategoryEntity = (VideoCategoryEntity) obj;
                iVar.f29165h.liveVideoCategory.h(iVar.f29162e.getViewLifecycleOwner());
                if (videoCategoryEntity != null) {
                    ArrayList arrayList4 = iVar.f29172o;
                    arrayList4.clear();
                    for (VideoCategoryEntity.NetworkEntity networkEntity : videoCategoryEntity.getNetwork()) {
                        if (networkEntity.getValue().equalsIgnoreCase("All Network") || networkEntity.getValue().equalsIgnoreCase("Netflix") || networkEntity.getValue().equalsIgnoreCase("Prime Video") || networkEntity.getValue().equalsIgnoreCase("Disney+") || networkEntity.getValue().equalsIgnoreCase("Apple TV+") || networkEntity.getValue().equalsIgnoreCase("Hulu") || networkEntity.getValue().equalsIgnoreCase("HBOMAX")) {
                            arrayList4.add(networkEntity);
                        }
                    }
                    iVar.f29171n.notifyDataSetChanged();
                }
                break;
            default:
                List list3 = (List) obj;
                iVar.f29165h.liveCollectionList.h(iVar.f29162e.getViewLifecycleOwner());
                iVar.f29177t.setLoading(false);
                if (iVar.f29177t.getPage() == 1) {
                    iVar.f29169l.clear();
                    iVar.f29169l.addAll(list3);
                    iVar.f29170m.notifyDataSetChanged();
                    iVar.f29168k.finishRefresh(IjkEventListener.BUFFERING_START);
                } else {
                    iVar.f29168k.finishLoadMore(IjkEventListener.BUFFERING_START);
                    if (list3.isEmpty()) {
                        PageInfo pageInfo = iVar.f29177t;
                        pageInfo.setPage(pageInfo.getPage() - 1);
                        iVar.f29177t.setHasMore(false);
                        iVar.f29168k.setNoMoreData(true);
                        if (xyz.stream.utils.e.d().f36118g) {
                            iVar.f29170m.c(true);
                        }
                    } else {
                        if (list3.size() < iVar.f29177t.getPageSize()) {
                            iVar.f29177t.setHasMore(false);
                            iVar.f29168k.setNoMoreData(true);
                            if (xyz.stream.utils.e.d().f36118g) {
                                iVar.f29170m.c(true);
                            }
                        }
                        iVar.f29169l.addAll(list3);
                        iVar.f29170m.notifyItemRangeInserted((iVar.f29169l.size() + 1) - list3.size(), list3.size());
                    }
                }
                break;
        }
    }
}
