package xyz.netfly.ui.iptv;

import android.content.Intent;
import android.net.Uri;
import android.os.Handler;
import android.os.Looper;
import android.view.KeyEvent;
import android.view.MotionEvent;
import android.view.View;
import android.view.animation.AnimationUtils;
import android.widget.TextView;
import androidx.annotation.Nullable;
import ie.k;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.LinkedHashMap;
import java.util.LinkedHashSet;
import java.util.Objects;
import org.drive_hunter.R;
import pe.h;
import rf.w;
import tv.danmaku.ijk.media.player.IMediaPlayer;
import tv.danmaku.ijk.media.player.MediaSource;
import tv.danmaku.ijk.media.player.misc.ITrackInfo;
import tv.danmaku.ijk.media.player.ui.IjkVideoView;
import x1.a;
import xyz.netfly.ui.iptv.IptvLiveActivity;
import xyz.netfly.ui.live.tv.CustomLiveControl;
import xyz.stream.api.entity.LiveChannelEntity;
import xyz.stream.api.viewmodel.LiveViewModel;
import xyz.stream.download.config.InnerConstant;
import xyz.stream.utils.e;
import xyz.stream.utils.e0;
import xyz.stream.utils.f0;
import xyz.stream.view.BaseActivity;
import xyz.stream.view.SelectDialogController;
import xyz.stream.view.UiUtils;
import xyz.stream.view.VideoGestureFrameLayout;

/* JADX INFO: loaded from: classes3.dex */
public class IptvLiveActivity extends BaseActivity<LiveViewModel, k> implements IMediaPlayer.Listener, View.OnKeyListener, VideoGestureFrameLayout.VideoGestureListener {
    public static final /* synthetic */ int R = 0;

    /* JADX INFO: renamed from: c, reason: collision with root package name */
    public a f35293c;

    /* JADX INFO: renamed from: d, reason: collision with root package name */
    public IjkVideoView f35294d;

    /* JADX INFO: renamed from: e, reason: collision with root package name */
    public LiveChannelEntity f35295e;

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

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

    /* JADX INFO: renamed from: h, reason: collision with root package name */
    public boolean f35298h;

    /* JADX INFO: renamed from: b, reason: collision with root package name */
    public final Handler f35292b = new Handler(Looper.getMainLooper());

    /* JADX INFO: renamed from: i, reason: collision with root package name */
    public String f35299i = "";

    /* JADX INFO: renamed from: j, reason: collision with root package name */
    public final h f35300j = new h(this, 1);

    /* JADX INFO: renamed from: k, reason: collision with root package name */
    public final h f35301k = new h(this, 2);

    /* JADX INFO: renamed from: l, reason: collision with root package name */
    public int f35302l = -1;

    /* JADX INFO: renamed from: m, reason: collision with root package name */
    public int f35303m = -1;
    public String Q = "";

    public static boolean K(IptvLiveActivity iptvLiveActivity, int i10, KeyEvent keyEvent) {
        iptvLiveActivity.getClass();
        if (keyEvent.getAction() != 0) {
            return false;
        }
        if (i10 == 19) {
            iptvLiveActivity.O(true);
        } else if (i10 == 20) {
            iptvLiveActivity.O(false);
        } else {
            if (i10 != 4) {
                return false;
            }
            iptvLiveActivity.M();
        }
        return true;
    }

    public final void L(LiveChannelEntity liveChannelEntity) {
        if (liveChannelEntity == null || liveChannelEntity.getId() == null) {
            return;
        }
        LiveChannelEntity liveChannelEntity2 = this.f35295e;
        if (liveChannelEntity2 != null && Objects.equals(liveChannelEntity2.getId(), liveChannelEntity.getId()) && Objects.equals(this.f35295e.getCategoryId(), liveChannelEntity.getCategoryId())) {
            S();
            return;
        }
        this.f35295e = liveChannelEntity;
        this.f35296f = liveChannelEntity.getCategoryId() == null ? this.f35296f : liveChannelEntity.getCategoryId().intValue();
        a aVar = this.f35293c;
        if (aVar != null) {
            aVar.c(liveChannelEntity);
        }
        this.f35297g = 0;
        R();
        S();
        U();
    }

    public final void M() {
        this.f35298h = false;
        this.f35292b.removeCallbacks(this.f35301k);
        if (e.d().f36119h) {
            ((k) this.binding).f27104j.a();
        } else {
            CustomLiveControl customLiveControl = ((k) this.binding).f27103i;
            customLiveControl.setVisibility(8);
            customLiveControl.f35466a.f27085d.startAnimation(AnimationUtils.loadAnimation(customLiveControl.getContext(), R.anim.slide_out_to_bottom));
        }
        ((k) this.binding).f27097c.requestFocus();
    }

