package com.martsnew.tv.ui.movie_list;

import A1.y;
import A5.f;
import A5.h;
import A6.k;
import C5.b;
import E1.F;
import K2.e;
import N5.a;
import N5.c;
import N5.j;
import N5.l;
import N5.m;
import N5.s;
import N5.t;
import N5.u;
import P6.n;
import W2.g;
import Z6.AbstractC0385z;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.FrameLayout;
import android.widget.ImageView;
import android.widget.TextView;
import androidx.leanback.app.E;
import androidx.leanback.widget.C0455b;
import androidx.leanback.widget.C0468h0;
import androidx.leanback.widget.P0;
import androidx.leanback.widget.S;
import androidx.leanback.widget.T;
import androidx.leanback.widget.X;
import androidx.lifecycle.P;
import com.google.android.gms.internal.measurement.AbstractC0707u1;
import com.martsnew.domain.model.Movie;
import com.martsnew.tv.R;
import java.util.ArrayList;
import n4.u0;
import r5.C1505j;
import u5.C0;
import u5.K0;
import u5.N0;
import u5.T0;
import y5.InterfaceC1760e;
import y5.InterfaceC1761f;
import y5.InterfaceC1762g;

/* JADX INFO: loaded from: classes.dex */
public final class TvMovieListFragment extends a implements InterfaceC1760e, S, T, InterfaceC1761f, InterfaceC1762g {

    /* JADX INFO: renamed from: Y0, reason: collision with root package name */
    public final e f11175Y0;

    /* JADX INFO: renamed from: Z0, reason: collision with root package name */
    public K0 f11176Z0;
    public N0 a1;

    /* JADX INFO: renamed from: b1, reason: collision with root package name */
    public C0 f11177b1;

    /* JADX INFO: renamed from: c1, reason: collision with root package name */
    public T0 f11178c1;

    /* JADX INFO: renamed from: d1, reason: collision with root package name */
    public final y f11179d1;

    /* JADX INFO: renamed from: e1, reason: collision with root package name */
    public View f11180e1;

    /* JADX INFO: renamed from: f1, reason: collision with root package name */
    public int f11181f1;

    /* JADX INFO: renamed from: g1, reason: collision with root package name */
    public final k f11182g1;

    /* JADX INFO: renamed from: h1, reason: collision with root package name */
    public final k f11183h1;

    public TvMovieListFragment() {
        A6.e eVarJ = AbstractC0707u1.j(new f(28, new N5.k(this, 1)));
        this.f11175Y0 = new e(n.a(u.class), new l(eVarJ, 0), new h(this, eVarJ, 13), new l(eVarJ, 1));
        this.f11179d1 = new y(n.a(m.class), new N5.k(this, 0));
        this.f11181f1 = -1;
        this.f11182g1 = new k(new b(4));
        this.f11183h1 = new k(new b(5));
    }

    public static final void s0(TvMovieListFragment tvMovieListFragment, boolean z8) {
        if (z8) {
            View view = tvMovieListFragment.X;
            K0 k02 = tvMovieListFragment.f11176Z0;
            if (k02 != null) {
                g.H(view, k02.f6656z);
                return;
            } else {
                P6.g.h("noResultBinding");
                throw null;
            }
        }
        View view2 = tvMovieListFragment.X;
        K0 k03 = tvMovieListFragment.f11176Z0;
        if (k03 != null) {
            g.J(view2, k03.f6656z);
        } else {
            P6.g.h("noResultBinding");
            throw null;
        }
    }

