package xyz.netfly.player.playback;

import ag.a;
import ag.g;
import ag.h;
import android.content.Intent;
import android.net.Uri;
import android.os.Handler;
import android.view.KeyEvent;
import android.view.MotionEvent;
import android.view.View;
import android.view.ViewGroup;
import androidx.annotation.Nullable;
import androidx.media3.exoplayer.ExoPlayer;
import com.google.android.gms.common.api.internal.i0;
import com.google.android.material.textfield.b;
import e.y;
import ie.r;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Iterator;
import java.util.LinkedHashMap;
import java.util.Map;
import me.c;
import org.drive_hunter.R;
import org.greenrobot.eventbus.Subscribe;
import org.greenrobot.eventbus.ThreadMode;
import rf.w;
import tv.danmaku.ijk.media.player.IMediaPlayer;
import tv.danmaku.ijk.media.player.MediaSource;
import tv.danmaku.ijk.media.player.ui.CacheManager;
import tv.danmaku.ijk.media.player.ui.IjkPlayerRuntime;
import tv.danmaku.ijk.media.player.ui.IjkVideoView;
import tv.danmaku.ijk.media.player.ui.PreloadManager;
import xyz.netfly.mobile.view.n;
import xyz.stream.api.entity.CmsVideoSource;
import xyz.stream.api.entity.MatchEntity;
import xyz.stream.download.config.InnerConstant;
import xyz.stream.utils.e;
import xyz.stream.utils.event.LogoutEvent;
import xyz.stream.utils.f;
import xyz.stream.utils.f0;
import xyz.stream.utils.j0;
import xyz.stream.view.BaseActivity;
import xyz.stream.view.BaseViewModel;
import xyz.stream.view.SelectDialogController;
import xyz.stream.view.UiUtils;
import xyz.stream.view.VideoGestureFrameLayout;
import xyz.stream.view.autosize.AutoSizeConfig;

/* JADX INFO: loaded from: classes3.dex */
public class PlaybackActivity extends BaseActivity<BaseViewModel, r> implements IMediaPlayer.Listener, View.OnKeyListener, h, a, g, VideoGestureFrameLayout.VideoGestureListener {

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

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

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

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

    /* JADX INFO: renamed from: e, reason: collision with root package name */
    public boolean f35251e = false;

    /* JADX INFO: renamed from: f, reason: collision with root package name */
    public final Handler f35252f = new Handler();

    /* JADX INFO: renamed from: g, reason: collision with root package name */
    public final i0 f35253g = new i0(this, 8);

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

    /* JADX INFO: renamed from: i, reason: collision with root package name */
    public int f35255i = 0;

    /* JADX INFO: renamed from: j, reason: collision with root package name */
    public long f35256j = 0;

    @Override // ag.a
    public final void A() {
        K();
    }

    public final void K() {
        try {
            this.f35249c.addListener(null);
            IjkVideoView ijkVideoView = this.f35249c;
            if (ijkVideoView != null) {
                ijkVideoView.removeListener();
            }
            if (((r) this.binding).f27411g.isAttachedToWindow() && ((r) this.binding).f27411g.getChildCount() > 0) {
                ((r) this.binding).f27411g.removeAllViews();
            }
            this.f35248b.f30660c = null;
            L();
            f.p().x("destroyPlayer: videoPlayId: " + this.f35250d);
        } catch (Exception e10) {
            xyz.stream.utils.h.c(e10.getMessage());
        }
    }

    public final void L() {
        IjkVideoView ijkVideoView = this.f35249c;
        if (ijkVideoView != null) {
            ijkVideoView.stop();
            this.f35249c.release();
        }
    }

    public final void M() {
        if (isFinishing() || isDestroyed()) {
            return;
        }
        this.f35251e = false;
        ((r) this.binding).f27409e.setVisibility(0);
        ((r) this.binding).f27410f.setVisibility(8);
        ((r) this.binding).f27407c.getBottomLayout().setVisibility(8);
        ((r) this.binding).f27406b.requestFocus();
        ((r) this.binding).f27406b.setFocusable(true);
        ((r) this.binding).f27406b.setFocusableInTouchMode(true);
        this.f35249c.setPlayer(4);
        this.f35249c.decode(1);
        this.f35249c.setResizeMode(f0.o().p(IjkPlayerRuntime.SP_VOD_VIDEO_RATIO, 0));
        this.f35249c.setMediaSourceLive(new MediaSource(new HashMap(), Uri.parse(this.f35250d.replace("http://", "https://"))));
        N();
    }