    public final void N() {
        M();
        Intent intent = new Intent(this, (Class<?>) IptvSelectChannelActivity.class);
        LiveChannelEntity liveChannelEntity = this.f35295e;
        intent.putExtra(InnerConstant.Db.f36069id, (liveChannelEntity == null || liveChannelEntity.getId() == null) ? 0 : this.f35295e.getId().intValue());
        intent.putExtra("groupId", this.f35296f);
        startActivityForResult(intent, 100);
    }

    public final void O(boolean z10) {
        a aVar = this.f35293c;
        if (aVar == null) {
            return;
        }
        L(z10 ? aVar.e(this.f35295e, true) : aVar.e(this.f35295e, false));
    }

    public final void P() {
        Handler handler = this.f35292b;
        handler.removeCallbacks(this.f35301k);
        handler.removeCallbacks(this.f35300j);
        IjkVideoView ijkVideoView = this.f35294d;
        if (ijkVideoView == null) {
            return;
        }
        try {
            ijkVideoView.removeListener();
        } catch (Throwable unused) {
        }
        try {
            this.f35294d.stop();
        } catch (Throwable unused2) {
        }
        try {
            this.f35294d.release();
        } catch (Throwable unused3) {
        }
    }

    public final void Q() {
        if (this.f35297g >= 3 || isFinishing() || isDestroyed()) {
            T();
        } else {
            this.f35297g++;
            this.f35292b.postDelayed(this.f35300j, 1000L);
        }
    }

    public final void R() {
        a aVar;
        boolean zContains;
        LiveChannelEntity liveChannelEntity = this.f35295e;
        if (liveChannelEntity == null || (aVar = this.f35293c) == null) {
            return;
        }
        int i10 = aVar.f34323a;
        Integer id2 = liveChannelEntity.getId();
        if (id2 == null) {
            zContains = false;
        } else {
            zContains = kotlinx.coroutines.flow.h.u("iptv_favorites_" + i10).contains(String.valueOf(id2));
        }
        String str = this.f35295e.getId() + " " + this.f35295e.getName();
        ((k) this.binding).f27103i.setData(this.f35295e.getName(), String.valueOf(this.f35295e.getId()), this.f35295e.getLogo(), zContains);
        ((k) this.binding).f27104j.setData(str, this.f35295e.getLogo(), zContains);
    }

    public final void S() {
        R();
        this.f35298h = true;
        if (e.d().f36119h) {
            ((k) this.binding).f27104j.b();
        } else {
            CustomLiveControl customLiveControl = ((k) this.binding).f27103i;
            customLiveControl.setVisibility(0);
            customLiveControl.f35466a.f27085d.startAnimation(AnimationUtils.loadAnimation(customLiveControl.getContext(), R.anim.slide_in_from_bottom));
        }
        Handler handler = this.f35292b;
        h hVar = this.f35301k;
        handler.removeCallbacks(hVar);
        handler.postDelayed(hVar, 5000L);
    }

    public final void T() {
        ((k) this.binding).f27113s.setVisibility(8);
        ((k) this.binding).f27112r.setText("Sorry, your current channel failed to load.");
        TextView textView = ((k) this.binding).f27111q;
        StringBuilder sb = new StringBuilder("Error code ");
        String str = this.Q;
        sb.append((str == null || str.isEmpty()) ? Integer.valueOf(this.f35303m) : this.Q);
        sb.append(".");
        textView.setText(sb.toString());
        ((k) this.binding).f27110p.setVisibility(0);
        ((k) this.binding).f27097c.requestFocus();
    }

    public final void U() {
        LiveChannelEntity liveChannelEntity;
        if (this.f35294d == null || (liveChannelEntity = this.f35295e) == null) {
            return;
        }
        String turboUrl = liveChannelEntity.getTurboUrl();
        this.f35299i = turboUrl;
        if (turboUrl == null || turboUrl.trim().isEmpty()) {
            T();
            return;
        }
        ((k) this.binding).f27110p.setVisibility(8);
        ((k) this.binding).f27113s.setVisibility(0);
        ((k) this.binding).f27114t.setText("");
        try {
            this.f35294d.removeListener();
            this.f35294d.stop();
        } catch (Throwable unused) {
        }
        try {
            this.f35294d.release();
        } catch (Throwable unused2) {
        }
        this.f35294d.addListener(this);
        this.f35294d.setPlayer(2);
        this.f35294d.decode(1);
        this.f35294d.setResizeMode(f0.o().p("sp_live_video_ratio", 4));
        this.f35294d.setVolume(1.0f, 1.0f);
        this.f35294d.setMediaSourceLive(new MediaSource(new HashMap(), Uri.parse(this.f35299i)));
    }

