package defpackage;

import android.util.SparseArray;
import android.view.View;
import android.widget.Toast;
import androidx.fragment.app.o;
import androidx.leanback.widget.VerticalGridView;
import androidx.lifecycle.n;
import androidx.lifecycle.v;
import androidx.media3.container.NalUnitUtil;
import androidx.media3.exoplayer.upstream.CmcdData;
import androidx.recyclerview.widget.RecyclerView;
import com.google.android.material.button.MaterialButton;
import com.strmr.ps.data.model.ContentItem;
import com.strmr.ps.ui.RowPrefetchManager;
import com.strmr.ps.ui.util.DimensionScaler;
import java.util.Collection;
import java.util.Iterator;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
import kotlin.Metadata;

/* JADX INFO: loaded from: classes3.dex */
@Metadata(d1 = {"\u0000\f\n\u0002\u0018\u0002\n\u0002\u0010\u0000\n\u0002\b\u0004\u0018\u00002\u00020\u0001:\u0003\u0002\u0003\u0004¨\u0006\u0005"}, d2 = {"Lg88;", "", "c", "b", CmcdData.OBJECT_TYPE_AUDIO_ONLY, "app_sideloadRelease"}, k = 1, mv = {2, 0, 0}, xi = NalUnitUtil.H265_NAL_UNIT_TYPE_UNSPECIFIED)
@vx8
public final class g88 {
    public final o a;
    public final i85 b;
    public final b c;
    public final c d;
    public final VerticalGridView e;
    public final View f;
    public final RowPrefetchManager g;
    public final b34 h;
    public final gr3 i;
    public final gr3 j;
    public final sq3 k;
    public final sq3 l;
    public final gr3 m;
    public final n n;
    public final DimensionScaler o;
    public final boolean p;
    public final long q;
    public final ir3 r;
    public final boolean s;
    public final boolean t;
    public final cf1 u;
    public boolean v;
    public View w;
    public c x;
    public int y;
    public final tb5 z;

    @Metadata(d1 = {"\u0000\u0018\n\u0002\u0018\u0002\n\u0002\u0010\u0000\n\u0002\u0010\b\n\u0002\b\u0002\n\u0002\u0010\t\n\u0002\b\u0003\b\u0086\u0003\u0018\u00002\u00020\u0001R\u0014\u0010\u0003\u001a\u00020\u00028\u0002X\u0082T¢\u0006\u0006\n\u0004\b\u0003\u0010\u0004R\u0014\u0010\u0006\u001a\u00020\u00058\u0002X\u0082T¢\u0006\u0006\n\u0004\b\u0006\u0010\u0007¨\u0006\b"}, d2 = {"Lg88$a;", "", "", "MAX_FOCUS_RETRIES", "I", "", "FOCUS_RETRY_INTERVAL_MS", "J", "app_sideloadRelease"}, k = 1, mv = {2, 0, 0}, xi = NalUnitUtil.H265_NAL_UNIT_TYPE_UNSPECIFIED)
    public static final class a {
    }

    @Metadata(d1 = {"\u0000\n\n\u0002\u0018\u0002\n\u0002\u0010\u0000\n\u0000\b\u0086\b\u0018\u00002\u00020\u0001¨\u0006\u0002"}, d2 = {"Lg88$b;", "", "app_sideloadRelease"}, k = 1, mv = {2, 0, 0}, xi = NalUnitUtil.H265_NAL_UNIT_TYPE_UNSPECIFIED)
    public static final /* data */ class b {
        public final MaterialButton a;
        public final MaterialButton b;
        public final MaterialButton c;
        public final MaterialButton d;
        public final MaterialButton e;
        public final MaterialButton f;

        public b(MaterialButton materialButton, MaterialButton materialButton2, MaterialButton materialButton3, MaterialButton materialButton4, MaterialButton materialButton5, MaterialButton materialButton6) {
            cr4.g(materialButton, "search");
            cr4.g(materialButton2, "home");
            cr4.g(materialButton3, "movies");
            cr4.g(materialButton4, "tvShows");
            cr4.g(materialButton6, "settings");
            this.a = materialButton;
            this.b = materialButton2;
            this.c = materialButton3;
            this.d = materialButton4;
            this.e = materialButton5;
            this.f = materialButton6;
        }

        public final boolean equals(Object obj) {
            if (this == obj) {
                return true;
            }
            if (!(obj instanceof b)) {
                return false;
            }
            b bVar = (b) obj;
            return cr4.b(this.a, bVar.a) && cr4.b(this.b, bVar.b) && cr4.b(this.c, bVar.c) && cr4.b(this.d, bVar.d) && cr4.b(this.e, bVar.e) && cr4.b(this.f, bVar.f);
        }

        public final int hashCode() {
            int iHashCode = (this.d.hashCode() + ((this.c.hashCode() + ((this.b.hashCode() + (this.a.hashCode() * 31)) * 31)) * 31)) * 31;
            MaterialButton materialButton = this.e;
            return this.f.hashCode() + ((iHashCode + (materialButton == null ? 0 : materialButton.hashCode())) * 31);
        }

        public final String toString() {
            return "NavButtons(search=" + this.a + ", home=" + this.b + ", movies=" + this.c + ", tvShows=" + this.d + ", library=" + this.e + ", settings=" + this.f + ")";
        }
    }

