package xyz.netfly.mobile.plugin;

import android.os.Handler;
import androidx.media3.exoplayer.hls.playlist.HlsMediaPlaylist;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Locale;
import java.util.TimeZone;
import java.util.TimerTask;
import tv.danmaku.ijk.media.player.ui.IjkVideoView;
import tv.danmaku.ijk.media.player.ui.abr.AbrController;
import xyz.netfly.ui.live.epg.z;
import xyz.stream.api.q;
import xyz.stream.utils.entity.MatchReminderEntity;
import xyz.stream.utils.event.MatchReminderEvent;
import xyz.stream.utils.f0;
import xyz.stream.utils.t;

/* JADX INFO: loaded from: classes3.dex */
public final class l extends TimerTask {

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

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

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

    public /* synthetic */ l(Object obj, int i10) {
        this.f35078a = i10;
        this.f35079b = obj;
    }

    public final /* synthetic */ void a() {
        int i10 = this.f35078a;
        Object obj = this.f35079b;
        switch (i10) {
            case 0:
                HashMap map = new HashMap();
                map.put("tcpSpeed", kotlinx.coroutines.flow.h.x());
                m mVar = (m) obj;
                if (mVar.T != null) {
                    map.put("currentBitrate", mVar.T.getWidth() + "x" + mVar.T.getHeight() + " (" + mVar.T.getBitrate() + ")");
                    map.put("bufferDuration", String.valueOf(mVar.f35086d.getBufferedPosition() - ((long) mVar.f35086d.getCurrentPosition())));
                    map.put("bitrateEstimate", String.valueOf(mVar.f35099j0));
                    map.put("downloadingBitrate", AbrController.getInstance().getsGlobalSelectBitrateStr());
                }
                ed.j jVar = mVar.f35088e;
                if (jVar != null) {
                    jVar.a(map);
                }
                break;
            default:
                ((z) obj).f35419d.f27802c.o();
                break;
        }
    }

    @Override // java.util.TimerTask, java.lang.Runnable
    public final void run() {
        int i10 = this.f35078a;
        final int i11 = 0;
        Object obj = this.f35079b;
        switch (i10) {
            case 0:
                m mVar = (m) obj;
                final int i12 = 1;
                int i13 = mVar.f35108p0 + 1;
                mVar.f35108p0 = i13;
                if (i13 >= 300) {
                    mVar.f35108p0 = 0;
                    xyz.stream.utils.l.f36161a.execute(new xyz.stream.utils.j(mVar.f35098j, mVar.f35100k.intValue(), mVar.f35102l, 1));
                }
                IjkVideoView ijkVideoView = mVar.f35086d;
                Handler handler = mVar.f35091f0;
                if (ijkVideoView != null) {
                    handler.post(new Runnable(this) { // from class: xyz.netfly.mobile.plugin.k

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

                        {
                            this.f35076b = this;
                        }

                        @Override // java.lang.Runnable
                        public final void run() {
                            int i14 = i11;
                            l lVar = this.f35076b;
                            switch (i14) {
                                case 0:
                                    lVar.a();
                                    break;
                                default:
                                    m mVar2 = (m) lVar.f35079b;
                                    IjkVideoView ijkVideoView2 = mVar2.f35086d;
                                    if (ijkVideoView2 != null && ijkVideoView2.isPlaying()) {
                                        HashMap map = new HashMap();
                                        map.put("buffer_time", Long.valueOf(mVar2.f35086d.getBufferedPosition()));
                                        map.put("current_time", Integer.valueOf(mVar2.f35086d.getCurrentPosition()));
                                        q.g().o(mVar2.W, xyz.stream.utils.m.a(map), HlsMediaPlaylist.Interstitial.CUE_TRIGGER_POST);
                                        break;
                                    }
                                    break;
                            }
                        }
                    });
                }
                handler.post(new Runnable(this) { // from class: xyz.netfly.mobile.plugin.k

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

                    {
                        this.f35076b = this;
                    }

                    @Override // java.lang.Runnable
                    public final void run() {
                        int i14 = i12;
                        l lVar = this.f35076b;
                        switch (i14) {
                            case 0:
                                lVar.a();
                                break;
                            default:
                                m mVar2 = (m) lVar.f35079b;
                                IjkVideoView ijkVideoView2 = mVar2.f35086d;
                                if (ijkVideoView2 != null && ijkVideoView2.isPlaying()) {
                                    HashMap map = new HashMap();
                                    map.put("buffer_time", Long.valueOf(mVar2.f35086d.getBufferedPosition()));
                                    map.put("current_time", Integer.valueOf(mVar2.f35086d.getCurrentPosition()));
                                    q.g().o(mVar2.W, xyz.stream.utils.m.a(map), HlsMediaPlaylist.Interstitial.CUE_TRIGGER_POST);
                                    break;
                                }
                                break;
                        }
                    }
                });
                break;
            case 1:
                ((z) obj).f35418c.runOnUiThread(new xyz.netfly.ads.h(this, 14));
                break;
            default:
                t tVar = (t) obj;
                List list = (List) tVar.f36173c;
                if (list != null && !list.isEmpty()) {
                    long jCurrentTimeMillis = System.currentTimeMillis();
                    MatchReminderEntity matchReminderEntity = (MatchReminderEntity) ((List) tVar.f36173c).get(0);
                    long jW = kotlinx.coroutines.flow.h.w(matchReminderEntity.getTime(), "yyyy-MM-dd HH:mm:ss");
                    if (jW > 0) {
                        StringBuilder sb = new StringBuilder("check remend match time: ");
                        sb.append(matchReminderEntity.getTime());
                        sb.append(", currentTimeMillis: ");
                        Date date = new Date(jCurrentTimeMillis);
                        SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss", Locale.US);
                        simpleDateFormat.setTimeZone(TimeZone.getDefault());
                        sb.append(simpleDateFormat.format(date));
                        xyz.stream.utils.h.b(sb.toString());
                        if (jCurrentTimeMillis < jW - 300000) {
                            matchReminderEntity = null;
                        }
                        if (matchReminderEntity == null) {
                            tVar.w();
                        } else {
                            ((List) tVar.f36173c).remove(matchReminderEntity);
                            f0.o().C("sp_match_reminder_list", (List) tVar.f36173c);
                            fe.d.b().e(new MatchReminderEvent(matchReminderEntity));
                            if (!((List) tVar.f36173c).isEmpty()) {
                                tVar.w();
                            } else {
                                tVar.l();
                            }
                        }
                    } else {
                        ((List) tVar.f36173c).remove(matchReminderEntity);
                        f0.o().C("sp_match_reminder_list", (List) tVar.f36173c);
                        if (!((List) tVar.f36173c).isEmpty()) {
                            tVar.w();
                        } else {
                            tVar.l();
                        }
                    }
                    break;
                }
                break;
        }
    }
}