    public final void V() {
        LiveChannelEntity liveChannelEntity;
        if (this.f35293c == null || (liveChannelEntity = this.f35295e) == null || liveChannelEntity.getId() == null) {
            return;
        }
        int i10 = this.f35293c.f34323a;
        Integer id2 = this.f35295e.getId();
        boolean z10 = false;
        if (id2 != null) {
            LinkedHashSet linkedHashSetU = kotlinx.coroutines.flow.h.u("iptv_favorites_" + i10);
            String strValueOf = String.valueOf(id2);
            if (linkedHashSetU.contains(strValueOf)) {
                linkedHashSetU.remove(strValueOf);
            } else {
                linkedHashSetU.add(strValueOf);
                z10 = true;
            }
            kotlinx.coroutines.flow.h.L("iptv_favorites_" + i10, linkedHashSetU);
        }
        ((k) this.binding).f27103i.setLiked(z10);
        ((k) this.binding).f27104j.setLiked(z10);
    }

    @Override // xyz.stream.view.BaseActivity
    public final v3.a getViewBinding() {
        return k.inflate(getLayoutInflater(), null, false);
    }

    @Override // xyz.stream.view.BaseActivity
    public final void initListener() {
        ((k) this.binding).f27097c.setOnKeyListener(this);
        ((k) this.binding).f27097c.setVideoGestureListener(this);
        final int i10 = 0;
        ((k) this.binding).f27103i.getChannelList().setOnClickListener(new View.OnClickListener(this) { // from class: pe.i

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

            {
                this.f31952b = this;
            }

            @Override // android.view.View.OnClickListener
            public final void onClick(View view) {
                int i11 = i10;
                IptvLiveActivity iptvLiveActivity = this.f31952b;
                switch (i11) {
                    case 0:
                        int i12 = IptvLiveActivity.R;
                        iptvLiveActivity.N();
                        break;
                    case 1:
                        int i13 = IptvLiveActivity.R;
                        iptvLiveActivity.getClass();
                        LinkedHashMap linkedHashMapR = w.r(iptvLiveActivity);
                        ArrayList arrayList = new ArrayList(linkedHashMapR.values());
                        new SelectDialogController(iptvLiveActivity, arrayList, Math.max(0, arrayList.indexOf(linkedHashMapR.get(Integer.valueOf(f0.o().p("sp_live_video_ratio", 4))))), new e0(iptvLiveActivity, linkedHashMapR, 22));
                        break;
                    case 2:
                        int i14 = IptvLiveActivity.R;
                        iptvLiveActivity.finish();
                        break;
                    case 3:
                        int i15 = IptvLiveActivity.R;
                        iptvLiveActivity.V();
                        break;
                    case 4:
                        int i16 = IptvLiveActivity.R;
                        iptvLiveActivity.N();
                        break;
                    case 5:
                        int i17 = IptvLiveActivity.R;
                        iptvLiveActivity.V();
                        break;
                    case 6:
                        int i18 = IptvLiveActivity.R;
                        iptvLiveActivity.O(false);
                        break;
                    default:
                        int i19 = IptvLiveActivity.R;
                        iptvLiveActivity.O(true);
                        break;
                }
            }
        });
        final int i11 = 3;
        ((k) this.binding).f27103i.getBtnLike().setOnClickListener(new View.OnClickListener(this) { // from class: pe.i

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

            {
                this.f31952b = this;
            }

            @Override // android.view.View.OnClickListener
            public final void onClick(View view) {
                int i112 = i11;
                IptvLiveActivity iptvLiveActivity = this.f31952b;
                switch (i112) {
                    case 0:
                        int i12 = IptvLiveActivity.R;
                        iptvLiveActivity.N();
                        break;
                    case 1:
                        int i13 = IptvLiveActivity.R;
                        iptvLiveActivity.getClass();
                        LinkedHashMap linkedHashMapR = w.r(iptvLiveActivity);
                        ArrayList arrayList = new ArrayList(linkedHashMapR.values());
                        new SelectDialogController(iptvLiveActivity, arrayList, Math.max(0, arrayList.indexOf(linkedHashMapR.get(Integer.valueOf(f0.o().p("sp_live_video_ratio", 4))))), new e0(iptvLiveActivity, linkedHashMapR, 22));
                        break;
                    case 2:
                        int i14 = IptvLiveActivity.R;
                        iptvLiveActivity.finish();
                        break;
                    case 3:
                        int i15 = IptvLiveActivity.R;
                        iptvLiveActivity.V();
                        break;
                    case 4:
                        int i16 = IptvLiveActivity.R;
                        iptvLiveActivity.N();
                        break;
                    case 5:
                        int i17 = IptvLiveActivity.R;
                        iptvLiveActivity.V();
                        break;
                    case 6:
                        int i18 = IptvLiveActivity.R;
                        iptvLiveActivity.O(false);
                        break;
                    default:
                        int i19 = IptvLiveActivity.R;
                        iptvLiveActivity.O(true);
                        break;
                }
            }
        });
        ((k) this.binding).f27103i.getChannelList().setOnKeyListener(new View.OnKeyListener(this) { // from class: pe.j

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

            {
                this.f31954b = this;
            }

            @Override // android.view.View.OnKeyListener
            public final boolean onKey(View view, int i12, KeyEvent keyEvent) {
                int i13 = i10;
                IptvLiveActivity iptvLiveActivity = this.f31954b;
                switch (i13) {
                }
                return IptvLiveActivity.K(iptvLiveActivity, i12, keyEvent);
            }
        });
        final int i12 = 1;
        ((k) this.binding).f27103i.getBtnLike().setOnKeyListener(new View.OnKeyListener(this) { // from class: pe.j

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

            {
                this.f31954b = this;
            }

            @Override // android.view.View.OnKeyListener
            public final boolean onKey(View view, int i122, KeyEvent keyEvent) {
                int i13 = i12;
                IptvLiveActivity iptvLiveActivity = this.f31954b;
                switch (i13) {
                }
                return IptvLiveActivity.K(iptvLiveActivity, i122, keyEvent);
            }
        });
        ((k) this.binding).f27103i.getChannelList().setOnFocusChangeListener(new View.OnFocusChangeListener(this) { // from class: pe.k

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

            {
                this.f31956b = this;
            }

            /* JADX WARN: Removed duplicated region for block: B:16:0x004a  */
            @Override // android.view.View.OnFocusChangeListener
            /*
                Code decompiled incorrectly, please refer to instructions dump.
            */
            public final void onFocusChange(View view, boolean z10) {
                boolean z11;
                LiveChannelEntity liveChannelEntity;
                int i13 = i10;
                IptvLiveActivity iptvLiveActivity = this.f31956b;
                switch (i13) {
                    case 0:
                        int i14 = IptvLiveActivity.R;
                        ((ie.k) iptvLiveActivity.binding).f27103i.setChannelListIcon(z10);
                        if (z10) {
                            Handler handler = iptvLiveActivity.f35292b;
                            h hVar = iptvLiveActivity.f35301k;
                            handler.removeCallbacks(hVar);
                            handler.postDelayed(hVar, 5000L);
                        }
                        break;
                    default:
                        int i15 = IptvLiveActivity.R;
                        CustomLiveControl customLiveControl = ((ie.k) iptvLiveActivity.binding).f27103i;
                        if (iptvLiveActivity.f35293c == null || (liveChannelEntity = iptvLiveActivity.f35295e) == null || liveChannelEntity.getId() == null) {
                            z11 = false;
                        } else {
                            int i16 = iptvLiveActivity.f35293c.f34323a;
                            Integer id2 = iptvLiveActivity.f35295e.getId();
                            if (id2 != null) {
                                if (kotlinx.coroutines.flow.h.u("iptv_favorites_" + i16).contains(String.valueOf(id2))) {
                                    z11 = true;
                                }
                            }
                        }
                        customLiveControl.setLiked(z11);
                        if (z10) {
                            Handler handler2 = iptvLiveActivity.f35292b;
                            h hVar2 = iptvLiveActivity.f35301k;
                            handler2.removeCallbacks(hVar2);
                            handler2.postDelayed(hVar2, 5000L);
                        }
                        break;
                }
            }
        });
        ((k) this.binding).f27103i.getBtnLike().setOnFocusChangeListener(new View.OnFocusChangeListener(this) { // from class: pe.k

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

            {
                this.f31956b = this;
            }

            /* JADX WARN: Removed duplicated region for block: B:16:0x004a  */
            @Override // android.view.View.OnFocusChangeListener
            /*
                Code decompiled incorrectly, please refer to instructions dump.
            */
            public final void onFocusChange(View view, boolean z10) {
                boolean z11;
                LiveChannelEntity liveChannelEntity;
                int i13 = i12;
                IptvLiveActivity iptvLiveActivity = this.f31956b;
                switch (i13) {
                    case 0:
                        int i14 = IptvLiveActivity.R;
                        ((ie.k) iptvLiveActivity.binding).f27103i.setChannelListIcon(z10);
                        if (z10) {
                            Handler handler = iptvLiveActivity.f35292b;
                            h hVar = iptvLiveActivity.f35301k;
                            handler.removeCallbacks(hVar);
                            handler.postDelayed(hVar, 5000L);
                        }
                        break;
                    default:
                        int i15 = IptvLiveActivity.R;
                        CustomLiveControl customLiveControl = ((ie.k) iptvLiveActivity.binding).f27103i;
                        if (iptvLiveActivity.f35293c == null || (liveChannelEntity = iptvLiveActivity.f35295e) == null || liveChannelEntity.getId() == null) {
                            z11 = false;
                        } else {
                            int i16 = iptvLiveActivity.f35293c.f34323a;
                            Integer id2 = iptvLiveActivity.f35295e.getId();
                            if (id2 != null) {
                                if (kotlinx.coroutines.flow.h.u("iptv_favorites_" + i16).contains(String.valueOf(id2))) {
                                    z11 = true;
                                }
                            }
                        }
                        customLiveControl.setLiked(z11);
                        if (z10) {
                            Handler handler2 = iptvLiveActivity.f35292b;
                            h hVar2 = iptvLiveActivity.f35301k;
                            handler2.removeCallbacks(hVar2);
                            handler2.postDelayed(hVar2, 5000L);
                        }
                        break;
                }
            }
        });
        final int i13 = 4;
        ((k) this.binding).f27104j.getBtnMenu().setOnClickListener(new View.OnClickListener(this) { // from class: pe.i

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

            {
                this.f31952b = this;
            }

            @Override // android.view.View.OnClickListener
            public final void onClick(View view) {
                int i112 = i13;
                IptvLiveActivity iptvLiveActivity = this.f31952b;
                switch (i112) {
                    case 0:
                        int i122 = IptvLiveActivity.R;
                        iptvLiveActivity.N();
                        break;
                    case 1:
                        int i132 = IptvLiveActivity.R;
                        iptvLiveActivity.getClass();
                        LinkedHashMap linkedHashMapR = w.r(iptvLiveActivity);
                        ArrayList arrayList = new ArrayList(linkedHashMapR.values());
                        new SelectDialogController(iptvLiveActivity, arrayList, Math.max(0, arrayList.indexOf(linkedHashMapR.get(Integer.valueOf(f0.o().p("sp_live_video_ratio", 4))))), new e0(iptvLiveActivity, linkedHashMapR, 22));
                        break;
                    case 2:
                        int i14 = IptvLiveActivity.R;
                        iptvLiveActivity.finish();
                        break;
                    case 3:
                        int i15 = IptvLiveActivity.R;
                        iptvLiveActivity.V();
                        break;
                    case 4:
                        int i16 = IptvLiveActivity.R;
                        iptvLiveActivity.N();
                        break;
                    case 5:
                        int i17 = IptvLiveActivity.R;
                        iptvLiveActivity.V();
                        break;
                    case 6:
                        int i18 = IptvLiveActivity.R;
                        iptvLiveActivity.O(false);
                        break;
                    default:
                        int i19 = IptvLiveActivity.R;
                        iptvLiveActivity.O(true);
                        break;
                }
            }
        });
        final int i14 = 5;
        ((k) this.binding).f27104j.getBtnLike().setOnClickListener(new View.OnClickListener(this) { // from class: pe.i

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

            {
                this.f31952b = this;
            }

            @Override // android.view.View.OnClickListener
            public final void onClick(View view) {
                int i112 = i14;
                IptvLiveActivity iptvLiveActivity = this.f31952b;
                switch (i112) {
                    case 0:
                        int i122 = IptvLiveActivity.R;
                        iptvLiveActivity.N();
                        break;
                    case 1:
                        int i132 = IptvLiveActivity.R;
                        iptvLiveActivity.getClass();
                        LinkedHashMap linkedHashMapR = w.r(iptvLiveActivity);
                        ArrayList arrayList = new ArrayList(linkedHashMapR.values());
                        new SelectDialogController(iptvLiveActivity, arrayList, Math.max(0, arrayList.indexOf(linkedHashMapR.get(Integer.valueOf(f0.o().p("sp_live_video_ratio", 4))))), new e0(iptvLiveActivity, linkedHashMapR, 22));
                        break;
                    case 2:
                        int i142 = IptvLiveActivity.R;
                        iptvLiveActivity.finish();
                        break;
                    case 3:
                        int i15 = IptvLiveActivity.R;
                        iptvLiveActivity.V();
                        break;
                    case 4:
                        int i16 = IptvLiveActivity.R;
                        iptvLiveActivity.N();
                        break;
                    case 5:
                        int i17 = IptvLiveActivity.R;
                        iptvLiveActivity.V();
                        break;
                    case 6:
                        int i18 = IptvLiveActivity.R;
                        iptvLiveActivity.O(false);
                        break;
                    default:
                        int i19 = IptvLiveActivity.R;
                        iptvLiveActivity.O(true);
                        break;
                }
            }
        });
        final int i15 = 6;
        ((k) this.binding).f27104j.getBtnPreview().setOnClickListener(new View.OnClickListener(this) { // from class: pe.i

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

            {
                this.f31952b = this;
            }

            @Override // android.view.View.OnClickListener
            public final void onClick(View view) {
                int i112 = i15;
                IptvLiveActivity iptvLiveActivity = this.f31952b;
                switch (i112) {
                    case 0:
                        int i122 = IptvLiveActivity.R;
                        iptvLiveActivity.N();
                        break;
                    case 1:
                        int i132 = IptvLiveActivity.R;
                        iptvLiveActivity.getClass();
                        LinkedHashMap linkedHashMapR = w.r(iptvLiveActivity);
                        ArrayList arrayList = new ArrayList(linkedHashMapR.values());
                        new SelectDialogController(iptvLiveActivity, arrayList, Math.max(0, arrayList.indexOf(linkedHashMapR.get(Integer.valueOf(f0.o().p("sp_live_video_ratio", 4))))), new e0(iptvLiveActivity, linkedHashMapR, 22));
                        break;
                    case 2:
                        int i142 = IptvLiveActivity.R;
                        iptvLiveActivity.finish();
                        break;
                    case 3:
                        int i152 = IptvLiveActivity.R;
                        iptvLiveActivity.V();
                        break;
                    case 4:
                        int i16 = IptvLiveActivity.R;
                        iptvLiveActivity.N();
                        break;
                    case 5:
                        int i17 = IptvLiveActivity.R;
                        iptvLiveActivity.V();
                        break;
                    case 6:
                        int i18 = IptvLiveActivity.R;
                        iptvLiveActivity.O(false);
                        break;
                    default:
                        int i19 = IptvLiveActivity.R;
                        iptvLiveActivity.O(true);
                        break;
                }
            }
        });
        final int i16 = 7;
        ((k) this.binding).f27104j.getBtnNext().setOnClickListener(new View.OnClickListener(this) { // from class: pe.i

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

            {
                this.f31952b = this;
            }

            @Override // android.view.View.OnClickListener
            public final void onClick(View view) {
                int i112 = i16;
                IptvLiveActivity iptvLiveActivity = this.f31952b;
                switch (i112) {
                    case 0:
                        int i122 = IptvLiveActivity.R;
                        iptvLiveActivity.N();
                        break;
                    case 1:
                        int i132 = IptvLiveActivity.R;
                        iptvLiveActivity.getClass();
                        LinkedHashMap linkedHashMapR = w.r(iptvLiveActivity);
                        ArrayList arrayList = new ArrayList(linkedHashMapR.values());
                        new SelectDialogController(iptvLiveActivity, arrayList, Math.max(0, arrayList.indexOf(linkedHashMapR.get(Integer.valueOf(f0.o().p("sp_live_video_ratio", 4))))), new e0(iptvLiveActivity, linkedHashMapR, 22));
                        break;
                    case 2:
                        int i142 = IptvLiveActivity.R;
                        iptvLiveActivity.finish();
                        break;
                    case 3:
                        int i152 = IptvLiveActivity.R;
                        iptvLiveActivity.V();
                        break;
                    case 4:
                        int i162 = IptvLiveActivity.R;
                        iptvLiveActivity.N();
                        break;
                    case 5:
                        int i17 = IptvLiveActivity.R;
                        iptvLiveActivity.V();
                        break;
                    case 6:
                        int i18 = IptvLiveActivity.R;
                        iptvLiveActivity.O(false);
                        break;
                    default:
                        int i19 = IptvLiveActivity.R;
                        iptvLiveActivity.O(true);
                        break;
                }
            }
        });
        ((k) this.binding).f27104j.getRatio().setOnClickListener(new View.OnClickListener(this) { // from class: pe.i

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

            {
                this.f31952b = this;
            }

            @Override // android.view.View.OnClickListener
            public final void onClick(View view) {
                int i112 = i12;
                IptvLiveActivity iptvLiveActivity = this.f31952b;
                switch (i112) {
                    case 0:
                        int i122 = IptvLiveActivity.R;
                        iptvLiveActivity.N();
                        break;
                    case 1:
                        int i132 = IptvLiveActivity.R;
                        iptvLiveActivity.getClass();
                        LinkedHashMap linkedHashMapR = w.r(iptvLiveActivity);
                        ArrayList arrayList = new ArrayList(linkedHashMapR.values());
                        new SelectDialogController(iptvLiveActivity, arrayList, Math.max(0, arrayList.indexOf(linkedHashMapR.get(Integer.valueOf(f0.o().p("sp_live_video_ratio", 4))))), new e0(iptvLiveActivity, linkedHashMapR, 22));
                        break;
                    case 2:
                        int i142 = IptvLiveActivity.R;
                        iptvLiveActivity.finish();
                        break;
                    case 3:
                        int i152 = IptvLiveActivity.R;
                        iptvLiveActivity.V();
                        break;
                    case 4:
                        int i162 = IptvLiveActivity.R;
                        iptvLiveActivity.N();
                        break;
                    case 5:
                        int i17 = IptvLiveActivity.R;
                        iptvLiveActivity.V();
                        break;
                    case 6:
                        int i18 = IptvLiveActivity.R;
                        iptvLiveActivity.O(false);
                        break;
                    default:
                        int i19 = IptvLiveActivity.R;
                        iptvLiveActivity.O(true);
                        break;
                }
            }
        });
        ((k) this.binding).f27104j.getIvBack().setVisibility(0);
        final int i17 = 2;
        ((k) this.binding).f27104j.getIvBack().setOnClickListener(new View.OnClickListener(this) { // from class: pe.i

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

            {
                this.f31952b = this;
            }

            @Override // android.view.View.OnClickListener
            public final void onClick(View view) {
                int i112 = i17;
                IptvLiveActivity iptvLiveActivity = this.f31952b;
                switch (i112) {
                    case 0:
                        int i122 = IptvLiveActivity.R;
                        iptvLiveActivity.N();
                        break;
                    case 1:
                        int i132 = IptvLiveActivity.R;
                        iptvLiveActivity.getClass();
                        LinkedHashMap linkedHashMapR = w.r(iptvLiveActivity);
                        ArrayList arrayList = new ArrayList(linkedHashMapR.values());
                        new SelectDialogController(iptvLiveActivity, arrayList, Math.max(0, arrayList.indexOf(linkedHashMapR.get(Integer.valueOf(f0.o().p("sp_live_video_ratio", 4))))), new e0(iptvLiveActivity, linkedHashMapR, 22));
                        break;
                    case 2:
                        int i142 = IptvLiveActivity.R;
                        iptvLiveActivity.finish();
                        break;
                    case 3:
                        int i152 = IptvLiveActivity.R;
                        iptvLiveActivity.V();
                        break;
                    case 4:
                        int i162 = IptvLiveActivity.R;
                        iptvLiveActivity.N();
                        break;
                    case 5:
                        int i172 = IptvLiveActivity.R;
                        iptvLiveActivity.V();
                        break;
                    case 6:
                        int i18 = IptvLiveActivity.R;
                        iptvLiveActivity.O(false);
                        break;
                    default:
                        int i19 = IptvLiveActivity.R;
                        iptvLiveActivity.O(true);
                        break;
                }
            }
        });
    }

