package com.martsnew.tv.ui.history;

import A5.f;
import A5.g;
import A5.h;
import A6.k;
import C5.b;
import G5.a;
import G5.o;
import G5.p;
import G5.q;
import K2.e;
import P6.n;
import U.c;
import Z6.AbstractC0385z;
import Z6.r0;
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.widget.AbstractC0458c0;
import androidx.leanback.widget.C0468h0;
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 com.martsnew.tv.ui.history.TvHistoryFragment;
import java.lang.reflect.InvocationTargetException;
import n4.u0;
import r5.C1505j;
import u5.C0;
import u5.D0;
import u5.K0;
import y5.InterfaceC1762g;

/* JADX INFO: loaded from: classes.dex */
public final class TvHistoryFragment extends a implements InterfaceC1762g {

    /* JADX INFO: renamed from: N1, reason: collision with root package name */
    public static final /* synthetic */ int f11150N1 = 0;

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

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

    /* JADX INFO: renamed from: K1, reason: collision with root package name */
    public D0 f11153K1;

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

    /* JADX INFO: renamed from: M1, reason: collision with root package name */
    public K0 f11155M1;

    public TvHistoryFragment() {
        A6.e eVarJ = AbstractC0707u1.j(new f(15, new f(14, this)));
        this.f11151I1 = new e(n.a(q.class), new g(eVarJ, 14), new h(this, eVarJ, 7), new g(eVarJ, 15));
        this.f11152J1 = new k(new b(1));
    }

    @Override // y5.AbstractC1757b, androidx.leanback.app.r, h0.ComponentCallbacksC1023x
    public final View G(LayoutInflater layoutInflater, ViewGroup viewGroup, Bundle bundle) {
        View view;
        TextView textView;
        View view2;
        ImageView imageView;
        View view3;
        final int i = 0;
        P6.g.e(layoutInflater, "inflater");
        View viewG = super.G(layoutInflater, viewGroup, bundle);
        int i5 = C0.f17523M;
        C0 c02 = (C0) c.b(layoutInflater, R.layout.layout_button_back, viewGroup, false);
        this.f11154L1 = c02;
        if (c02 != null && (view3 = c02.f6656z) != null) {
            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.width = s().getDimensionPixelSize(R.dimen.dp_60);
            layoutParams2.height = s().getDimensionPixelSize(R.dimen.dp_60);
            view3.setLayoutParams(layoutParams2);
        }
        C0 c03 = this.f11154L1;
        if (c03 != null && (imageView = c03.f17524K) != null) {
            imageView.setOnClickListener(new View.OnClickListener(this) { // from class: G5.b

                /* JADX INFO: renamed from: r, reason: collision with root package name */
                public final /* synthetic */ TvHistoryFragment f2982r;

                {
                    this.f2982r = this;
                }

                @Override // android.view.View.OnClickListener
                public final void onClick(View view4) {
                    TvHistoryFragment tvHistoryFragment = this.f2982r;
                    switch (i) {
                        case u0.f15495q /* 0 */:
                            int i8 = TvHistoryFragment.f11150N1;
                            u0.s(tvHistoryFragment).k();
                            break;
                        default:
                            int i9 = TvHistoryFragment.f11150N1;
                            q qVarY0 = tvHistoryFragment.Y0();
                            qVarY0.e(false, new n(qVarY0, null));
                            tvHistoryFragment.f18986B1.f();
                            tvHistoryFragment.Z0();
                            break;
                    }
                }
            });
        }
        int i8 = D0.f17528M;
        D0 d02 = (D0) c.b(layoutInflater, R.layout.layout_button_clear_history, viewGroup, false);
        this.f11153K1 = d02;
        if (d02 != null && (view2 = d02.f6656z) != null) {
            ViewGroup.LayoutParams layoutParams3 = view2.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.width = s().getDimensionPixelSize(R.dimen.dp_188);
            layoutParams4.height = s().getDimensionPixelSize(R.dimen.dp_48);
            layoutParams4.setMargins(s().getDimensionPixelSize(R.dimen.dp_300), s().getDimensionPixelSize(R.dimen.dp_690), 0, 0);
            view2.setLayoutParams(layoutParams4);
        }
        D0 d03 = this.f11153K1;
        if (d03 != null && (textView = d03.f17529K) != null) {
            final int i9 = 1;
            textView.setOnClickListener(new View.OnClickListener(this) { // from class: G5.b

                /* JADX INFO: renamed from: r, reason: collision with root package name */
                public final /* synthetic */ TvHistoryFragment f2982r;

                {
                    this.f2982r = this;
                }

                @Override // android.view.View.OnClickListener
                public final void onClick(View view4) {
                    TvHistoryFragment tvHistoryFragment = this.f2982r;
                    switch (i9) {
                        case u0.f15495q /* 0 */:
                            int i82 = TvHistoryFragment.f11150N1;
                            u0.s(tvHistoryFragment).k();
                            break;
                        default:
                            int i92 = TvHistoryFragment.f11150N1;
                            q qVarY0 = tvHistoryFragment.Y0();
                            qVarY0.e(false, new n(qVarY0, null));
                            tvHistoryFragment.f18986B1.f();
                            tvHistoryFragment.Z0();
                            break;
                    }
                }
            });
        }
        K0 k0M = K0.M(layoutInflater, viewGroup);
        this.f11155M1 = k0M;
        if (k0M != null && (view = k0M.f6656z) != null) {
            ViewGroup.LayoutParams layoutParams5 = view.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 = -1;
            layoutParams6.height = -1;
            view.setLayoutParams(layoutParams6);
        }
        C0 c04 = this.f11154L1;
        W2.g.H(viewG, c04 != null ? c04.f6656z : null);
        return viewG;
    }