    /* JADX WARN: Failed to restore enum class, 'enum' modifier and super class removed */
    /* JADX WARN: Unknown enum class pattern. Please report as an issue! */
    @Metadata(d1 = {"\u0000\n\n\u0002\u0018\u0002\n\u0002\u0010\u0010\n\u0000\b\u0086\u0081\u0002\u0018\u00002\b\u0012\u0004\u0012\u00020\u00000\u0001¨\u0006\u0002"}, d2 = {"Lg88$c;", "", "app_sideloadRelease"}, k = 1, mv = {2, 0, 0}, xi = NalUnitUtil.H265_NAL_UNIT_TYPE_UNSPECIFIED)
    public static final class c {
        public static final c a;
        public static final c b;
        public static final c c;
        public static final c d;
        public static final c e;
        public static final c f;
        public static final /* synthetic */ c[] i;
        public static final /* synthetic */ hn2 j;

        static {
            c cVar = new c("SEARCH", 0);
            a = cVar;
            c cVar2 = new c("HOME", 1);
            b = cVar2;
            c cVar3 = new c("MOVIES", 2);
            c = cVar3;
            c cVar4 = new c("TV_SHOWS", 3);
            d = cVar4;
            c cVar5 = new c("LIBRARY", 4);
            e = cVar5;
            c cVar6 = new c("SETTINGS", 5);
            f = cVar6;
            c[] cVarArr = {cVar, cVar2, cVar3, cVar4, cVar5, cVar6};
            i = cVarArr;
            j = jn2.a(cVarArr);
        }

        public static c valueOf(String str) {
            return (c) Enum.valueOf(c.class, str);
        }

        public static c[] values() {
            return (c[]) i.clone();
        }
    }

    @Metadata(k = 3, mv = {2, 0, 0}, xi = NalUnitUtil.H265_NAL_UNIT_TYPE_UNSPECIFIED)
    public /* synthetic */ class d {
        static {
            int[] iArr = new int[c.values().length];
            try {
                iArr[0] = 1;
            } catch (NoSuchFieldError unused) {
            }
            try {
                c cVar = c.a;
                iArr[1] = 2;
            } catch (NoSuchFieldError unused2) {
            }
            try {
                c cVar2 = c.a;
                iArr[2] = 3;
            } catch (NoSuchFieldError unused3) {
            }
            try {
                c cVar3 = c.a;
                iArr[3] = 4;
            } catch (NoSuchFieldError unused4) {
            }
            try {
                c cVar4 = c.a;
                iArr[4] = 5;
            } catch (NoSuchFieldError unused5) {
            }
            try {
                c cVar5 = c.a;
                iArr[5] = 6;
            } catch (NoSuchFieldError unused6) {
            }
        }
    }

    @Metadata(k = 3, mv = {2, 0, 0}, xi = NalUnitUtil.H265_NAL_UNIT_TYPE_UNSPECIFIED)
    public static final class e implements zs6, sr3 {
        public final /* synthetic */ sq3 a;

        public e(sq3 sq3Var) {
            this.a = sq3Var;
        }

        @Override // defpackage.zs6
        public final /* synthetic */ void a(Object obj) {
            this.a.invoke(obj);
        }

        @Override // defpackage.sr3
        public final lr3 b() {
            return this.a;
        }