    @Override // xyz.stream.view.BaseActivity
    public final void initView() {
        getWindow().addFlags(128);
        this.f35293c = a.f34322d;
        this.f35294d = ((k) this.binding).f27118x;
        LiveChannelEntity liveChannelEntity = (LiveChannelEntity) getIntent().getParcelableExtra("channel");
        this.f35295e = liveChannelEntity;
        if (this.f35293c == null || liveChannelEntity == null) {
            finish();
            return;
        }
        this.f35296f = getIntent().getIntExtra("groupId", this.f35295e.getCategoryId() == null ? -100000000 : this.f35295e.getCategoryId().intValue());
        ((k) this.binding).f27097c.initView(this);
        ((k) this.binding).f27097c.setFocusable(true);
        ((k) this.binding).f27097c.setFocusableInTouchMode(true);
        ((k) this.binding).f27097c.requestFocus();
        ((k) this.binding).f27115u.setVisibility(8);
        ((k) this.binding).f27103i.getBtnEpg().setVisibility(8);
        ((k) this.binding).f27103i.getBtnQuality().setVisibility(8);
        ((k) this.binding).f27103i.getBtnAudio().setVisibility(8);
        ((k) this.binding).f27103i.getBtnSubtitle().setVisibility(8);
        ((k) this.binding).f27104j.getBtnEpg().setVisibility(8);
        ((k) this.binding).f27104j.getBtnQuality().setVisibility(8);
        ((k) this.binding).f27104j.getBtnAudio().setVisibility(8);
        ((k) this.binding).f27104j.getBtnSubtitle().setVisibility(8);
        ((k) this.binding).f27104j.getBtnFeedback().setVisibility(8);
        if (e.d().f36119h) {
            ((k) this.binding).f27103i.setVisibility(8);
        } else {
            ((k) this.binding).f27104j.setVisibility(8);
        }
        R();
        S();
        U();
    }

