package com.mbridge.msdk.splash.c; import android.app.Activity; import android.content.Context; import android.os.Handler; import android.os.Looper; import android.os.Message; import android.text.TextUtils; import android.util.Base64; import android.view.View; import android.view.ViewGroup; import android.webkit.WebView; import android.widget.RelativeLayout; import android.widget.TextView; import androidx.constraintlayout.core.motion.utils.TypedValues; import com.iab.omid.library.mmadbridge.adsession.AdEvents; import com.iab.omid.library.mmadbridge.adsession.AdSession; import com.mbridge.msdk.click.b; import com.mbridge.msdk.foundation.db.i; import com.mbridge.msdk.foundation.db.l; import com.mbridge.msdk.foundation.entity.CampaignEx; import com.mbridge.msdk.foundation.entity.p; import com.mbridge.msdk.foundation.same.report.c; import com.mbridge.msdk.foundation.tools.aa; import com.mbridge.msdk.foundation.tools.w; import com.mbridge.msdk.mbjscommon.confirmation.e; import com.mbridge.msdk.mbjscommon.windvane.AbsFeedBackForH5; import com.mbridge.msdk.mbjscommon.windvane.h; import com.mbridge.msdk.out.MBridgeIds; import com.mbridge.msdk.splash.d.a; import com.mbridge.msdk.splash.view.MBSplashView; import com.mbridge.msdk.splash.view.MBSplashWebview; import com.mbridge.msdk.widget.FeedBackButton; import java.util.ArrayList; import java.util.List; import org.json.JSONObject; /* compiled from: SplashShowManager */ public final class d { public Handler a = new Handler(Looper.getMainLooper()) { /* class com.mbridge.msdk.splash.c.d.AnonymousClass2 */ public final void handleMessage(Message message) { MBSplashWebview splashWebview; super.handleMessage(message); int i = message.what; if (i == 1) { if (!d.this.s) { d.this.g(); } if (d.this.m > 0) { d.e(d.this); d dVar = d.this; d.b(dVar, dVar.m); d.this.a.removeMessages(1); sendEmptyMessageDelayed(1, 1000); return; } d.this.b((d) 2); } else if (i == 2 && d.this.c != null && d.this.c.isActiveOm() && d.this.d != null && (splashWebview = d.this.d.getSplashWebview()) != null) { try { AdSession adSession = splashWebview.getAdSession(); if (adSession != null) { AdEvents.createAdEvents(adSession).impressionOccurred(); } w.a("OMSDK", "adSession.impressionOccurred()"); } catch (Throwable th) { w.a("OMSDK", th.getMessage()); if (d.this.c != null) { String requestId = d.this.c.getRequestId(); String requestIdNotice = d.this.c.getRequestIdNotice(); String id = d.this.c.getId(); com.mbridge.msdk.foundation.same.report.d dVar2 = new com.mbridge.msdk.foundation.same.report.d(splashWebview.getContext()); String str = d.this.j; dVar2.a(requestId, requestIdNotice, id, str, "fetch OM failed, exception" + th.getMessage()); } } } } }; private String b = "SplashShowManager"; private CampaignEx c; private MBSplashView d; private com.mbridge.msdk.splash.d.d e; private b f; private boolean g; private TextView h; private View i; private String j; private String k; private MBridgeIds l; private int m = 5; private String n = "点击跳过|"; private String o = "点击跳过|"; private String p = "秒"; private String q = "秒后自动关闭"; private boolean r; private boolean s; private Context t; private View.OnClickListener u = new View.OnClickListener() { /* class com.mbridge.msdk.splash.c.d.AnonymousClass1 */ public final void onClick(View view) { if (d.this.g) { d.this.b((d) 1); d.b(d.this, -1); } } }; private a v = new a() { /* class com.mbridge.msdk.splash.c.d.AnonymousClass3 */ @Override // com.mbridge.msdk.splash.d.a public final void a(int i) { if (d.this.d != null) { d.this.d.changeCloseBtnState(i); } } @Override // com.mbridge.msdk.splash.d.a public final void a(Object obj, String str) { d.this.b((d) 1); } @Override // com.mbridge.msdk.splash.d.a public final void a(CampaignEx campaignEx) { d.this.a(campaignEx, false, ""); } @Override // com.mbridge.msdk.splash.d.a public final void b(int i) { String str = d.this.b; w.d(str, "resetCountdown" + i); d.this.m = i; d.this.a.removeMessages(1); d.this.a.sendEmptyMessageDelayed(1, 1000); } @Override // com.mbridge.msdk.splash.d.a public final void a(int i, int i2) { if (i == 1) { d.this.a.removeMessages(1); } if (i == 2) { d.this.m = i2; d.this.a.removeMessages(1); d.this.a.sendEmptyMessageDelayed(1, 1000); } } @Override // com.mbridge.msdk.splash.d.a public final void a() { d.this.b((d) 1); } @Override // com.mbridge.msdk.splash.d.a public final void a(boolean z) { if (z) { d.this.a.removeMessages(1); } } @Override // com.mbridge.msdk.splash.d.a public final void a(boolean z, String str) { try { if (d.this.e == null) { return; } if (TextUtils.isEmpty(str)) { d.this.e.b(d.this.l); return; } CampaignEx parseCampaignWithBackData = CampaignEx.parseCampaignWithBackData(CampaignEx.campaignToJsonObject(d.this.c)); parseCampaignWithBackData.setClickURL(str); d.this.a(parseCampaignWithBackData, true, str); } catch (Exception e) { w.d(d.this.b, e.getMessage()); } } }; static /* synthetic */ int e(d dVar) { int i2 = dVar.m; dVar.m = i2 - 1; return i2; } public d(Context context, String str, String str2) { this.j = str2; this.k = str; this.l = new MBridgeIds(this.k, str2); this.t = context; if (this.h == null) { TextView textView = new TextView(context); this.h = textView; textView.setGravity(1); this.h.setTextIsSelectable(false); this.h.setPadding(aa.b(context, 5.0f), aa.b(context, 5.0f), aa.b(context, 5.0f), aa.b(context, 5.0f)); RelativeLayout.LayoutParams layoutParams = (RelativeLayout.LayoutParams) this.h.getLayoutParams(); this.h.setLayoutParams(layoutParams == null ? new RelativeLayout.LayoutParams(aa.b(context, 100.0f), aa.b(context, 50.0f)) : layoutParams); Context j2 = com.mbridge.msdk.foundation.controller.a.f().j(); if (j2 != null) { String d2 = com.mbridge.msdk.foundation.controller.a.f().d(); int identifier = j2.getResources().getIdentifier("mbridge_splash_count_time_can_skip", TypedValues.Custom.S_STRING, d2); int identifier2 = j2.getResources().getIdentifier("mbridge_splash_count_time_can_skip_not", TypedValues.Custom.S_STRING, d2); int identifier3 = j2.getResources().getIdentifier("mbridge_splash_count_time_can_skip_s", TypedValues.Custom.S_STRING, d2); this.o = j2.getResources().getString(identifier); String string = j2.getResources().getString(identifier2); this.q = string; this.n = string; this.p = j2.getResources().getString(identifier3); this.h.setBackgroundResource(j2.getResources().getIdentifier("mbridge_splash_close_bg", "drawable", com.mbridge.msdk.foundation.controller.a.f().d())); this.h.setTextColor(j2.getResources().getColor(j2.getResources().getIdentifier("mbridge_splash_count_time_skip_text_color", "color", d2))); } } } public final void a(com.mbridge.msdk.splash.d.d dVar) { this.e = dVar; } public final void a(int i2) { this.m = i2; } public final void a(ViewGroup viewGroup) { if (viewGroup != null) { viewGroup.setOnClickListener(this.u); } this.i = viewGroup; } public final a a() { return this.v; } public final void a(CampaignEx campaignEx, MBSplashView mBSplashView) { MBSplashWebview splashWebview; a(this.g); this.c = campaignEx; this.d = mBSplashView; com.mbridge.msdk.splash.js.b splashJSBridgeImpl = mBSplashView.getSplashJSBridgeImpl(); if (splashJSBridgeImpl == null) { splashJSBridgeImpl = new com.mbridge.msdk.splash.js.b(mBSplashView.getContext(), this.k, this.j); ArrayList arrayList = new ArrayList(); arrayList.add(campaignEx); splashJSBridgeImpl.a(arrayList); } splashJSBridgeImpl.b(this.m); splashJSBridgeImpl.a(this.g ? 1 : 0); splashJSBridgeImpl.a(this.v); mBSplashView.setSplashJSBridgeImpl(splashJSBridgeImpl); boolean isHasMBTplMark = campaignEx.isHasMBTplMark(); View view = this.i; if (view == null) { if (isHasMBTplMark) { this.h.setVisibility(8); } h(); a(this.h); mBSplashView.setCloseView(this.h); } else { if (isHasMBTplMark) { view.setVisibility(8); } a(this.i); mBSplashView.setCloseView(this.i); } mBSplashView.show(); CampaignEx campaignEx2 = this.c; if (!(campaignEx2 == null || !campaignEx2.isActiveOm() || mBSplashView == null || (splashWebview = mBSplashView.getSplashWebview()) == null)) { try { AdSession a2 = com.mbridge.msdk.a.b.a(com.mbridge.msdk.foundation.controller.a.f().j(), splashWebview, splashWebview.getUrl(), this.c); if (a2 != null) { splashWebview.setAdSession(a2); a2.registerAdView(splashWebview); a2.start(); w.a("OMSDK", "adSession.start()"); } } catch (Throwable th) { w.a("OMSDK", th.getMessage()); CampaignEx campaignEx3 = this.c; if (campaignEx3 != null) { String requestId = campaignEx3.getRequestId(); String requestIdNotice = this.c.getRequestIdNotice(); String id = this.c.getId(); com.mbridge.msdk.foundation.same.report.d dVar = new com.mbridge.msdk.foundation.same.report.d(splashWebview.getContext()); String str = this.j; dVar.a(requestId, requestIdNotice, id, str, "fetch OM failed, exception" + th.getMessage()); } } } b.a(this.j); b.b(this.c.getImageUrl()); this.a.removeMessages(1); this.a.sendEmptyMessageDelayed(1, 1000); this.a.sendEmptyMessageDelayed(2, 1000); if (com.mbridge.msdk.foundation.b.b.a().b() && !this.d.isDynamicView()) { com.mbridge.msdk.foundation.b.b.a().a(this.j, new com.mbridge.msdk.foundation.b.a() { /* class com.mbridge.msdk.splash.c.d.AnonymousClass4 */ @Override // com.mbridge.msdk.foundation.b.a public final void a() { String str; d.this.e(); try { JSONObject jSONObject = new JSONObject(); if (com.mbridge.msdk.foundation.controller.a.f().j() != null) { jSONObject.put("status", 1); } str = jSONObject.toString(); } catch (Throwable th) { w.b(d.this.b, th.getMessage(), th); str = ""; } h.a().a((WebView) d.this.d.getSplashWebview(), AbsFeedBackForH5.WEBVIEW_EVENT_DIALOG_METHOD_NAME, Base64.encodeToString(str.getBytes(), 2)); } @Override // com.mbridge.msdk.foundation.b.a public final void b() { String str; d.this.d(); try { JSONObject jSONObject = new JSONObject(); if (com.mbridge.msdk.foundation.controller.a.f().j() != null) { jSONObject.put("status", 2); } str = jSONObject.toString(); } catch (Throwable th) { w.b(d.this.b, th.getMessage(), th); str = ""; } h.a().a((WebView) d.this.d.getSplashWebview(), AbsFeedBackForH5.WEBVIEW_EVENT_DIALOG_METHOD_NAME, Base64.encodeToString(str.getBytes(), 2)); } @Override // com.mbridge.msdk.foundation.b.a public final void a(String str) { String str2; d.this.d(); try { JSONObject jSONObject = new JSONObject(); if (com.mbridge.msdk.foundation.controller.a.f().j() != null) { jSONObject.put("status", 2); } str2 = jSONObject.toString(); } catch (Throwable th) { w.b(d.this.b, th.getMessage(), th); str2 = ""; } h.a().a((WebView) d.this.d.getSplashWebview(), AbsFeedBackForH5.WEBVIEW_EVENT_DIALOG_METHOD_NAME, Base64.encodeToString(str2.getBytes(), 2)); } }); FeedBackButton b2 = com.mbridge.msdk.foundation.b.b.a().b(this.j); if (b2 != null) { RelativeLayout.LayoutParams layoutParams = null; try { layoutParams = (RelativeLayout.LayoutParams) b2.getLayoutParams(); } catch (Exception e2) { e2.printStackTrace(); } if (layoutParams == null) { layoutParams = new RelativeLayout.LayoutParams(com.mbridge.msdk.foundation.b.b.a, com.mbridge.msdk.foundation.b.b.b); } layoutParams.topMargin = aa.b(com.mbridge.msdk.foundation.controller.a.f().j(), 10.0f); layoutParams.leftMargin = aa.b(com.mbridge.msdk.foundation.controller.a.f().j(), 10.0f); ViewGroup viewGroup = (ViewGroup) b2.getParent(); if (viewGroup != null) { viewGroup.removeView(b2); } this.d.addView(b2, layoutParams); } this.c.setCampaignUnitId(this.j); com.mbridge.msdk.foundation.b.b.a().a(this.j, this.c); } } public final String b() { CampaignEx campaignEx = this.c; return (campaignEx == null || campaignEx.getRequestId() == null) ? "" : this.c.getRequestId(); } /* access modifiers changed from: private */ /* access modifiers changed from: public */ private synchronized void g() { if (this.c != null) { boolean z = true; this.s = true; if (!(this.e == null || this.d == null)) { Context context = this.t; if (context != null && (context instanceof Activity) && ((Activity) context).isFinishing()) { this.e.a(this.l, "Activity is finishing"); return; } else if (this.d.isShown()) { this.e.a(this.l); } else { this.e.a(this.l, "SplashView or container is not visibility"); } } if (!this.c.isReport()) { if (!this.d.isDynamicView()) { CampaignEx campaignEx = this.c; if (!campaignEx.isHasMBTplMark()) { c(campaignEx, com.mbridge.msdk.foundation.controller.a.f().j(), this.j); campaignEx.setReport(true); com.mbridge.msdk.foundation.same.a.d.a(this.j, campaignEx, "splash"); } else { z = false; } if (z) { b(campaignEx, com.mbridge.msdk.foundation.controller.a.f().j(), this.j); a(campaignEx, com.mbridge.msdk.foundation.controller.a.f().j(), this.j); } } else { CampaignEx campaignEx2 = this.c; b(campaignEx2, com.mbridge.msdk.foundation.controller.a.f().j(), this.j); c(campaignEx2, com.mbridge.msdk.foundation.controller.a.f().j(), this.j); a(campaignEx2, com.mbridge.msdk.foundation.controller.a.f().j(), this.j); campaignEx2.setReport(true); com.mbridge.msdk.foundation.same.a.d.a(this.j, campaignEx2, "splash"); } Context j2 = com.mbridge.msdk.foundation.controller.a.f().j(); CampaignEx campaignEx3 = this.c; String str = this.j; if (campaignEx3 != null) { try { if (campaignEx3.isMraid()) { p pVar = new p(); pVar.k(campaignEx3.getRequestId()); pVar.l(campaignEx3.getRequestIdNotice()); pVar.n(campaignEx3.getId()); pVar.a(campaignEx3.isMraid() ? p.a : p.b); c.a(pVar, j2.getApplicationContext(), str); } } catch (Exception e2) { e2.printStackTrace(); } } } } } public final void a(boolean z) { this.g = z; if (z) { this.n = this.o; } else { this.n = this.q; } } public final void a(final CampaignEx campaignEx, final boolean z, final String str) { MBSplashWebview splashWebview; Handler handler; if (campaignEx != null) { try { if (campaignEx.needShowIDialog()) { final AnonymousClass5 r0 = new com.mbridge.msdk.widget.dialog.a() { /* class com.mbridge.msdk.splash.c.d.AnonymousClass5 */ @Override // com.mbridge.msdk.widget.dialog.a public final void a() { d.this.b((d) campaignEx, (CampaignEx) z, (boolean) str); } @Override // com.mbridge.msdk.widget.dialog.a public final void b() { d.this.f(); } @Override // com.mbridge.msdk.widget.dialog.a public final void c() { a(); } }; if (this.d != null && com.mbridge.msdk.click.c.a(campaignEx) && campaignEx.needShowIDialog() && !this.r) { if (this.f == null) { this.f = new b(com.mbridge.msdk.foundation.controller.a.f().j(), this.j); } final Context context = this.d.getContext(); this.d.post(new Runnable() { /* class com.mbridge.msdk.splash.c.d.AnonymousClass6 */ public final void run() { if (!d.this.f.b(campaignEx)) { Context context = context; if (context != context.getApplicationContext()) { e.a().a("", campaignEx, context, d.this.j, r0); } else { e.a().a("", campaignEx, d.this.t, d.this.j, r0); } } else { com.mbridge.msdk.splash.e.a.a(com.mbridge.msdk.foundation.controller.a.f().j(), campaignEx); if (d.this.e != null) { d.this.e.b(d.this.l); d.this.b((d) 3); } } } }); this.r = true; if (this.m > 0 && (handler = this.a) != null) { handler.removeMessages(1); } MBSplashView mBSplashView = this.d; if (mBSplashView != null && (splashWebview = mBSplashView.getSplashWebview()) != null && !splashWebview.isDestoryed()) { com.mbridge.msdk.splash.js.c.a(splashWebview, "onInstallAlertShow", ""); return; } return; } } } catch (Throwable th) { w.a(this.b, th.getMessage()); } } if (campaignEx != null) { b(campaignEx, z, str); } } /* access modifiers changed from: private */ /* access modifiers changed from: public */ private void b(CampaignEx campaignEx, boolean z, String str) { if (this.f == null) { this.f = new b(com.mbridge.msdk.foundation.controller.a.f().j(), this.j); } campaignEx.setCampaignUnitId(this.j); this.f.c(campaignEx); if (!this.c.isReportClick()) { this.c.setReportClick(true); com.mbridge.msdk.splash.e.a.a(com.mbridge.msdk.foundation.controller.a.f().j(), campaignEx); } com.mbridge.msdk.splash.d.d dVar = this.e; if (dVar != null) { dVar.b(this.l); b(3); } if (z && !TextUtils.isEmpty(str)) { com.mbridge.msdk.splash.e.a.a(campaignEx, this.j, str); } } private void h() { String str; if (this.g) { str = this.o + this.m + this.p; } else { str = this.m + this.q; } this.h.setText(str); } private void a(View view) { if (view != null) { view.setOnClickListener(this.u); } } /* access modifiers changed from: private */ /* access modifiers changed from: public */ private void b(int i2) { com.mbridge.msdk.splash.a.b bVar; MBSplashWebview splashWebview; com.mbridge.msdk.splash.d.d dVar = this.e; if (dVar != null) { dVar.a(this.l, i2); this.e = null; com.mbridge.msdk.splash.e.a.a(this.j, this.c); } this.s = false; if (this.c != null) { bVar = com.mbridge.msdk.splash.a.b.a().b(this.j).d(this.c.getRequestId()).g(this.c.getRequestIdNotice()).c(this.c.getId()).e(this.c.getCreativeId() + "").a(this.c.isBidCampaign()); } else { bVar = null; } com.mbridge.msdk.splash.e.a.a(bVar, this.j, i2); MBSplashView mBSplashView = this.d; if (!(mBSplashView == null || (splashWebview = mBSplashView.getSplashWebview()) == null)) { splashWebview.finishAdSession(); } Handler handler = this.a; if (handler != null) { handler.removeCallbacksAndMessages(null); } } private void a(CampaignEx campaignEx, Context context, String str) { if (campaignEx != null) { try { List<String> pv_urls = campaignEx.getPv_urls(); if (pv_urls != null && pv_urls.size() > 0) { for (String str2 : pv_urls) { b.a(context, campaignEx, str, str2, false, true); } } } catch (Throwable th) { w.d(this.b, th.getMessage()); } } } private void b(CampaignEx campaignEx, Context context, String str) { if (campaignEx != null) { try { if (!TextUtils.isEmpty(campaignEx.getOnlyImpressionURL())) { b.a(context, campaignEx, str, campaignEx.getOnlyImpressionURL(), false, true, com.mbridge.msdk.click.a.a.h); } } catch (Throwable th) { w.d(this.b, th.getMessage()); } } } private void c(final CampaignEx campaignEx, final Context context, String str) { com.mbridge.msdk.foundation.controller.a.f().a(context); if (!TextUtils.isEmpty(campaignEx.getImpressionURL())) { new Thread(new Runnable() { /* class com.mbridge.msdk.splash.c.d.AnonymousClass7 */ public final void run() { try { l.a(i.a(context)).b(campaignEx.getId()); } catch (Exception unused) { w.d(d.this.b, "campain can't insert db"); } } }).start(); b.a(context, campaignEx, str, campaignEx.getImpressionURL(), false, true, com.mbridge.msdk.click.a.a.g); } if (!TextUtils.isEmpty(str) && campaignEx.getNativeVideoTracking() != null && campaignEx.getNativeVideoTracking().l() != null) { b.a(context, campaignEx, str, campaignEx.getNativeVideoTracking().l(), false, false); } } public final void c() { if (this.e != null) { this.e = null; } if (this.v != null) { this.v = null; } if (this.u != null) { this.u = null; } MBSplashView mBSplashView = this.d; if (mBSplashView != null) { mBSplashView.destroy(); } com.mbridge.msdk.foundation.b.b.a().c(this.j); } public final void d() { Handler handler; if (!this.r && !com.mbridge.msdk.foundation.b.b.c) { if (this.m > 0 && (handler = this.a) != null) { handler.removeMessages(1); this.a.sendEmptyMessageDelayed(1, 1000); } MBSplashView mBSplashView = this.d; if (mBSplashView != null) { mBSplashView.onResume(); MBSplashWebview splashWebview = this.d.getSplashWebview(); if (splashWebview != null && !splashWebview.isDestoryed()) { com.mbridge.msdk.splash.js.c.a(splashWebview, "onSystemResume", ""); } } } } public final void e() { Handler handler; if (this.m > 0 && (handler = this.a) != null) { handler.removeMessages(1); } MBSplashView mBSplashView = this.d; if (mBSplashView != null) { mBSplashView.onPause(); MBSplashWebview splashWebview = this.d.getSplashWebview(); if (splashWebview != null && !splashWebview.isDestoryed()) { com.mbridge.msdk.splash.js.c.a(splashWebview, "onSystemPause", ""); } } } public final void f() { MBSplashWebview splashWebview; Handler handler; this.r = false; if (this.m > 0 && (handler = this.a) != null) { handler.removeMessages(1); this.a.sendEmptyMessageDelayed(1, 1000); } MBSplashView mBSplashView = this.d; if (mBSplashView != null && (splashWebview = mBSplashView.getSplashWebview()) != null && !splashWebview.isDestoryed()) { com.mbridge.msdk.splash.js.c.a(splashWebview, "onInstallAlertHide", ""); } } static /* synthetic */ void b(d dVar, int i2) { MBSplashView mBSplashView = dVar.d; if (mBSplashView != null) { mBSplashView.updateCountdown(i2); if (dVar.d.getSplashJSBridgeImpl() != null) { dVar.d.getSplashJSBridgeImpl().c(i2); } } if (i2 < 0) { dVar.m = i2; return; } com.mbridge.msdk.splash.d.d dVar2 = dVar.e; if (dVar2 != null) { dVar2.a(dVar.l, (long) (i2 * 1000)); } if (dVar.i == null) { dVar.h(); } } }