        public final boolean equals(Object obj) {
            if (!(obj instanceof zs6) || !(obj instanceof sr3)) {
                return false;
            }
            return this.a.equals(((sr3) obj).b());
        }

        public final int hashCode() {
            return this.a.hashCode();
        }
    }

    public g88(o oVar, i85 i85Var, b bVar, c cVar, VerticalGridView verticalGridView, View view, RecyclerView.v vVar, RowPrefetchManager rowPrefetchManager, b34 b34Var, gr3 gr3Var, gr3 gr3Var2, sq3 sq3Var, sq3 sq3Var2, v74 v74Var, n nVar, DimensionScaler dimensionScaler, boolean z, long j, ir3 ir3Var, boolean z2, boolean z3) {
        cr4.g(verticalGridView, "contentRowsView");
        cr4.g(view, "loadingIndicator");
        cr4.g(vVar, "sharedViewPool");
        cr4.g(rowPrefetchManager, "rowPrefetchManager");
        cr4.g(b34Var, "heroSyncManager");
        this.a = oVar;
        this.b = i85Var;
        this.c = bVar;
        this.d = cVar;
        this.e = verticalGridView;
        this.f = view;
        this.g = rowPrefetchManager;
        this.h = b34Var;
        this.i = gr3Var;
        this.j = gr3Var2;
        this.k = sq3Var;
        this.l = sq3Var2;
        this.m = v74Var;
        this.n = nVar;
        this.o = dimensionScaler;
        this.p = z;
        this.q = j;
        this.r = ir3Var;
        this.s = z2;
        this.t = z3;
        this.x = cVar;
        LinkedHashMap linkedHashMapK = wo5.k(new q07(c.a, bVar.a), new q07(c.b, bVar.b), new q07(c.c, bVar.c), new q07(c.d, bVar.d), new q07(c.f, bVar.f));
        MaterialButton materialButton = bVar.e;
        if (materialButton != null) {
            linkedHashMapK.put(c.e, materialButton);
        }
        for (MaterialButton materialButton2 : linkedHashMapK.values()) {
            materialButton2.setStateListAnimator(null);
            materialButton2.setElevation(0.0f);
            materialButton2.setOutlineProvider(null);
            materialButton2.setOnFocusChangeListener(new fb(this, 8));
            materialButton2.setOnKeyListener(new va(this, 1));
        }
        e(this.d);
        for (Map.Entry entry : linkedHashMapK.entrySet()) {
            ((MaterialButton) entry.getValue()).setOnClickListener(new rb5(this, (c) entry.getKey(), 27));
        }
        v78.a(this.e);
        this.e.setItemAnimator(null);
        VerticalGridView verticalGridView2 = this.e;
        cf1 cf1Var = new cf1(ik2.a, this.i, new ux3(this, 7), new ah(this, 29), this.j, this.k, this.n, this.o, this.p, this.q, this.r, this.s, this.t, 256);
        this.u = cf1Var;
        verticalGridView2.setAdapter(cf1Var);
        this.z = new tb5(this, 18);
    }

    public static MaterialButton b(b bVar, c cVar) {
        int iOrdinal = cVar.ordinal();
        if (iOrdinal == 0) {
            return bVar.a;
        }
        if (iOrdinal == 1) {
            return bVar.b;
        }
        if (iOrdinal == 2) {
            return bVar.c;
        }
        if (iOrdinal == 3) {
            return bVar.d;
        }
        if (iOrdinal == 4) {
            return bVar.e;
        }
        if (iOrdinal == 5) {
            return bVar.f;
        }
        throw new io6();
    }