    public final void N() {
        IjkVideoView ijkVideoView = this.f35249c;
        if (ijkVideoView == null) {
            ((r) this.binding).f27406b.setSeekGestureState(0L, 0L, false);
        } else {
            long duration = ijkVideoView.getDuration();
            ((r) this.binding).f27406b.setSeekGestureState(this.f35249c.getCurrentPosition(), duration, duration > 0 && this.f35249c.getPlaybackState() > 2);
        }
    }

    @Override // ag.h
    public void OnBtnAudioClickListener(View view) {
        c cVar = this.f35248b;
        cVar.f30659b.removeCallbacks(cVar.f30668k);
    }

    @Override // ag.h
    public void OnBtnSubtitleClickListener(View view) {
        c cVar = this.f35248b;
        cVar.f30659b.removeCallbacks(cVar.f30668k);
    }

    @Override // ag.a
    public final void e() {
        L();
        M();
    }

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

    @Override // ag.h
    public final void h(String str) {
        this.f35250d = str;
        runOnUiThread(new me.a(this, 0));
    }

    @Override // ag.h
    public final void i(int i10) {
        if (i10 == PreloadManager.getInstance().hardwareDecode) {
            return;
        }
        PreloadManager.getInstance().hardwareDecode = i10;
        L();
        runOnUiThread(new me.a(this, 4));
    }

