package te;

import android.app.Activity;
import android.os.Handler;
import android.os.Looper;
import androidx.emoji2.text.v;
import androidx.media3.exoplayer.hls.playlist.HlsMediaPlaylist;
import com.google.android.gms.internal.ads.p80;
import java.util.HashMap;
import java.util.concurrent.CountDownLatch;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.AtomicReference;
import xyz.stream.api.q;

/* JADX INFO: loaded from: classes3.dex */
public final /* synthetic */ class g implements Runnable {

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

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

    public /* synthetic */ g(p80 p80Var, int i10) {
        this.f33053a = i10;
        this.f33054b = p80Var;
    }

    @Override // java.lang.Runnable
    public final void run() {
        int i10 = this.f33053a;
        p80 p80Var = this.f33054b;
        switch (i10) {
            case 0:
                if (((ag.c) p80Var.f15297e) != null) {
                    ((Handler) p80Var.f15300h).post(new g(p80Var, 4));
                    break;
                }
                break;
            case 1:
                Activity activity = (Activity) p80Var.f15295c;
                if (activity != null && !activity.isFinishing() && !activity.isDestroyed() && ((ag.c) p80Var.f15297e) != null) {
                    ((Handler) p80Var.f15300h).post(new com.tekartik.sqflite.g(p80Var, kotlinx.coroutines.flow.h.x(), 29));
                    break;
                }
                break;
            case 2:
                Activity activity2 = (Activity) p80Var.f15295c;
                if (activity2 != null && !activity2.isFinishing() && !activity2.isDestroyed()) {
                    boolean zIsFinishing = activity2.isFinishing();
                    Object obj = p80Var.f15300h;
                    h hVarA = null;
                    if (!zIsFinishing && !activity2.isDestroyed()) {
                        if (Looper.myLooper() == Looper.getMainLooper()) {
                            hVarA = p80Var.a();
                        } else {
                            CountDownLatch countDownLatch = new CountDownLatch(1);
                            AtomicReference atomicReference = new AtomicReference();
                            ((Handler) obj).post(new v(p80Var, atomicReference, countDownLatch, 19));
                            try {
                                if (countDownLatch.await(500L, TimeUnit.MILLISECONDS)) {
                                    hVarA = (h) atomicReference.get();
                                }
                            } catch (InterruptedException unused) {
                                Thread.currentThread().interrupt();
                            }
                        }
                    }
                    if (hVarA != null && hVarA.f33055a) {
                        HashMap map = new HashMap();
                        map.put("current_time", Integer.valueOf(hVarA.f33056b));
                        map.put("buffer_time", Integer.valueOf(hVarA.f33057c));
                        q.g().o((String) p80Var.f15298f, xyz.stream.utils.m.a(map), HlsMediaPlaylist.Interstitial.CUE_TRIGGER_POST);
                        ((Handler) obj).post(new g(p80Var, 3));
                        break;
                    }
                }
                break;
            case 3:
                ag.c cVar = (ag.c) p80Var.f15297e;
                if (cVar != null) {
                    cVar.w();
                }
                break;
            default:
                ag.c cVar2 = (ag.c) p80Var.f15297e;
                if (cVar2 != null) {
                    cVar2.z();
                }
                break;
        }
    }
}
