package te;

import androidx.lifecycle.x;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import xyz.stream.api.entity.LiveCategoryEntity;
import xyz.stream.api.entity.LiveChannelEntity;
import xyz.stream.view.UiUtils;

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

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

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

    public /* synthetic */ i(n nVar, int i10) {
        this.f33058a = i10;
        this.f33059b = nVar;
    }

    @Override // androidx.lifecycle.x
    public final void onChanged(Object obj) {
        int i10 = this.f33058a;
        n nVar = this.f33059b;
        switch (i10) {
            case 0:
                nVar.getClass();
                ArrayList arrayList = new ArrayList();
                for (LiveCategoryEntity liveCategoryEntity : (List) obj) {
                    if (re.a.u().g(liveCategoryEntity.getCategoryId().intValue())) {
                        arrayList.add(liveCategoryEntity.clone());
                    }
                }
                nVar.d(arrayList);
                break;
            default:
                xyz.stream.api.viewmodel.j jVar = (xyz.stream.api.viewmodel.j) obj;
                if (jVar == null) {
                    nVar.getClass();
                    break;
                } else {
                    int i11 = nVar.f33085r;
                    if (i11 != Integer.MIN_VALUE) {
                        if (jVar.f35981a == nVar.f33087t) {
                            boolean z10 = nVar.f33086s;
                            nVar.f33085r = Integer.MIN_VALUE;
                            nVar.f33086s = false;
                            nVar.f33087t = -1;
                            ArrayList arrayList2 = nVar.f33079l;
                            arrayList2.clear();
                            List list = jVar.f35982b;
                            if (list != null && !list.isEmpty() && i11 >= 0) {
                                ArrayList arrayList3 = nVar.f33075h;
                                if (i11 < arrayList3.size()) {
                                    arrayList2.addAll(list);
                                    if (((LiveCategoryEntity) arrayList3.get(i11)).getIsAdult() == 1) {
                                        t4.f fVarX = t4.f.x(arrayList2);
                                        while (true) {
                                            Iterator it = fVarX.f32951a;
                                            if (it.hasNext()) {
                                                ((LiveChannelEntity) it.next()).setIsAdult(1);
                                            }
                                        }
                                    }
                                    nVar.f33078k.notifyDataSetChanged();
                                    if (z10) {
                                        int i12 = 2;
                                        LiveChannelEntity liveChannelEntity = (LiveChannelEntity) t4.f.x(arrayList2).e(new j(nVar, i12)).k();
                                        int iIndexOf = liveChannelEntity != null ? arrayList2.indexOf(liveChannelEntity) : 0;
                                        nVar.f33074g = iIndexOf;
                                        UiUtils.recyclerScrollToCenter(nVar.f33069b.f27508d, iIndexOf);
                                        nVar.f33069b.f27508d.post(new k(nVar, i12));
                                    } else {
                                        int i13 = 3;
                                        LiveChannelEntity liveChannelEntity2 = (LiveChannelEntity) t4.f.x(arrayList2).e(new j(nVar, i13)).k();
                                        int iIndexOf2 = liveChannelEntity2 != null ? arrayList2.indexOf(liveChannelEntity2) : -1;
                                        nVar.f33074g = iIndexOf2;
                                        if (iIndexOf2 >= 0) {
                                            nVar.f33069b.f27508d.post(new k(nVar, i13));
                                        } else {
                                            nVar.f33069b.f27508d.post(new k(nVar, 4));
                                        }
                                    }
                                }
                            }
                            nVar.f33078k.notifyDataSetChanged();
                            break;
                        }
                    }
                }
                break;
        }
    }
}