    @Override // xyz.stream.view.BaseActivity
    public final void initData() {
        this.f35248b = new c();
        MatchEntity matchEntity = (MatchEntity) getIntent().getParcelableExtra("matchBean");
        final int i10 = 0;
        int intExtra = getIntent().getIntExtra(InnerConstant.Db.f36069id, 0);
        final c cVar = this.f35248b;
        r rVar = (r) this.binding;
        IjkVideoView ijkVideoView = this.f35249c;
        cVar.getClass();
        cVar.f30658a = rVar.f27407c;
        cVar.f30660c = this;
        ArrayList arrayList = cVar.f30666i;
        arrayList.clear();
        cVar.f30658a.setVideoView(ijkVideoView);
        cVar.f30658a.setControllerListener(cVar);
        cVar.f30661d = ijkVideoView;
        cVar.f30662e = rVar.f27410f;
        final int i11 = 1;
        if (matchEntity != null && matchEntity.getPlaybackList() != null && !matchEntity.getPlaybackList().isEmpty()) {
            for (MatchEntity.PlaybackListEntity playbackListEntity : matchEntity.getPlaybackList()) {
                arrayList.add(new CmsVideoSource(playbackListEntity.getId(), playbackListEntity.getPlaybackUrl(), playbackListEntity.getChannelName(), playbackListEntity.getChannelName(), 0, 0));
            }
            cVar.f30658a.getBtnSource().setVisibility(arrayList.size() > 1 ? 0 : 8);
            if (!arrayList.isEmpty()) {
                int i12 = 0;
                while (true) {
                    if (i12 >= arrayList.size()) {
                        break;
                    }
                    if (((CmsVideoSource) arrayList.get(i12)).getVideoId() != null && ((CmsVideoSource) arrayList.get(i12)).getVideoId().intValue() == intExtra) {
                        cVar.f30665h = i12;
                        break;
                    }
                    i12++;
                }
                int i13 = cVar.f30665h;
                if (i13 < 0 || i13 >= arrayList.size()) {
                    cVar.f30665h = 0;
                }
                h(((CmsVideoSource) arrayList.get(cVar.f30665h)).getVideoSource());
                cVar.f30658a.getBtnSource().setText(((CmsVideoSource) arrayList.get(cVar.f30665h)).getSourceName());
            }
        }
        if (e.d().f36119h || e.d().f36121j) {
            cVar.f30658a.getIvBack().setVisibility(0);
        }
        cVar.f30662e.setOnClickListener(new View.OnClickListener() { // from class: me.b
            @Override // android.view.View.OnClickListener
            public final void onClick(View view) {
                int i14 = i10;
                c cVar2 = cVar;
                switch (i14) {
                    case 0:
                        cVar2.getClass();
                        kotlinx.coroutines.flow.h.d(view);
                        cVar2.e();
                        break;
                    case 1:
                        cVar2.getClass();
                        kotlinx.coroutines.flow.h.d(view);
                        cVar2.e();
                        break;
                    case 2:
                        cVar2.getClass();
                        kotlinx.coroutines.flow.h.d(view);
                        cVar2.a();
                        new SelectDialogController(cVar2.f30660c, t4.f.x(cVar2.f30666i).m(new com.google.gson.internal.a(cVar2, 14)).E(), cVar2.f30665h, new y(cVar2));
                        break;
                    case 3:
                        cVar2.getClass();
                        kotlinx.coroutines.flow.h.d(view);
                        cVar2.a();
                        new SelectDialogController(cVar2.f30660c, cVar2.f30663f, cVar2.f30664g, new nb.c(cVar2, 29));
                        break;
                    case 4:
                        cVar2.getClass();
                        kotlinx.coroutines.flow.h.d(view);
                        cVar2.a();
                        LinkedHashMap linkedHashMapR = w.r(cVar2.f30660c);
                        ArrayList arrayList2 = new ArrayList();
                        Iterator it = linkedHashMapR.entrySet().iterator();
                        while (it.hasNext()) {
                            arrayList2.add((String) ((Map.Entry) it.next()).getValue());
                        }
                        new SelectDialogController(cVar2.f30660c, arrayList2, arrayList2.indexOf(linkedHashMapR.get(Integer.valueOf(f0.o().p(IjkPlayerRuntime.SP_VOD_VIDEO_RATIO, 0)))), new xyz.stream.utils.f(cVar2, linkedHashMapR, 22));
                        break;
                    default:
                        cVar2.getClass();
                        kotlinx.coroutines.flow.h.d(view);
                        cVar2.a();
                        uf.r.h(cVar2.f30660c);
                        break;
                }
            }
        });
        cVar.f30658a.getBtnPlay().setOnClickListener(new View.OnClickListener() { // from class: me.b
            @Override // android.view.View.OnClickListener
            public final void onClick(View view) {
                int i14 = i11;
                c cVar2 = cVar;
                switch (i14) {
                    case 0:
                        cVar2.getClass();
                        kotlinx.coroutines.flow.h.d(view);
                        cVar2.e();
                        break;
                    case 1:
                        cVar2.getClass();
                        kotlinx.coroutines.flow.h.d(view);
                        cVar2.e();
                        break;
                    case 2:
                        cVar2.getClass();
                        kotlinx.coroutines.flow.h.d(view);
                        cVar2.a();
                        new SelectDialogController(cVar2.f30660c, t4.f.x(cVar2.f30666i).m(new com.google.gson.internal.a(cVar2, 14)).E(), cVar2.f30665h, new y(cVar2));
                        break;
                    case 3:
                        cVar2.getClass();
                        kotlinx.coroutines.flow.h.d(view);
                        cVar2.a();
                        new SelectDialogController(cVar2.f30660c, cVar2.f30663f, cVar2.f30664g, new nb.c(cVar2, 29));
                        break;
                    case 4:
                        cVar2.getClass();
                        kotlinx.coroutines.flow.h.d(view);
                        cVar2.a();
                        LinkedHashMap linkedHashMapR = w.r(cVar2.f30660c);
                        ArrayList arrayList2 = new ArrayList();
                        Iterator it = linkedHashMapR.entrySet().iterator();
                        while (it.hasNext()) {
                            arrayList2.add((String) ((Map.Entry) it.next()).getValue());
                        }
                        new SelectDialogController(cVar2.f30660c, arrayList2, arrayList2.indexOf(linkedHashMapR.get(Integer.valueOf(f0.o().p(IjkPlayerRuntime.SP_VOD_VIDEO_RATIO, 0)))), new xyz.stream.utils.f(cVar2, linkedHashMapR, 22));
                        break;
                    default:
                        cVar2.getClass();
                        kotlinx.coroutines.flow.h.d(view);
                        cVar2.a();
                        uf.r.h(cVar2.f30660c);
                        break;
                }
            }
        });
        final int i14 = 2;
        cVar.f30658a.getBtnSource().setOnClickListener(new View.OnClickListener() { // from class: me.b
            @Override // android.view.View.OnClickListener
            public final void onClick(View view) {
                int i142 = i14;
                c cVar2 = cVar;
                switch (i142) {
                    case 0:
                        cVar2.getClass();
                        kotlinx.coroutines.flow.h.d(view);
                        cVar2.e();
                        break;
                    case 1:
                        cVar2.getClass();
                        kotlinx.coroutines.flow.h.d(view);
                        cVar2.e();
                        break;
                    case 2:
                        cVar2.getClass();
                        kotlinx.coroutines.flow.h.d(view);
                        cVar2.a();
                        new SelectDialogController(cVar2.f30660c, t4.f.x(cVar2.f30666i).m(new com.google.gson.internal.a(cVar2, 14)).E(), cVar2.f30665h, new y(cVar2));
                        break;
                    case 3:
                        cVar2.getClass();
                        kotlinx.coroutines.flow.h.d(view);
                        cVar2.a();
                        new SelectDialogController(cVar2.f30660c, cVar2.f30663f, cVar2.f30664g, new nb.c(cVar2, 29));
                        break;
                    case 4:
                        cVar2.getClass();
                        kotlinx.coroutines.flow.h.d(view);
                        cVar2.a();
                        LinkedHashMap linkedHashMapR = w.r(cVar2.f30660c);
                        ArrayList arrayList2 = new ArrayList();
                        Iterator it = linkedHashMapR.entrySet().iterator();
                        while (it.hasNext()) {
                            arrayList2.add((String) ((Map.Entry) it.next()).getValue());
                        }
                        new SelectDialogController(cVar2.f30660c, arrayList2, arrayList2.indexOf(linkedHashMapR.get(Integer.valueOf(f0.o().p(IjkPlayerRuntime.SP_VOD_VIDEO_RATIO, 0)))), new xyz.stream.utils.f(cVar2, linkedHashMapR, 22));
                        break;
                    default:
                        cVar2.getClass();
                        kotlinx.coroutines.flow.h.d(view);
                        cVar2.a();
                        uf.r.h(cVar2.f30660c);
                        break;
                }
            }
        });
        final int i15 = 3;
        cVar.f30658a.getBtnSpeed().setOnClickListener(new View.OnClickListener() { // from class: me.b
            @Override // android.view.View.OnClickListener
            public final void onClick(View view) {
                int i142 = i15;
                c cVar2 = cVar;
                switch (i142) {
                    case 0:
                        cVar2.getClass();
                        kotlinx.coroutines.flow.h.d(view);
                        cVar2.e();
                        break;
                    case 1:
                        cVar2.getClass();
                        kotlinx.coroutines.flow.h.d(view);
                        cVar2.e();
                        break;
                    case 2:
                        cVar2.getClass();
                        kotlinx.coroutines.flow.h.d(view);
                        cVar2.a();
                        new SelectDialogController(cVar2.f30660c, t4.f.x(cVar2.f30666i).m(new com.google.gson.internal.a(cVar2, 14)).E(), cVar2.f30665h, new y(cVar2));
                        break;
                    case 3:
                        cVar2.getClass();
                        kotlinx.coroutines.flow.h.d(view);
                        cVar2.a();
                        new SelectDialogController(cVar2.f30660c, cVar2.f30663f, cVar2.f30664g, new nb.c(cVar2, 29));
                        break;
                    case 4:
                        cVar2.getClass();
                        kotlinx.coroutines.flow.h.d(view);
                        cVar2.a();
                        LinkedHashMap linkedHashMapR = w.r(cVar2.f30660c);
                        ArrayList arrayList2 = new ArrayList();
                        Iterator it = linkedHashMapR.entrySet().iterator();
                        while (it.hasNext()) {
                            arrayList2.add((String) ((Map.Entry) it.next()).getValue());
                        }
                        new SelectDialogController(cVar2.f30660c, arrayList2, arrayList2.indexOf(linkedHashMapR.get(Integer.valueOf(f0.o().p(IjkPlayerRuntime.SP_VOD_VIDEO_RATIO, 0)))), new xyz.stream.utils.f(cVar2, linkedHashMapR, 22));
                        break;
                    default:
                        cVar2.getClass();
                        kotlinx.coroutines.flow.h.d(view);
                        cVar2.a();
                        uf.r.h(cVar2.f30660c);
                        break;
                }
            }
        });
        final int i16 = 4;
        cVar.f30658a.getBtnRatio().setOnClickListener(new View.OnClickListener() { // from class: me.b
            @Override // android.view.View.OnClickListener
            public final void onClick(View view) {
                int i142 = i16;
                c cVar2 = cVar;
                switch (i142) {
                    case 0:
                        cVar2.getClass();
                        kotlinx.coroutines.flow.h.d(view);
                        cVar2.e();
                        break;
                    case 1:
                        cVar2.getClass();
                        kotlinx.coroutines.flow.h.d(view);
                        cVar2.e();
                        break;
                    case 2:
                        cVar2.getClass();
                        kotlinx.coroutines.flow.h.d(view);
                        cVar2.a();
                        new SelectDialogController(cVar2.f30660c, t4.f.x(cVar2.f30666i).m(new com.google.gson.internal.a(cVar2, 14)).E(), cVar2.f30665h, new y(cVar2));
                        break;
                    case 3:
                        cVar2.getClass();
                        kotlinx.coroutines.flow.h.d(view);
                        cVar2.a();
                        new SelectDialogController(cVar2.f30660c, cVar2.f30663f, cVar2.f30664g, new nb.c(cVar2, 29));
                        break;
                    case 4:
                        cVar2.getClass();
                        kotlinx.coroutines.flow.h.d(view);
                        cVar2.a();
                        LinkedHashMap linkedHashMapR = w.r(cVar2.f30660c);
                        ArrayList arrayList2 = new ArrayList();
                        Iterator it = linkedHashMapR.entrySet().iterator();
                        while (it.hasNext()) {
                            arrayList2.add((String) ((Map.Entry) it.next()).getValue());
                        }
                        new SelectDialogController(cVar2.f30660c, arrayList2, arrayList2.indexOf(linkedHashMapR.get(Integer.valueOf(f0.o().p(IjkPlayerRuntime.SP_VOD_VIDEO_RATIO, 0)))), new xyz.stream.utils.f(cVar2, linkedHashMapR, 22));
                        break;
                    default:
                        cVar2.getClass();
                        kotlinx.coroutines.flow.h.d(view);
                        cVar2.a();
                        uf.r.h(cVar2.f30660c);
                        break;
                }
            }
        });
        final int i17 = 5;
        cVar.f30658a.getBtnFeedback().setOnClickListener(new View.OnClickListener() { // from class: me.b
            @Override // android.view.View.OnClickListener
            public final void onClick(View view) {
                int i142 = i17;
                c cVar2 = cVar;
                switch (i142) {
                    case 0:
                        cVar2.getClass();
                        kotlinx.coroutines.flow.h.d(view);
                        cVar2.e();
                        break;
                    case 1:
                        cVar2.getClass();
                        kotlinx.coroutines.flow.h.d(view);
                        cVar2.e();
                        break;
                    case 2:
                        cVar2.getClass();
                        kotlinx.coroutines.flow.h.d(view);
                        cVar2.a();
                        new SelectDialogController(cVar2.f30660c, t4.f.x(cVar2.f30666i).m(new com.google.gson.internal.a(cVar2, 14)).E(), cVar2.f30665h, new y(cVar2));
                        break;
                    case 3:
                        cVar2.getClass();
                        kotlinx.coroutines.flow.h.d(view);
                        cVar2.a();
                        new SelectDialogController(cVar2.f30660c, cVar2.f30663f, cVar2.f30664g, new nb.c(cVar2, 29));
                        break;
                    case 4:
                        cVar2.getClass();
                        kotlinx.coroutines.flow.h.d(view);
                        cVar2.a();
                        LinkedHashMap linkedHashMapR = w.r(cVar2.f30660c);
                        ArrayList arrayList2 = new ArrayList();
                        Iterator it = linkedHashMapR.entrySet().iterator();
                        while (it.hasNext()) {
                            arrayList2.add((String) ((Map.Entry) it.next()).getValue());
                        }
                        new SelectDialogController(cVar2.f30660c, arrayList2, arrayList2.indexOf(linkedHashMapR.get(Integer.valueOf(f0.o().p(IjkPlayerRuntime.SP_VOD_VIDEO_RATIO, 0)))), new xyz.stream.utils.f(cVar2, linkedHashMapR, 22));
                        break;
                    default:
                        cVar2.getClass();
                        kotlinx.coroutines.flow.h.d(view);
                        cVar2.a();
                        uf.r.h(cVar2.f30660c);
                        break;
                }
            }
        });
        cVar.f30658a.setSeekListener(new j0(cVar, 28));
    }

