package B0;

import D1.C0093s;
import P2.C0253j;
import android.content.Context;
import android.graphics.SurfaceTexture;
import android.graphics.Typeface;
import android.os.SystemClock;
import android.os.Trace;
import android.telephony.TelephonyManager;
import android.text.TextUtils;
import android.view.Surface;
import android.view.View;
import androidx.lifecycle.C0518x;
import androidx.lifecycle.EnumC0509n;
import androidx.media3.ui.DefaultTimeBar;
import androidx.media3.ui.PlayerView;
import com.google.android.gms.internal.measurement.C1;
import com.google.android.gms.internal.measurement.X1;
import com.martsnew.tv.customviews.CustomNavigationView;
import com.martsnew.tv.ui.episodelist.TvEpisodeListFragment;
import com.martsnew.tv.ui.genres.TvGenresFragment;
import com.martsnew.tv.ui.tvseries.TvSeriesFragment;
import e6.C0891c;
import h0.ComponentCallbacksC1023x;
import java.lang.reflect.Method;
import java.nio.MappedByteBuffer;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.Locale;
import java.util.Map;
import java.util.concurrent.atomic.AtomicMarkableReference;
import java.util.concurrent.atomic.AtomicReference;
import m4.C1169e;
import m4.C1172h;
import m4.RunnableC1180p;
import n.U0;
import n4.u0;
import u5.AbstractC1644q;
import u5.AbstractC1651u;
import v0.AbstractC1664c;
import y5.AbstractActivityC1764i;