    public final void a(v vVar, v vVar2, v vVar3, v vVar4, v vVar5) {
        cr4.g(vVar, "contentRows");
        cr4.g(vVar3, "isLoading");
        cr4.g(vVar4, "error");
        cr4.g(vVar5, "heroContent");
        final int i = 0;
        e eVar = new e(new sq3(this) { // from class: f88
            public final /* synthetic */ g88 b;

            {
                this.b = this;
            }

            @Override // defpackage.sq3
            public final Object invoke(Object obj) {
                switch (i) {
                    case 0:
                        g88 g88Var = this.b;
                        cf1 cf1Var = g88Var.u;
                        List list = (List) obj;
                        if (list.isEmpty()) {
                            if (cf1Var != null) {
                                cf1Var.f(ik2.a);
                            }
                            g88Var.g.b.clear();
                            g88Var.v = false;
                        } else {
                            if (cf1Var != null) {
                                cf1Var.f(list);
                            }
                            if (!g88Var.v) {
                                List list2 = list;
                                if (!(list2 instanceof Collection) || !list2.isEmpty()) {
                                    Iterator it = list2.iterator();
                                    while (true) {
                                        if (it.hasNext()) {
                                            List list3 = ((af1) it.next()).b;
                                            if (!(list3 instanceof Collection) || !list3.isEmpty()) {
                                                Iterator it2 = list3.iterator();
                                                while (it2.hasNext()) {
                                                    if (!((ContentItem) it2.next()).isPlaceholder()) {
                                                        g88Var.d();
                                                    }
                                                }
                                            }
                                        }
                                    }
                                }
                            }
                        }
                        break;
                    case 1:
                        this.b.f.setVisibility(((Boolean) obj).booleanValue() ? 0 : 8);
                        break;
                    case 2:
                        String str = (String) obj;
                        if (str != null) {
                            Toast.makeText(this.b.a.requireContext(), str, 1).show();
                        }
                        break;
                    default:
                        ContentItem contentItem = (ContentItem) obj;
                        if (contentItem != null) {
                            this.b.h.b(contentItem);
                        }
                        break;
                }
                return e6a.a;
            }
        });
        i85 i85Var = this.b;
        vVar.f(i85Var, eVar);
        if (vVar2 != null) {
            vVar2.f(i85Var, new e(new h88(this)));
        }
        final int i2 = 1;
        vVar3.f(i85Var, new e(new sq3(this) { // from class: f88
            public final /* synthetic */ g88 b;

            {
                this.b = this;
            }

            @Override // defpackage.sq3
            public final Object invoke(Object obj) {
                switch (i2) {
                    case 0:
                        g88 g88Var = this.b;
                        cf1 cf1Var = g88Var.u;
                        List list = (List) obj;
                        if (list.isEmpty()) {
                            if (cf1Var != null) {
                                cf1Var.f(ik2.a);
                            }
                            g88Var.g.b.clear();
                            g88Var.v = false;
                        } else {
                            if (cf1Var != null) {
                                cf1Var.f(list);
                            }
                            if (!g88Var.v) {
                                List list2 = list;
                                if (!(list2 instanceof Collection) || !list2.isEmpty()) {
                                    Iterator it = list2.iterator();
                                    while (true) {
                                        if (it.hasNext()) {
                                            List list3 = ((af1) it.next()).b;
                                            if (!(list3 instanceof Collection) || !list3.isEmpty()) {
                                                Iterator it2 = list3.iterator();
                                                while (it2.hasNext()) {
                                                    if (!((ContentItem) it2.next()).isPlaceholder()) {
                                                        g88Var.d();
                                                    }
                                                }
                                            }
                                        }
                                    }
                                }
                            }
                        }
                        break;
                    case 1:
                        this.b.f.setVisibility(((Boolean) obj).booleanValue() ? 0 : 8);
                        break;
                    case 2:
                        String str = (String) obj;
                        if (str != null) {
                            Toast.makeText(this.b.a.requireContext(), str, 1).show();
                        }
                        break;
                    default:
                        ContentItem contentItem = (ContentItem) obj;
                        if (contentItem != null) {
                            this.b.h.b(contentItem);
                        }
                        break;
                }
                return e6a.a;
            }
        }));
        final int i3 = 2;
        vVar4.f(i85Var, new e(new sq3(this) { // from class: f88
            public final /* synthetic */ g88 b;

            {
                this.b = this;
            }

            @Override // defpackage.sq3
            public final Object invoke(Object obj) {
                switch (i3) {
                    case 0:
                        g88 g88Var = this.b;
                        cf1 cf1Var = g88Var.u;
                        List list = (List) obj;
                        if (list.isEmpty()) {
                            if (cf1Var != null) {
                                cf1Var.f(ik2.a);
                            }
                            g88Var.g.b.clear();
                            g88Var.v = false;
                        } else {
                            if (cf1Var != null) {
                                cf1Var.f(list);
                            }
                            if (!g88Var.v) {
                                List list2 = list;
                                if (!(list2 instanceof Collection) || !list2.isEmpty()) {
                                    Iterator it = list2.iterator();
                                    while (true) {
                                        if (it.hasNext()) {
                                            List list3 = ((af1) it.next()).b;
                                            if (!(list3 instanceof Collection) || !list3.isEmpty()) {
                                                Iterator it2 = list3.iterator();
                                                while (it2.hasNext()) {
                                                    if (!((ContentItem) it2.next()).isPlaceholder()) {
                                                        g88Var.d();
                                                    }
                                                }
                                            }
                                        }
                                    }
                                }
                            }
                        }
                        break;
                    case 1:
                        this.b.f.setVisibility(((Boolean) obj).booleanValue() ? 0 : 8);
                        break;
                    case 2:
                        String str = (String) obj;
                        if (str != null) {
                            Toast.makeText(this.b.a.requireContext(), str, 1).show();
                        }
                        break;
                    default:
                        ContentItem contentItem = (ContentItem) obj;
                        if (contentItem != null) {
                            this.b.h.b(contentItem);
                        }
                        break;
                }
                return e6a.a;
            }
        }));
        final int i4 = 3;
        vVar5.f(i85Var, new e(new sq3(this) { // from class: f88
            public final /* synthetic */ g88 b;

            {
                this.b = this;
            }

            @Override // defpackage.sq3
            public final Object invoke(Object obj) {
                switch (i4) {
                    case 0:
                        g88 g88Var = this.b;
                        cf1 cf1Var = g88Var.u;
                        List list = (List) obj;
                        if (list.isEmpty()) {
                            if (cf1Var != null) {
                                cf1Var.f(ik2.a);
                            }
                            g88Var.g.b.clear();
                            g88Var.v = false;
                        } else {
                            if (cf1Var != null) {
                                cf1Var.f(list);
                            }
                            if (!g88Var.v) {
                                List list2 = list;
                                if (!(list2 instanceof Collection) || !list2.isEmpty()) {
                                    Iterator it = list2.iterator();
                                    while (true) {
                                        if (it.hasNext()) {
                                            List list3 = ((af1) it.next()).b;
                                            if (!(list3 instanceof Collection) || !list3.isEmpty()) {
                                                Iterator it2 = list3.iterator();
                                                while (it2.hasNext()) {
                                                    if (!((ContentItem) it2.next()).isPlaceholder()) {
                                                        g88Var.d();
                                                    }
                                                }
                                            }
                                        }
                                    }
                                }
                            }
                        }
                        break;
                    case 1:
                        this.b.f.setVisibility(((Boolean) obj).booleanValue() ? 0 : 8);
                        break;
                    case 2:
                        String str = (String) obj;
                        if (str != null) {
                            Toast.makeText(this.b.a.requireContext(), str, 1).show();
                        }
                        break;
                    default:
                        ContentItem contentItem = (ContentItem) obj;
                        if (contentItem != null) {
                            this.b.h.b(contentItem);
                        }
                        break;
                }
                return e6a.a;
            }
        }));
    }