    @Override // xyz.stream.view.BaseActivity
    public final void initListener() {
        this.f35249c.addListener(this);
        ((r) this.binding).f27406b.setOnKeyListener(this);
        ((r) this.binding).f27406b.setVideoGestureListener(this);
        this.f35248b.f30667j = this;
        ((r) this.binding).f27407c.getIvBack().setOnClickListener(new b(this, 7));
    }

    @Override // xyz.stream.view.BaseActivity
    public final void initView() {
        getWindow().addFlags(128);
        ((r) this.binding).f27406b.post(new me.a(this, 1));
        ((r) this.binding).f27410f.setImageResource(R.mipmap.play);
        IjkVideoView ijkVideoView = new IjkVideoView(this);
        this.f35249c = ijkVideoView;
        if (ijkVideoView.getParent() != null) {
            ((ViewGroup) this.f35249c.getParent()).removeView(this.f35249c);
        }
        ((r) this.binding).f27411g.addView(this.f35249c);
        ((r) this.binding).f27406b.initView(this);
        N();
    }

    @Override // ag.h
    public final void j(int i10, int i11, String str) {
    }

    @Override // ag.g
    public final void n(String str) {
        L();
        this.f35250d = str;
        M();
    }

    @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) {
            this.f35248b.c();
        }
    }

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

    @Override // xyz.stream.view.BaseActivity, androidx.appcompat.app.AppCompatActivity, androidx.fragment.app.FragmentActivity, android.app.Activity
    public final void onDestroy() {
        super.onDestroy();
        K();
        j0.k().p(this);
        getWindow().clearFlags(128);
    }

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

    @Override // tv.danmaku.ijk.media.player.IMediaPlayer.Listener
    public final boolean onError(IMediaPlayer iMediaPlayer, int i10, int i11, String str) {
        synchronized (this) {
            int i12 = 1;
            try {
                if (i11 == -666) {
                    xyz.stream.utils.h.c("Hardware decode error, switching to software decode");
                    PreloadManager.getInstance().hardwareDecode = 0;
                    L();
                    runOnUiThread(new me.a(this, 2));
                    return true;
                }
                CacheManager.getInstance().deleteCacheFile(this.f35250d);
                if (this.f35251e) {
                    return true;
                }
                this.f35251e = true;
                f.p().x("play error: " + i10 + " extra: " + i11 + " url: " + this.f35250d);
                runOnUiThread(new n(this, this, i12));
                return true;
            } catch (Throwable th) {
                throw th;
            }
        }
    }

    @Override // tv.danmaku.ijk.media.player.IMediaPlayer.Listener
    public final void onInfo(IMediaPlayer iMediaPlayer, int i10, int i11) {
        Handler handler = this.f35252f;
        i0 i0Var = this.f35253g;
        if (i10 == 701) {
            handler.postDelayed(i0Var, 200L);
        } else if (i10 == 702 || i10 == 10008) {
            handler.removeCallbacks(i0Var);
            ((r) this.binding).f27409e.setVisibility(8);
            if (this.f35254h != 702) {
                this.f35254h = IMediaPlayer.MEDIA_INFO_BUFFERING_END;
            }
        }
        N();
    }

    @Override // xyz.stream.view.BaseActivity
    public final void onInit() {
        super.onInit();
        if (e.d().f36121j) {
            AutoSizeConfig.getInstance().setDesignWidthInDp(1920).setDesignHeightInDp(1080);
            requestWindowFeature(1);
            kotlinx.coroutines.y.S("MobilePlaybackActivity");
            UiUtils.setUpActivity(this, null);
        }
    }

    @Override // android.view.View.OnKeyListener
    public final boolean onKey(View view, int i10, KeyEvent keyEvent) {
        if (i10 == 21 || i10 == 22) {
            if (this.f35249c.getDuration() > 0 && keyEvent.getAction() == 0) {
                c cVar = this.f35248b;
                cVar.c();
                cVar.f30658a.setVisibility(0);
                cVar.f30658a.getTimeBar().requestFocus();
            }
            return true;
        }
        if ((i10 == 23 || i10 == 66) && keyEvent.getAction() == 0) {
            if (((r) this.binding).f27407c.getVisibility() != 0) {
                this.f35248b.d();
            }
            return true;
        }
        if (i10 == 4 || keyEvent.getAction() != 0 || ((r) this.binding).f27407c.getVisibility() == 0) {
            return false;
        }
        c cVar2 = this.f35248b;
        if (cVar2.f30658a.getVisibility() == 0) {
            cVar2.a();
        } else if (cVar2.f30661d.getPlaybackState() > 0) {
            cVar2.d();
        }
        return true;
    }

    @Override // androidx.appcompat.app.AppCompatActivity, android.app.Activity, android.view.KeyEvent.Callback
    public final boolean onKeyDown(int i10, KeyEvent keyEvent) {
        if (i10 != 4 || keyEvent.getAction() != 0) {
            return super.onKeyDown(i10, keyEvent);
        }
        if (((r) this.binding).f27407c.getVisibility() == 0) {
            this.f35248b.a();
            return true;
        }
        if (e.d().f36119h) {
            K();
            finish();
            return true;
        }
        long jCurrentTimeMillis = System.currentTimeMillis();
        if (jCurrentTimeMillis - this.f35256j > ExoPlayer.DEFAULT_DETACH_SURFACE_TIMEOUT_MS) {
            this.f35255i = 1;
        } else {
            this.f35255i++;
        }
        this.f35256j = jCurrentTimeMillis;
        int i11 = this.f35255i;
        if (i11 > 1) {
            K();
            finish();
            return true;
        }
        if (i11 == 1) {
            ((r) this.binding).f27408d.f27504a.setVisibility(0);
            ((r) this.binding).f27408d.f27504a.postDelayed(new me.a(this, 3), ExoPlayer.DEFAULT_DETACH_SURFACE_TIMEOUT_MS);
        }
        return true;
    }

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

    @Subscribe(sticky = true, threadMode = ThreadMode.MAIN)
    public void onMessageEvent(LogoutEvent logoutEvent) {
        this.f35248b.b();
        uf.r.j(this, new com.google.gson.internal.a(this, 13));
    }

    @Override // androidx.fragment.app.FragmentActivity, android.app.Activity
    public final void onPause() {
        super.onPause();
    }

    @Override // tv.danmaku.ijk.media.player.IMediaPlayer.Listener
    public final void onPrepared(IMediaPlayer iMediaPlayer) {
        f.p().x("onPrepared");
        ((r) this.binding).f27409e.setVisibility(8);
        PlaybackSeekControl playbackSeekControl = this.f35248b.f30658a;
        playbackSeekControl.removeCallbacks(playbackSeekControl.f35258a);
        playbackSeekControl.post(playbackSeekControl.f35258a);
        this.f35248b.f30658a.setPlayButtonIcon(true);
        ((r) this.binding).f27410f.setImageResource(R.mipmap.pause);
        ((r) this.binding).f27407c.getBottomLayout().setVisibility(0);
        N();
    }

    @Override // android.app.Activity
    public final void onRestart() {
        super.onRestart();
        if (this.f35249c.getPlaybackState() != 4 || this.f35248b == null) {
            return;
        }
        IjkVideoView ijkVideoView = this.f35249c;
        ijkVideoView.start(Math.max(ijkVideoView.getCurrentPosition(), 0));
        ((r) this.binding).f27410f.setImageResource(R.mipmap.pause);
        this.f35248b.f30658a.setPlayButtonIcon(true);
        ((r) this.binding).f27410f.setVisibility(8);
        this.f35248b.c();
    }

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

    @Override // xyz.stream.view.VideoGestureFrameLayout.VideoGestureListener
    public final void onSeekGestureCommit(long j10) {
        IjkVideoView ijkVideoView = this.f35249c;
        if (ijkVideoView == null || ijkVideoView.getDuration() <= 0 || this.f35249c.getPlaybackState() <= 2) {
            return;
        }
        this.f35249c.seekTo(j10);
    }

    @Override // xyz.stream.view.VideoGestureFrameLayout.VideoGestureListener
    public final void onSingleTapGesture(MotionEvent motionEvent) {
        c cVar = this.f35248b;
        if (cVar.f30658a.getVisibility() == 0) {
            cVar.a();
        } else if (cVar.f30661d.getPlaybackState() > 0) {
            cVar.d();
        }
    }

    @Override // xyz.stream.view.BaseActivity, androidx.appcompat.app.AppCompatActivity, androidx.fragment.app.FragmentActivity, android.app.Activity
    public final void onStop() {
        super.onStop();
        if (isFinishing() || isDestroyed()) {
            return;
        }
        this.f35248b.b();
    }
}