    @Override // y5.AbstractC1757b
    public final void H0() {
        AbstractC0385z.r(P.f(this), null, new G5.h(this, null), 3);
    }

    @Override // y5.AbstractC1757b
    public final boolean L0() {
        return false;
    }

    @Override // y5.AbstractC1757b, androidx.leanback.widget.T
    /* JADX INFO: renamed from: N0 */
    public final void e(X x8, Object obj, C0468h0 c0468h0, AbstractC0458c0 abstractC0458c0) throws IllegalAccessException, InvocationTargetException {
        super.e(x8, obj, c0468h0, abstractC0458c0);
        if (obj instanceof Movie) {
            q qVarY0 = Y0();
            Movie movie = (Movie) obj;
            P6.g.e(movie, "movie");
            r0 r0Var = qVarY0.f3013j;
            if (r0Var != null) {
                r0Var.b(null);
            }
            qVarY0.f3013j = qVarY0.e(false, new p(qVarY0, movie, null));
        }
    }

    @Override // y5.AbstractC1757b
    public final void O0(Movie movie) {
        P6.g.e(movie, "movie");
        u0.s(this).j(new C1505j(movie));
    }

    @Override // y5.AbstractC1757b
    public final void P0() {
        W0(true);
        V0(true);
        U0(false);
        q qVarY0 = Y0();
        qVarY0.e(true, new o(qVarY0, null));
    }

    @Override // y5.AbstractC1757b
    public final void U0(boolean z8) {
        super.U0(z8);
        View view = this.X;
        D0 d02 = this.f11153K1;
        W2.g.J(view, d02 != null ? d02.f6656z : null);
    }

    public final q Y0() {
        return (q) this.f11151I1.getValue();
    }

    public final void Z0() {
        ImageView imageView;
        V0(false);
        U0(false);
        W0(false);
        C0 c02 = this.f11154L1;
        if (c02 != null && (imageView = c02.f17524K) != null) {
            imageView.requestFocus();
        }
        View view = this.X;
        K0 k02 = this.f11155M1;
        W2.g.H(view, k02 != null ? k02.f6656z : null);
    }

    @Override // y5.InterfaceC1762g
    public final void i() {
        D0 d02;
        TextView textView;
        if (y()) {
            return;
        }
        if ((this.f8268h1 != 0 && this.f18986B1.f8626c.size() != 0) || (d02 = this.f11153K1) == null || (textView = d02.f17529K) == null) {
            return;
        }
        textView.requestFocus();
    }
}
