package com.tapjoy; import android.content.Context; import android.os.Looper; import android.text.TextUtils; import android.view.View; import com.ironsource.nb; import com.tapjoy.TapjoyErrorMessage; /* loaded from: classes4.dex */ public final class c implements Runnable { public final /* synthetic */ Context a; public final /* synthetic */ TJPlacementData b; public final /* synthetic */ boolean c; public final /* synthetic */ TJAdUnit d; public c(TJAdUnit tJAdUnit, Context context, TJPlacementData tJPlacementData, boolean z) { this.d = tJAdUnit; this.a = context; this.b = tJPlacementData; this.c = z; } @Override // java.lang.Runnable public final void run() { TJAdUnit tJAdUnit = this.d; Context context = this.a; tJAdUnit.getClass(); if (Looper.myLooper() == Looper.getMainLooper() && !tJAdUnit.i && context != null) { TapjoyLog.d("TJAdUnit", "Constructing ad unit"); tJAdUnit.i = true; try { tJAdUnit.d = new View(context); TJWebView tJWebView = new TJWebView(context); tJAdUnit.e = tJWebView; tJWebView.setWebViewClient(tJAdUnit.l); tJAdUnit.e.setWebChromeClient(tJAdUnit.m); tJAdUnit.c = new TJAdUnitJSBridge(new k(tJAdUnit)); if (context instanceof TJAdUnitActivity) { tJAdUnit.setAdUnitActivity((TJAdUnitActivity) context); } } catch (Exception e) { TapjoyLog.w("TJAdUnit", e.getMessage()); return; } } if (tJAdUnit.i) { TapjoyLog.i("TJAdUnit", "Loading ad unit content"); this.d.g = true; try { if (TextUtils.isEmpty(this.b.getRedirectURL())) { if (this.b.getBaseURL() == null || this.b.getHttpResponse() == null) { TapjoyLog.e("TJAdUnit", new TapjoyErrorMessage(TapjoyErrorMessage.ErrorType.SDK_ERROR, "Error loading ad unit content")); this.d.g = false; } else { this.d.e.loadDataWithBaseURL(this.b.getBaseURL(), this.b.getHttpResponse(), "text/html", nb.N, null); } } else if (this.b.isPreloadDisabled()) { this.d.e.postUrl(this.b.getRedirectURL(), null); } else { this.d.e.loadUrl(this.b.getRedirectURL()); } } catch (Exception unused) { TapjoyLog.e("TJAdUnit", new TapjoyErrorMessage(TapjoyErrorMessage.ErrorType.SDK_ERROR, "Error loading ad unit content")); this.d.g = false; } TJAdUnit tJAdUnit2 = this.d; tJAdUnit2.h = tJAdUnit2.g && this.c; } } }