package com.ironsource; import java.util.Calendar; import java.util.Timer; import java.util.TimerTask; /* loaded from: classes2.dex */ public class qk implements ij { private Timer b; private long e; private Runnable f; private String a = "INTERNAL"; private boolean c = false; private Long d = null; public class a extends TimerTask { public a() { } @Override // java.util.TimerTask, java.lang.Runnable public void run() { qk.this.f.run(); } } public qk(long j, Runnable runnable, boolean z) { this.e = j; this.f = runnable; if (z) { g(); } } private synchronized void f() { Timer timer = this.b; if (timer != null) { timer.cancel(); this.b = null; } } private synchronized void h() { if (this.b == null) { Timer timer = new Timer(); this.b = timer; timer.schedule(new a(), this.e); Calendar.getInstance().setTimeInMillis(this.d.longValue()); } } @Override // com.ironsource.ij public void a() { } @Override // com.ironsource.ij public void b() { if (this.b != null) { f(); } } @Override // com.ironsource.ij public void c() { Long l; if (this.b == null && (l = this.d) != null) { long longValue = l.longValue() - System.currentTimeMillis(); this.e = longValue; if (longValue > 0) { h(); } else { e(); this.f.run(); } } } @Override // com.ironsource.ij public void d() { } public void e() { f(); this.c = false; this.d = null; com.ironsource.lifecycle.b.d().b(this); } public void g() { if (this.c) { return; } this.c = true; com.ironsource.lifecycle.b.d().a(this); this.d = Long.valueOf(System.currentTimeMillis() + this.e); if (com.ironsource.lifecycle.b.d().e()) { return; } h(); } }