package com.vungle.warren; import android.os.Handler; import android.os.Looper; import android.os.SystemClock; import android.util.Log; import com.vungle.warren.utility.o; import java.lang.ref.WeakReference; import java.util.ArrayList; import java.util.List; import java.util.concurrent.CopyOnWriteArrayList; import java.util.concurrent.Executor; /* loaded from: classes2.dex */ class j0 implements i8.h { /* renamed from: i, reason: collision with root package name */ private static Handler f8250i = new Handler(Looper.getMainLooper()); /* renamed from: j, reason: collision with root package name */ private static final String f8251j = j0.class.getSimpleName(); /* renamed from: a, reason: collision with root package name */ private final k8.b f8252a; /* renamed from: b, reason: collision with root package name */ private final com.vungle.warren.utility.o f8253b; /* renamed from: c, reason: collision with root package name */ private i8.f f8254c; /* renamed from: d, reason: collision with root package name */ private Executor f8255d; /* renamed from: g, reason: collision with root package name */ private long f8258g = Long.MAX_VALUE; /* renamed from: h, reason: collision with root package name */ private final o.d f8259h = new a(); /* renamed from: e, reason: collision with root package name */ private List f8256e = new CopyOnWriteArrayList(); /* renamed from: f, reason: collision with root package name */ private Runnable f8257f = new c(new WeakReference(this)); class a implements o.d { a() { } @Override // com.vungle.warren.utility.o.d public void a(int i10) { j0.this.d(); } } private static class b { /* renamed from: a, reason: collision with root package name */ private final long f8261a; /* renamed from: b, reason: collision with root package name */ i8.g f8262b; b(long j10, i8.g gVar) { this.f8261a = j10; this.f8262b = gVar; } } private static class c implements Runnable { /* renamed from: a, reason: collision with root package name */ WeakReference f8263a; c(WeakReference weakReference) { this.f8263a = weakReference; } @Override // java.lang.Runnable public void run() { j0 j0Var = (j0) this.f8263a.get(); if (j0Var != null) { j0Var.d(); } } } j0(i8.f fVar, Executor executor, k8.b bVar, com.vungle.warren.utility.o oVar) { this.f8254c = fVar; this.f8255d = executor; this.f8252a = bVar; this.f8253b = oVar; } /* JADX INFO: Access modifiers changed from: private */ public synchronized void d() { long uptimeMillis = SystemClock.uptimeMillis(); long j10 = Long.MAX_VALUE; long j11 = 0; for (b bVar : this.f8256e) { if (uptimeMillis >= bVar.f8261a) { boolean z10 = true; if (bVar.f8262b.g() == 1 && this.f8253b.e() == -1) { j11++; z10 = false; } if (z10) { this.f8256e.remove(bVar); this.f8255d.execute(new j8.a(bVar.f8262b, this.f8254c, this, this.f8252a)); } } else { j10 = Math.min(j10, bVar.f8261a); } } if (j10 != Long.MAX_VALUE && j10 != this.f8258g) { f8250i.removeCallbacks(this.f8257f); f8250i.postAtTime(this.f8257f, f8251j, j10); } this.f8258g = j10; if (j11 > 0) { this.f8253b.d(this.f8259h); } else { this.f8253b.j(this.f8259h); } } @Override // i8.h public synchronized void a(i8.g gVar) { i8.g a10 = gVar.a(); String e10 = a10.e(); long b10 = a10.b(); a10.j(0L); if (a10.h()) { for (b bVar : this.f8256e) { if (bVar.f8262b.e().equals(e10)) { Log.d(f8251j, "replacing pending job with new " + e10); this.f8256e.remove(bVar); } } } this.f8256e.add(new b(SystemClock.uptimeMillis() + b10, a10)); d(); } @Override // i8.h public synchronized void b(String str) { ArrayList arrayList = new ArrayList(); for (b bVar : this.f8256e) { if (bVar.f8262b.e().equals(str)) { arrayList.add(bVar); } } this.f8256e.removeAll(arrayList); } }