package com.mbridge.msdk.interstitial.signalcommon; import android.content.Context; import android.text.TextUtils; import android.util.Base64; import com.mbridge.msdk.click.c; import com.mbridge.msdk.foundation.db.j; import com.mbridge.msdk.foundation.entity.CampaignEx; import com.mbridge.msdk.foundation.same.a.b; import com.mbridge.msdk.foundation.same.net.f.e; import com.mbridge.msdk.foundation.tools.af; import com.mbridge.msdk.interstitial.b.a; import com.mbridge.msdk.interstitial.view.MBInterstitialActivity; import com.mbridge.msdk.mbsignalcommon.windvane.AbsFeedBackForH5; import com.mbridge.msdk.mbsignalcommon.windvane.g; import com.mbridge.msdk.mbsignalcommon.windvane.h; import java.util.ArrayList; import java.util.List; import org.json.JSONArray; import org.json.JSONException; import org.json.JSONObject; /* loaded from: classes4.dex */ public class interstitial extends AbsFeedBackForH5 { public static final /* synthetic */ int $r8$clinit = 0; private static final String a = "com.mbridge.msdk.interstitial.signalcommon.interstitial"; private Object e; public void getInfo(Object obj, String str) { MBInterstitialActivity mBInterstitialActivity; try { this.e = obj; Context context = this.b; if (context == null) { a(); return; } int a2 = a(context); if (TextUtils.isEmpty(b())) { a(); return; } if (a2 == 1) { try { Context context2 = this.b; if (context2 != null && a(context2) == 1) { try { MBInterstitialActivity mBInterstitialActivity2 = (MBInterstitialActivity) this.b; if (mBInterstitialActivity2 != null) { mBInterstitialActivity2.hideLoading(); } } catch (Exception e) { e.printStackTrace(); } } } catch (Exception e2) { try { e2.printStackTrace(); } catch (Exception e3) { e3.printStackTrace(); a(); return; } } try { Context context3 = this.b; if (context3 != null && a(context3) == 1 && (mBInterstitialActivity = (MBInterstitialActivity) this.b) != null) { mBInterstitialActivity.showWebView(); } } catch (Exception e4) { e4.printStackTrace(); } Context context4 = this.b; if (context4 == null) { a(); return; } if (a(context4) != 1) { a(); return; } Context context5 = this.b; if (context5 instanceof MBInterstitialActivity) { ((MBInterstitialActivity) context5).mIsMBPage = true; } final String b = b(); if (TextUtils.isEmpty(b)) { a(); return; } final List a3 = a(b); if (a3 != null) { String a4 = a(a3); if (TextUtils.isEmpty(a4)) { a(); return; } g.a().a(obj, a4); try { if (!TextUtils.isEmpty(b) && a3.size() != 0) { for (int i = 0; i < a3.size(); i++) { CampaignEx campaignEx = a3.get(i); if (campaignEx != null) { b.a(b, campaignEx, "interstitial"); } } } } catch (Exception e5) { e5.printStackTrace(); } try { if (!TextUtils.isEmpty(b) && a3.size() != 0) { new Thread(new Runnable() { // from class: com.mbridge.msdk.interstitial.signalcommon.interstitial.2 @Override // java.lang.Runnable public final void run() { for (int i2 = 0; i2 < a3.size(); i2++) { CampaignEx campaignEx2 = (CampaignEx) a3.get(i2); if (campaignEx2 != null) { j.a(com.mbridge.msdk.foundation.db.g.a(((h) interstitial.this).b)).a(campaignEx2.getId()); } } } }).start(); } } catch (Exception e6) { e6.printStackTrace(); } try { new Thread(new Runnable() { // from class: com.mbridge.msdk.interstitial.signalcommon.interstitial.1 @Override // java.lang.Runnable public final void run() { a a5 = a.a(); if (a5 != null) { a5.a(a3, b); } } }).start(); return; } catch (Exception e7) { e7.printStackTrace(); return; } } a(); } } catch (Exception e8) { e8.printStackTrace(); a(); } } public void install(Object obj, String str) { try { Context context = this.b; if (context != null && (context instanceof MBInterstitialActivity)) { ((MBInterstitialActivity) context).clickTracking(); } } catch (Exception e) { e.printStackTrace(); } } public void openURL(Object obj, String str) { if (TextUtils.isEmpty(str)) { return; } try { JSONObject jSONObject = new JSONObject(str); String optString = jSONObject.optString("url"); int optInt = jSONObject.optInt("type"); if (optInt == 1) { c.d(this.b, optString); } else if (optInt == 2) { c.f(this.b, optString); } } catch (JSONException e) { af.b(a, e.getMessage()); } catch (Throwable th) { af.b(a, th.getMessage()); } } private void a() { try { g.a().a(this.e, ""); } catch (Exception e) { e.printStackTrace(); } } private List a(String str) { try { if (TextUtils.isEmpty(str) || a.a() == null) { return null; } return a.a().a(str, 1); } catch (Exception e) { e.printStackTrace(); return null; } } private String a(List list) { if (list == null) { return ""; } try { if (list.size() <= 0) { return ""; } JSONArray parseCamplistToJson = CampaignEx.parseCamplistToJson(list); JSONObject jSONObject = new JSONObject(); jSONObject.put("campaignList", parseCamplistToJson); String jSONObject2 = jSONObject.toString(); return !TextUtils.isEmpty(jSONObject2) ? Base64.encodeToString(jSONObject2.getBytes(), 2) : ""; } catch (Exception e) { e.printStackTrace(); return ""; } } public List getExcludeIdList(String str) { Exception e; ArrayList arrayList; try { } catch (Exception e2) { e = e2; arrayList = null; } if (TextUtils.isEmpty(str)) { return null; } String optString = new JSONObject(str).optString(e.e); if (TextUtils.isEmpty(optString)) { return null; } JSONArray jSONArray = new JSONArray(optString); if (jSONArray.length() <= 0) { return null; } arrayList = new ArrayList(); for (int i = 0; i < jSONArray.length(); i++) { try { if (!TextUtils.isEmpty(jSONArray.optString(i))) { arrayList.add(jSONArray.optString(i)); } } catch (Exception e3) { e = e3; e.printStackTrace(); return arrayList; } } return arrayList; } private int a(Context context) { return (context == null || !(context instanceof MBInterstitialActivity)) ? -1 : 1; } private String b() { Context context; MBInterstitialActivity mBInterstitialActivity; String str = null; try { context = this.b; } catch (Exception e) { e.printStackTrace(); } if (context == null) { return null; } if (a(context) == 1) { try { Context context2 = this.b; if (context2 != null && (context2 instanceof MBInterstitialActivity) && (mBInterstitialActivity = (MBInterstitialActivity) context2) != null) { str = mBInterstitialActivity.mUnitid; return str; } } catch (Exception e2) { e2.printStackTrace(); } } return str; } }