package com.tapjoy.internal; import android.os.SystemClock; import androidx.work.WorkRequest; import com.tapjoy.TJActionRequest; import com.tapjoy.TJError; import com.tapjoy.TJPlacement; import com.tapjoy.TJPlacementListener; import com.tapjoy.TapjoyConnectCore; import com.tapjoy.TapjoyLog; import java.util.Observable; import java.util.Observer; /* loaded from: classes4.dex */ public final class l1 implements Observer, TJPlacementListener { public final d3 a; public volatile boolean b; public TJPlacement c; public final /* synthetic */ m1 d; public l1(m1 m1Var) { d3 d3Var = new d3(WorkRequest.MIN_BACKOFF_MILLIS); this.d = m1Var; this.a = d3Var; } public final void a() { synchronized (this) { try { if (this.b) { return; } d3 d3Var = this.a; d3Var.getClass(); try { if (SystemClock.elapsedRealtime() - d3Var.b <= d3Var.a) { if (!TapjoyConnectCore.getInstance().isConnected()) { x xVar = y.a; xVar.addObserver(this); if (!TapjoyConnectCore.getInstance().isConnected()) { return; } else { xVar.deleteObserver(this); } } TJPlacement tJPlacement = this.c; if (tJPlacement == null) { if (!this.d.a()) { a("Cannot request"); return; } TJPlacement a = this.d.a(TapjoyConnectCore.getInstance().getContext(), this); this.c = a; a.requestContent(); return; } if (tJPlacement.isContentReady()) { this.d.getClass(); if (TapjoyConnectCore.getInstance().isViewOpen()) { x xVar2 = y.c; xVar2.addObserver(this); if (TapjoyConnectCore.getInstance().isViewOpen()) { return; } else { xVar2.deleteObserver(this); } } this.c.showContent(); a(null); return; } return; } } catch (NullPointerException unused) { } a("Timed out"); } catch (Throwable th) { throw th; } } } @Override // com.tapjoy.TJPlacementListener public final void onClick(TJPlacement tJPlacement) { } @Override // com.tapjoy.TJPlacementListener public final void onContentDismiss(TJPlacement tJPlacement) { } @Override // com.tapjoy.TJPlacementListener public final void onContentReady(TJPlacement tJPlacement) { a(); } @Override // com.tapjoy.TJPlacementListener public final void onContentShow(TJPlacement tJPlacement) { } @Override // com.tapjoy.TJPlacementListener public final void onPurchaseRequest(TJPlacement tJPlacement, TJActionRequest tJActionRequest, String str) { } @Override // com.tapjoy.TJPlacementListener public final void onRequestFailure(TJPlacement tJPlacement, TJError tJError) { a(tJError.message); } @Override // com.tapjoy.TJPlacementListener public final void onRequestSuccess(TJPlacement tJPlacement) { } @Override // com.tapjoy.TJPlacementListener public final void onRewardRequest(TJPlacement tJPlacement, TJActionRequest tJActionRequest, String str, int i) { } @Override // java.util.Observer public final void update(Observable observable, Object obj) { a(); } public final void a(String str) { synchronized (this) { try { String b = this.d.b(); if (str == null) { TapjoyLog.i("SystemPlacement", "Placement " + b + " is presented now"); } else { TapjoyLog.i("SystemPlacement", "Cannot show placement " + b + " now (" + str + ")"); } this.b = true; this.c = null; y.a.deleteObserver(this); y.c.deleteObserver(this); } catch (Throwable th) { throw th; } } this.d.a(this); } }