package xyz.netfly.ui.live.epg;

import android.view.KeyEvent;
import android.view.View;
import androidx.recyclerview.widget.q1;
import java.util.ArrayList;
import java.util.List;
import java.util.Objects;
import xyz.stream.api.entity.LiveChannelEntity;
import xyz.stream.api.entity.LiveEpgEntity;
import xyz.stream.view.RecyclerWithPositionView;
import xyz.stream.view.UiUtils;
import xyz.stream.view.tvrecyclerview.TvRecyclerView;

/* JADX INFO: loaded from: classes3.dex */
public final /* synthetic */ class b implements ag.f, ag.e, ag.d {

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

    public /* synthetic */ b(EPGView ePGView) {
        this.f35337a = ePGView;
    }

    @Override // ag.e
    public final void a(TvRecyclerView tvRecyclerView, View view, int i10, int i11) {
        EPGView ePGView = this.f35337a;
        ArrayList arrayList = ePGView.U;
        if (((List) arrayList.get(i10)).isEmpty()) {
            return;
        }
        ePGView.f35331q0 = i10;
        ePGView.i(i10);
        if (((List) arrayList.get(i10)).size() == 1 && (tvRecyclerView instanceof RecyclerWithPositionView)) {
            RecyclerWithPositionView recyclerWithPositionView = (RecyclerWithPositionView) tvRecyclerView;
            recyclerWithPositionView.post(new com.tekartik.sqflite.g(ePGView, recyclerWithPositionView, 23));
        }
        ePGView.f();
        ePGView.f35334t0.postDelayed(new xyz.netfly.mobile.player.x(ePGView, view, i10, i11, 1), 800L);
    }

    @Override // ag.d
    public final void b(View view, int i10, int i11) {
        EPGView ePGView = this.f35337a;
        if (i11 != 0 || !kotlinx.coroutines.flow.h.G(ePGView.f35324j0)) {
            if (ePGView.f35322h0 == i10 && ePGView.f35323i0 == i11) {
                ePGView.f();
                return;
            } else {
                ePGView.m(view, (LiveEpgEntity) ((List) ePGView.U.get(i10)).get(i11), i10, i11);
                return;
            }
        }
        ePGView.f();
        com.google.gson.internal.a aVar = ePGView.f35319e0;
        if (aVar != null) {
            ((ve.v) aVar.f24293b).f33928h.q((LiveChannelEntity) ePGView.S.get(i10));
            z.g().b();
        }
    }

    /* JADX WARN: Removed duplicated region for block: B:43:0x0092  */
    @Override // ag.f
    /*
        Code decompiled incorrectly, please refer to instructions dump.
    */
    public final boolean e(View view, int i10, KeyEvent keyEvent, int i11, int i12) {
        int iH;
        int i13 = EPGView.f35314u0;
        EPGView ePGView = this.f35337a;
        ePGView.getClass();
        if (keyEvent.getAction() != 0) {
            return false;
        }
        if ((i10 == 4 || i10 == 111) && ePGView.f35321g0 != null) {
            ePGView.f();
        } else if (i10 == 19 && i11 == 0) {
            ePGView.f();
            Runnable runnable = ePGView.f35325k0;
            if (runnable != null) {
                runnable.run();
            }
        } else if (UiUtils.isDpadRight(i10) && i11 >= 0) {
            ArrayList arrayList = ePGView.U;
            if (i11 < arrayList.size() && !((List) arrayList.get(i11)).isEmpty() && i12 == ((List) arrayList.get(i11)).size() - 1) {
                ePGView.f();
                f fVar = ePGView.f35328n0;
                if (fVar == null) {
                    return false;
                }
                z zVar = (z) ((com.google.gson.internal.a) fVar).f24293b;
                ArrayList arrayList2 = zVar.f35438w;
                if (arrayList2.isEmpty() || (iH = zVar.h() + 1) < 0 || iH >= arrayList2.size()) {
                    return false;
                }
                zVar.A = i11;
                zVar.q(iH, (String) arrayList2.get(iH));
            }
        } else {
            if (!UiUtils.isDpadLeft(i10) || i12 != 0) {
                return false;
            }
            ePGView.f();
            q1 layoutManager = ePGView.R.f27183b.getLayoutManager();
            Objects.requireNonNull(layoutManager);
            View viewFindViewByPosition = layoutManager.findViewByPosition(i11);
            if (viewFindViewByPosition == null) {
                return false;
            }
            viewFindViewByPosition.requestFocus();
        }
        return true;
    }
}