    public final void c() {
        View viewB = this.w;
        if (viewB == null) {
            viewB = b(this.c, this.x);
        }
        if (viewB != null) {
            viewB.requestFocus();
        }
    }

    public final void d() {
        VerticalGridView verticalGridView = this.e;
        verticalGridView.scrollToPosition(0);
        tb5 tb5Var = this.z;
        verticalGridView.removeCallbacks(tb5Var);
        this.y = 0;
        verticalGridView.post(tb5Var);
    }

    public final void e(c cVar) {
        this.x = cVar;
        b bVar = this.c;
        Iterator it = st.w(new MaterialButton[]{bVar.a, bVar.b, bVar.c, bVar.d, bVar.e, bVar.f}).iterator();
        while (it.hasNext()) {
            ((MaterialButton) it.next()).setActivated(false);
        }
        MaterialButton materialButtonB = b(bVar, cVar);
        if (materialButtonB != null) {
            materialButtonB.setActivated(true);
        }
    }

    public final void f(boolean z) {
        cf1 cf1Var = this.u;
        if (cf1Var != null) {
            cf1Var.h = z;
            SparseArray sparseArray = cf1Var.n;
            int size = sparseArray.size();
            for (int i = 0; i < size && i < sparseArray.size(); i++) {
                ((kd7) sparseArray.valueAt(i)).n = z;
            }
        }
    }
}