    @Override // androidx.fragment.app.FragmentActivity, androidx.activity.ComponentActivity, android.app.Activity
    public void onActivityResult(int i10, int i11, @Nullable Intent intent) {
        super.onActivityResult(i10, i11, intent);
        if (i10 == 100 && i11 == 100 && intent != null) {
            L((LiveChannelEntity) intent.getParcelableExtra("channel"));
        }
    }

    @Override // tv.danmaku.ijk.media.player.IMediaPlayer.Listener
    public final void onAudioTrackSelect(ITrackInfo iTrackInfo) {
    }

    @Override // tv.danmaku.ijk.media.player.IMediaPlayer.Listener
    public final void onCompletion(IMediaPlayer iMediaPlayer) {
        Q();
    }

    @Override // xyz.stream.view.BaseActivity, androidx.appcompat.app.AppCompatActivity, androidx.fragment.app.FragmentActivity, android.app.Activity
    public final void onDestroy() {
        P();
        a.f34322d = null;
        this.f35292b.removeCallbacksAndMessages(null);
        getWindow().clearFlags(128);
        super.onDestroy();
    }

    @Override // xyz.stream.view.VideoGestureFrameLayout.VideoGestureListener
    public final void onDoubleTapGesture(MotionEvent motionEvent) {
        N();
    }