/* JADX INFO: renamed from: B0.a, reason: case insensitive filesystem */
/* JADX INFO: loaded from: classes.dex */
public final /* synthetic */ class RunnableC0014a implements Runnable {

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

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

    public /* synthetic */ RunnableC0014a(int i, Object obj) {
        this.f707q = i;
        this.f708r = obj;
    }

    private final void a() {
        I0.h hVar = (I0.h) this.f708r;
        synchronized (hVar.f3212a) {
            try {
                if (hVar.f3223m) {
                    return;
                }
                long j8 = hVar.f3222l - 1;
                hVar.f3222l = j8;
                if (j8 > 0) {
                    return;
                }
                if (j8 < 0) {
                    hVar.b(new IllegalStateException());
                } else {
                    hVar.a();
                }
            } catch (Throwable th) {
                throw th;
            }
        }
    }

    private final void b() {
        c0.n nVar = (c0.n) this.f708r;
        synchronized (nVar.f9314t) {
            try {
                if (nVar.f9318x == null) {
                    return;
                }
                try {
                    J.j jVarD = nVar.d();
                    int i = jVarD.f3439e;
                    if (i == 2) {
                        synchronized (nVar.f9314t) {
                        }
                    }
                    if (i != 0) {
                        throw new RuntimeException("fetchFonts result is not OK. (" + i + ")");
                    }
                    try {
                        Method method = I.g.f3185b;
                        Trace.beginSection("EmojiCompat.FontRequestEmojiCompatConfig.buildTypeface");
                        C0253j c0253j = nVar.f9313s;
                        Context context = nVar.f9311q;
                        c0253j.getClass();
                        J.j[] jVarArr = {jVarD};
                        U2.a aVar = F.e.f2236a;
                        s7.d.e("TypefaceCompat.createFromFontInfo");
                        try {
                            Typeface typefaceI = F.e.f2236a.i(context, jVarArr, 0);
                            Trace.endSection();
                            MappedByteBuffer mappedByteBufferB = W2.g.B(nVar.f9311q, jVarD.f3435a);
                            if (mappedByteBufferB == null || typefaceI == null) {
                                throw new RuntimeException("Unable to open file.");
                            }
                            try {
                                Trace.beginSection("EmojiCompat.MetadataRepo.create");
                                C2.a aVar2 = new C2.a(typefaceI, X1.G(mappedByteBufferB));
                                Trace.endSection();
                                synchronized (nVar.f9314t) {
                                    try {
                                        C1 c12 = nVar.f9318x;
                                        if (c12 != null) {
                                            c12.G(aVar2);
                                        }
                                    } finally {
                                    }
                                }
                                nVar.b();
                            } finally {
                                Method method2 = I.g.f3185b;
                            }
                        } finally {
                            Trace.endSection();
                        }
                    } catch (Throwable th) {
                        throw th;
                    }
                } catch (Throwable th2) {
                    synchronized (nVar.f9314t) {
                        try {
                            C1 c13 = nVar.f9318x;
                            if (c13 != null) {
                                c13.F(th2);
                            }
                            nVar.b();
                        } finally {
                        }
                    }
                }
            } finally {
            }
        }
    }

    private final void c() {
        C0016c c0016c = (C0016c) this.f708r;
        Map mapA = null;
        ((AtomicReference) c0016c.f719s).set(null);
        synchronized (c0016c) {
            try {
                if (((AtomicMarkableReference) c0016c.f718r).isMarked()) {
                    mapA = ((C1169e) ((AtomicMarkableReference) c0016c.f718r).getReference()).a();
                    AtomicMarkableReference atomicMarkableReference = (AtomicMarkableReference) c0016c.f718r;
                    atomicMarkableReference.set((C1169e) atomicMarkableReference.getReference(), false);
                }
            } catch (Throwable th) {
                throw th;
            }
        }
        if (mapA != null) {
            U0 u02 = (U0) c0016c.f720t;
            ((C1172h) u02.f14793a).h((String) u02.f14795c, mapA, c0016c.f717q);
        }
    }

    /* JADX WARN: Removed duplicated region for block: B:36:0x0066 A[Catch: all -> 0x002c, TryCatch #0 {, blocks: (B:8:0x0021, B:10:0x0025, B:17:0x0031, B:21:0x0038, B:27:0x0043, B:29:0x0047, B:31:0x004d, B:33:0x0057, B:35:0x0061, B:37:0x0072, B:36:0x0066, B:38:0x0074, B:40:0x0087, B:42:0x008f), top: B:131:0x0021 }] */
    @Override // java.lang.Runnable
    /*
        Code decompiled incorrectly, please refer to instructions dump.
    */
    public final void run() {
        String strG;
        TelephonyManager telephonyManager;
        int i = 0;
        switch (this.f707q) {
            case u0.f15495q /* 0 */:
                C0016c c0016c = (C0016c) this.f708r;
                ((Context) c0016c.f718r).unregisterReceiver((C0015b) c0016c.f719s);
                return;
            case 1:
                C0015b c0015b = (C0015b) this.f708r;
                if (c0015b.f712c.f717q) {
                    c0015b.f710a.f523q.m0(3, false);
                    return;
                }
                return;
            case 2:
                I i5 = (I) this.f708r;
                i5.getClass();
                int i8 = x0.v.f18553a;
                Integer numValueOf = Integer.valueOf(AbstractC1664c.q(i5.f575u).generateAudioSessionId());
                K2.e eVar = i5.f549V;
                eVar.f3556u = numValueOf;
                ((x0.s) eVar.f3553r).c(new RunnableC1180p(eVar, 4, numValueOf));
                return;
            case 3:
                C0.f fVar = (C0.f) this.f708r;
                fVar.M(fVar.H(), 1028, new C0031s(26));
                fVar.f1104v.d();
                return;
            case 4:
                D0.F f3 = (D0.F) this.f708r;
                if (f3.f1476h0 >= 300000) {
                    ((D0.H) f3.f1486r.f3604r).f1507e1 = true;
                    f3.f1476h0 = 0L;
                    return;
                }
                return;
            case 5:
                int i9 = DefaultTimeBar.f8886i0;
                ((DefaultTimeBar) this.f708r).d(false);
                return;
            case Z.g.STRING_SET_FIELD_NUMBER /* 6 */:
                ((C0093s) this.f708r).o();
                return;
            case Z.g.DOUBLE_FIELD_NUMBER /* 7 */:
                ((PlayerView) this.f708r).invalidate();
                return;
            case Z.g.BYTES_FIELD_NUMBER /* 8 */:
                ((AbstractC1644q) ((TvEpisodeListFragment) this.f708r).f0()).f17786N.requestFocus();
                return;
            case 9:
                ((K4.c) this.f708r).H();
                return;
            case 10:
                F2.k kVar = (F2.k) this.f708r;
                kVar.getClass();
                ((G2.h) kVar.f2482d).n(new A1.G(15, kVar));
                return;
            case 11:
                ((AbstractC1651u) ((TvGenresFragment) this.f708r).f0()).f17806L.requestFocus();
                return;
            case 12:
                a();
                return;
            case 13:
                S0.l lVar = (S0.l) this.f708r;
                Surface surface = lVar.f6267x;
                if (surface != null) {
                    Iterator it = lVar.f6260q.iterator();
                    while (it.hasNext()) {
                        ((F) it.next()).f523q.j0(null);
                    }
                }
                SurfaceTexture surfaceTexture = lVar.f6266w;
                if (surfaceTexture != null) {
                    surfaceTexture.release();
                }
                if (surface != null) {
                    surface.release();
                }
                lVar.f6266w = null;
                lVar.f6267x = null;
                return;
            case 14:
                ((AbstractC1644q) ((S5.g) this.f708r).f0()).f17786N.requestFocus();
                return;
            case 15:
                TvSeriesFragment tvSeriesFragment = (TvSeriesFragment) this.f708r;
                View view = tvSeriesFragment.f11216L1;
                if (view != null) {
                    view.requestFocus();
                }
                tvSeriesFragment.f11216L1 = null;
                return;
            case 16:
                androidx.lifecycle.E e8 = (androidx.lifecycle.E) this.f708r;
                int i10 = e8.f8757r;
                C0518x c0518x = e8.f8761v;
                if (i10 == 0) {
                    e8.f8758s = true;
                    c0518x.H(EnumC0509n.ON_PAUSE);
                }
                if (e8.f8756q == 0 && e8.f8758s) {
                    c0518x.H(EnumC0509n.ON_STOP);
                    e8.f8759t = true;
                    return;
                }
                return;
            case 17:
                b();
                return;
            case 18:
                ((AbstractActivityC1764i) this.f708r).invalidateOptionsMenu();
                return;
            case 19:
                d.l lVar2 = (d.l) this.f708r;
                Runnable runnable = lVar2.f11286r;
                if (runnable != null) {
                    runnable.run();
                    lVar2.f11286r = null;
                    return;
                }
                return;
            case 20:
                d.n.a((d.n) this.f708r);
                return;
            case 21:
                C0891c c0891c = (C0891c) this.f708r;
                P6.g.e(c0891c, "this$0");
                c0891c.f12521a.M0();
                return;
            case 22:
                ComponentCallbacksC1023x componentCallbacksC1023x = (ComponentCallbacksC1023x) this.f708r;
                componentCallbacksC1023x.f13286g0.f13141v.p(componentCallbacksC1023x.f13296t);
                componentCallbacksC1023x.f13296t = null;
                return;
            case 23:
                ArrayList arrayList = ((h0.P) this.f708r).f13079n;
                int size = arrayList.size();
                while (i < size) {
                    Object obj = arrayList.get(i);
                    i++;
                    ((h0.K) obj).getClass();
                }
                return;
            case 24:
                c();
                return;
            case 25:
                CustomNavigationView.setupMenuExpandedUI$lambda$14((CustomNavigationView) this.f708r);
                return;
            default:
                x0.m mVar = (x0.m) this.f708r;
                P0.f fVar2 = (P0.f) mVar.f18527a.get();
                if (fVar2 != null) {
                    int iB = mVar.f18529c.b();
                    P0.g gVar = fVar2.f5269a;
                    synchronized (gVar) {
                        int i11 = gVar.f5289n;
                        if (i11 == 0 || gVar.f5281e) {
                            if (i11 != iB || gVar.f5290o == null) {
                                gVar.f5289n = iB;
                                if (iB != 1 && iB != 0 && iB != 8) {
                                    if (gVar.f5290o == null) {
                                        Context context = gVar.f5277a;
                                        int i12 = x0.v.f18553a;
                                        if (context == null || (telephonyManager = (TelephonyManager) context.getSystemService("phone")) == null) {
                                            strG = s7.d.G(Locale.getDefault().getCountry());
                                            gVar.f5290o = strG;
                                        } else {
                                            String networkCountryIso = telephonyManager.getNetworkCountryIso();
                                            if (!TextUtils.isEmpty(networkCountryIso)) {
                                                strG = s7.d.G(networkCountryIso);
                                            }
                                            gVar.f5290o = strG;
                                        }
                                    }
                                    gVar.f5287l = gVar.a(iB);
                                    gVar.f5280d.getClass();
                                    long jElapsedRealtime = SystemClock.elapsedRealtime();
                                    gVar.b(gVar.f5283g > 0 ? (int) (jElapsedRealtime - gVar.f5284h) : 0, gVar.i, gVar.f5287l);
                                    gVar.f5284h = jElapsedRealtime;
                                    gVar.i = 0L;
                                    gVar.f5286k = 0L;
                                    gVar.f5285j = 0L;
                                    P0.q qVar = gVar.f5282f;
                                    qVar.f5318a.clear();
                                    qVar.f5320c = -1;
                                    qVar.f5321d = 0;
                                    qVar.f5322e = 0;
                                    return;
                                }
                                return;
                            }
                            return;
                        }
                        return;
                    }
                }
                return;
        }
    }
}