    @Override // androidx.leanback.app.g, h0.ComponentCallbacksC1023x
    public final void F(Bundle bundle) {
        super.F(bundle);
        c cVar = new c(0, 0);
        cVar.f4751c = false;
        cVar.f4749a = 8;
        this.K0 = cVar;
        cVar.f4752d = this.f8187R0;
        E e8 = this.f8183N0;
        if (e8 != null) {
            cVar.f4753e = e8;
        }
        C0455b c0455b = (C0455b) this.f11182g1.getValue();
        this.f8180J0 = c0455b;
        P0 p02 = this.f8181L0;
        if (p02 != null) {
            this.K0.c(p02, c0455b);
            int i = this.f8185P0;
            if (i != -1) {
                this.f8181L0.f8486c.setSelectedPosition(i);
            }
        }
    }

    @Override // androidx.leanback.app.E, h0.ComponentCallbacksC1023x
    public final View G(LayoutInflater layoutInflater, ViewGroup viewGroup, Bundle bundle) {
        TextView textView;
        View view;
        ImageView imageView;
        View view2;
        P6.g.e(layoutInflater, "inflater");
        View viewG = super.G(layoutInflater, viewGroup, bundle);
        ViewGroup viewGroup2 = (ViewGroup) viewG;
        K0 k0M = K0.M(layoutInflater, viewGroup2);
        this.f11176Z0 = k0M;
        if (k0M == null) {
            P6.g.h("noResultBinding");
            throw null;
        }
        View view3 = k0M.f6656z;
        P6.g.d(view3, "getRoot(...)");
        ViewGroup.LayoutParams layoutParams = view3.getLayoutParams();
        if (layoutParams == null) {
            throw new NullPointerException("null cannot be cast to non-null type android.widget.FrameLayout.LayoutParams");
        }
        FrameLayout.LayoutParams layoutParams2 = (FrameLayout.LayoutParams) layoutParams;
        layoutParams2.setMargins(s().getDimensionPixelSize(R.dimen.dp_150), 0, 0, 0);
        view3.setLayoutParams(layoutParams2);
        int i = N0.f17624M;
        N0 n02 = (N0) U.c.b(layoutInflater, R.layout.layout_shimmer_search, viewGroup2, false);
        this.a1 = n02;
        if (n02 == null) {
            P6.g.h("layoutShimmer");
            throw null;
        }
        View view4 = n02.f6656z;
        P6.g.d(view4, "getRoot(...)");
        ViewGroup.LayoutParams layoutParams3 = view4.getLayoutParams();
        if (layoutParams3 == null) {
            throw new NullPointerException("null cannot be cast to non-null type android.widget.FrameLayout.LayoutParams");
        }
        FrameLayout.LayoutParams layoutParams4 = (FrameLayout.LayoutParams) layoutParams3;
        layoutParams4.setMargins(s().getDimensionPixelSize(R.dimen.dp_150), s().getDimensionPixelSize(R.dimen.dp_188), 0, 0);
        view4.setLayoutParams(layoutParams4);
        int i5 = C0.f17523M;
        C0 c02 = (C0) U.c.b(layoutInflater, R.layout.layout_button_back, viewGroup, false);
        this.f11177b1 = c02;
        if (c02 != null && (view2 = c02.f6656z) != null) {
            ViewGroup.LayoutParams layoutParams5 = view2.getLayoutParams();
            if (layoutParams5 == null) {
                throw new NullPointerException("null cannot be cast to non-null type android.widget.FrameLayout.LayoutParams");
            }
            FrameLayout.LayoutParams layoutParams6 = (FrameLayout.LayoutParams) layoutParams5;
            layoutParams6.width = s().getDimensionPixelSize(R.dimen.dp_60);
            layoutParams6.height = s().getDimensionPixelSize(R.dimen.dp_60);
            view2.setLayoutParams(layoutParams6);
        }
        C0 c03 = this.f11177b1;
        if (c03 != null && (imageView = c03.f17524K) != null) {
            imageView.setOnClickListener(new C5.c(12, this));
        }
        int i8 = T0.f17672M;
        T0 t02 = (T0) U.c.b(layoutInflater, R.layout.view_title_grid, viewGroup, false);
        this.f11178c1 = t02;
        if (t02 != null && (view = t02.f6656z) != null) {
            ViewGroup.LayoutParams layoutParams7 = view.getLayoutParams();
            if (layoutParams7 == null) {
                throw new NullPointerException("null cannot be cast to non-null type android.widget.FrameLayout.LayoutParams");
            }
            FrameLayout.LayoutParams layoutParams8 = (FrameLayout.LayoutParams) layoutParams7;
            layoutParams8.setMargins(s().getDimensionPixelSize(R.dimen.dp_150), s().getDimensionPixelSize(R.dimen.dp_75), 0, 0);
            view.setLayoutParams(layoutParams8);
        }
        N0 n03 = this.a1;
        if (n03 == null) {
            P6.g.h("layoutShimmer");
            throw null;
        }
        n03.f17625K.setAdapter((W5.c) this.f11183h1.getValue());
        T0 t03 = this.f11178c1;
        y yVar = this.f11179d1;
        if (t03 != null && (textView = t03.f17673K) != null) {
            textView.setText(((m) yVar.getValue()).f4776b);
        }
        C0 c04 = this.f11177b1;
        g.H(viewG, c04 != null ? c04.f6656z : null);
        T0 t04 = this.f11178c1;
        g.H(viewG, t04 != null ? t04.f6656z : null);
        this.f8183N0 = this;
        c cVar = this.K0;
        if (cVar != null) {
            cVar.f4753e = this;
        }
        this.f8182M0 = this;
        AbstractC0385z.r(P.f(this), null, new j(null, this), 3);
        u uVarT0 = t0();
        uVarT0.e(false, new s(((m) yVar.getValue()).f4775a, ((m) yVar.getValue()).f4777c, uVarT0, null));
        return viewG;
    }