    @Override // tv.danmaku.ijk.media.player.IMediaPlayer.Listener
    public final boolean onError(IMediaPlayer iMediaPlayer, int i10, int i11, String str) {
        this.f35303m = i10;
        this.Q = i10 + "-" + i11;
        Q();
        return true;
    }

    @Override // tv.danmaku.ijk.media.player.IMediaPlayer.Listener
    public final void onInfo(IMediaPlayer iMediaPlayer, int i10, int i11) {
        if (isFinishing() || isDestroyed()) {
            return;
        }
        if (i10 == 701) {
            if (this.f35302l == i10) {
                return;
            }
            this.f35302l = i10;
            ((k) this.binding).f27113s.setVisibility(0);
            return;
        }
        if (i10 == 702 || i10 == 3 || i10 == 10008) {
            this.f35302l = i10;
            ((k) this.binding).f27113s.setVisibility(8);
        }
    }

    @Override // android.view.View.OnKeyListener
    public final boolean onKey(View view, int i10, KeyEvent keyEvent) {
        if (keyEvent.getAction() != 0) {
            return false;
        }
        if (i10 == 4) {
            if (this.f35298h) {
                M();
                return true;
            }
            finish();
            return true;
        }
        if (i10 == 82) {
            N();
            return true;
        }
        if (i10 == 23 || i10 == 66) {
            N();
            return true;
        }
        if (i10 == 19) {
            O(true);
            return true;
        }
        if (i10 == 20) {
            O(false);
            return true;
        }
        if (!UiUtils.isDpadLeft(i10) && !UiUtils.isDpadRight(i10)) {
            return false;
        }
        S();
        if (!e.d().f36119h) {
            ((k) this.binding).f27103i.post(new h(this, 0));
        }
        return true;
    }