    @Override // androidx.leanback.widget.S
    public final void b(X x8, Object obj, C0468h0 c0468h0, Object obj2) {
        if (obj instanceof Movie) {
            Movie movie = (Movie) obj;
            F fS = u0.s(this);
            P6.g.e(movie, "movie");
            fS.j(new C1505j(movie));
        }
    }

    @Override // y5.InterfaceC1761f
    public final void c() {
        ImageView imageView;
        View view;
        C0 c02 = this.f11177b1;
        if (c02 == null || (imageView = c02.f17524K) == null || !imageView.isFocused() || (view = this.f11180e1) == null) {
            return;
        }
        view.requestFocus();
    }

    @Override // androidx.leanback.widget.T
    public final void e(X x8, Object obj, C0468h0 c0468h0, Object obj2) {
        this.f11180e1 = x8 != null ? x8.f8620a : null;
        if (obj instanceof Movie) {
            int iIndexOf = ((C0455b) this.f11182g1.getValue()).f8626c.indexOf(obj);
            this.f11181f1 = iIndexOf;
            C0455b c0455b = this.f8180J0;
            if (c0455b != null) {
                ArrayList arrayList = c0455b.f8626c;
                if (arrayList.size() < 30 || (arrayList.size() / 8) - (iIndexOf / 8) > 4) {
                    return;
                }
                u uVarT0 = t0();
                y yVar = this.f11179d1;
                uVarT0.e(false, new t(((m) yVar.getValue()).f4775a, ((m) yVar.getValue()).f4777c, uVarT0, (arrayList.size() / 30) + 1, null));
            }
        }
    }

    @Override // y5.InterfaceC1760e
    public final void f() {
        C0 c02;
        View view;
        if (this.f11181f1 != 0 || (c02 = this.f11177b1) == null || (view = c02.f6656z) == null) {
            return;
        }
        view.requestFocus();
    }

    @Override // y5.InterfaceC1762g
    public final void i() {
        C0 c02;
        View view;
        if (this.f11181f1 >= 8 || (c02 = this.f11177b1) == null || (view = c02.f6656z) == null) {
            return;
        }
        view.requestFocus();
    }

    public final u t0() {
        return (u) this.f11175Y0.getValue();
    }
}