    @Override // androidx.appcompat.app.AppCompatActivity, android.app.Activity, android.view.KeyEvent.Callback
    public final boolean onKeyDown(int i10, KeyEvent keyEvent) {
        if (keyEvent.getAction() == 0 && i10 == 4 && this.f35298h) {
            M();
            return true;
        }
        if (keyEvent.getAction() == 0 && i10 == 82) {
            N();
            return true;
        }
        View currentFocus = getCurrentFocus();
        if ((currentFocus == null || currentFocus == ((k) this.binding).f27097c) && onKey(((k) this.binding).f27097c, i10, keyEvent)) {
            return true;
        }
        return super.onKeyDown(i10, keyEvent);
    }

    @Override // tv.danmaku.ijk.media.player.IMediaPlayer.Listener
    public final void onLog(IMediaPlayer iMediaPlayer, String str) {
    }

    @Override // tv.danmaku.ijk.media.player.IMediaPlayer.Listener
    public final void onPrepared(IMediaPlayer iMediaPlayer) {
        if (isFinishing() || isDestroyed()) {
            return;
        }
        this.f35297g = 0;
        ((k) this.binding).f27113s.setVisibility(8);
        IjkVideoView ijkVideoView = this.f35294d;
        if (ijkVideoView != null) {
            ijkVideoView.setVolume(1.0f, 1.0f);
        }
    }

    @Override // android.app.Activity
    public final void onRestart() {
        super.onRestart();
        if (this.f35295e != null) {
            IjkVideoView ijkVideoView = this.f35294d;
            if (ijkVideoView == null || ijkVideoView.getPlaybackState() == 0) {
                U();
            }
        }
    }

    @Override // xyz.stream.view.VideoGestureFrameLayout.VideoGestureListener
    public final void onSingleTapGesture(MotionEvent motionEvent) {
        if (this.f35298h) {
            M();
        } else {
            S();
        }
    }

    @Override // xyz.stream.view.BaseActivity, androidx.appcompat.app.AppCompatActivity, androidx.fragment.app.FragmentActivity, android.app.Activity
    public final void onStop() {
        super.onStop();
        P();
    }

    @Override // tv.danmaku.ijk.media.player.IMediaPlayer.Listener
    public final void onSubtitleTrackSelect(ITrackInfo iTrackInfo) {
    }

    @Override // tv.danmaku.ijk.media.player.IMediaPlayer.Listener
    public final void onVideoTrackSelect(ITrackInfo iTrackInfo) {
    }
}
