package com.mbridge.msdk.mbnative.controller; import android.content.Context; import android.graphics.Bitmap; import android.os.Build; import android.os.Handler; import android.os.Looper; import android.os.Message; import android.text.TextUtils; import android.util.Log; import android.view.View; import android.view.ViewGroup; 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.MBridgeConstans; import com.mbridge.msdk.foundation.db.i; import com.mbridge.msdk.foundation.db.k; import com.mbridge.msdk.foundation.db.l; import com.mbridge.msdk.foundation.db.t; import com.mbridge.msdk.foundation.download.download.H5DownLoadManager; import com.mbridge.msdk.foundation.download.download.HTMLResourceManager; import com.mbridge.msdk.foundation.download.download.ResourceManager; import com.mbridge.msdk.foundation.entity.CampaignEx; import com.mbridge.msdk.foundation.entity.CampaignUnit; import com.mbridge.msdk.foundation.entity.h; import com.mbridge.msdk.foundation.entity.m; import com.mbridge.msdk.foundation.entity.p; import com.mbridge.msdk.foundation.same.e.a; import com.mbridge.msdk.foundation.tools.SameMD5; import com.mbridge.msdk.foundation.tools.aa; import com.mbridge.msdk.foundation.tools.r; import com.mbridge.msdk.foundation.tools.s; import com.mbridge.msdk.foundation.tools.u; import com.mbridge.msdk.foundation.tools.w; import com.mbridge.msdk.mbnative.controller.a; import com.mbridge.msdk.out.Campaign; import com.mbridge.msdk.out.Frame; import com.mbridge.msdk.out.NativeListener; import com.sigmob.sdk.base.mta.PointCategory; import java.lang.ref.WeakReference; import java.util.ArrayList; import java.util.HashMap; import java.util.Hashtable; import java.util.Iterator; import java.util.LinkedList; import java.util.List; import java.util.Map; import java.util.Queue; import java.util.Timer; import java.util.TimerTask; import java.util.UUID; import java.util.concurrent.CopyOnWriteArrayList; import org.json.JSONArray; import org.json.JSONException; import org.json.JSONObject; public class NativeController { private static boolean B = false; public static Map<String, Long> c = new HashMap(); private static final String e = "NativeController"; private boolean A = false; private int C = 0; private int D = 0; private int E = 0; private int F = 0; private com.mbridge.msdk.foundation.same.e.b G; private Map<String, Boolean> H = new HashMap(); private List<a> I; private List<a.AbstractC0220a> J; /* renamed from: K reason: collision with root package name */ private CopyOnWriteArrayList<com.mbridge.msdk.foundation.same.e.a> f116K = new CopyOnWriteArrayList<>(); private Hashtable<String, AdSession> L = new Hashtable<>(); private int M = 1; private String N = ""; private i O; private int P = 2; private a Q; private boolean R; private boolean S; private String T = ""; private Timer U; private String V = ""; private com.mbridge.msdk.c.d W; private long X; private int Y; private int Z; protected List<Integer> a; private boolean aa; private int ab; private int ac; private boolean ad; protected List<Integer> b; Map<String, Object> d; private com.mbridge.msdk.c.c f; private com.mbridge.msdk.mbnative.c.a g; private NativeListener.NativeTrackingListener h; private Context i; private String j; private String k; private Queue<Integer> l; private Queue<Long> m; private String n; private e o; private com.mbridge.msdk.foundation.same.report.d p; private String q; private com.mbridge.msdk.click.b r; private int s = 1; private int t = 1; private int u = -1; private int v = 0; private String w; private boolean x; private boolean y = false; private boolean z = false; public interface b { void a(); } /* access modifiers changed from: private */ public static class e extends Handler { private WeakReference<NativeController> a; public e(NativeController nativeController) { this.a = new WeakReference<>(nativeController); } public final void handleMessage(Message message) { WeakReference<NativeController> weakReference; NativeController nativeController; super.handleMessage(message); try { if (!(message.what != 0 || (weakReference = this.a) == null || (nativeController = weakReference.get()) == null)) { nativeController.p.a(message.arg1, (String) message.obj); } if (message.what == 1) { NativeController nativeController2 = null; WeakReference<NativeController> weakReference2 = this.a; if (!(weakReference2 == null || weakReference2.get() == null)) { nativeController2 = this.a.get(); } if (nativeController2 != null) { nativeController2.z = true; w.b(NativeController.e, "time out return"); List<Campaign> b = nativeController2.b(nativeController2.j, nativeController2.t, nativeController2.V); if (!nativeController2.y) { String str = NativeController.e; w.b(str, "time out return isReturn = " + nativeController2.y); nativeController2.a((NativeController) b); } } } } catch (Exception e) { w.d(NativeController.e, com.mbridge.msdk.mbnative.b.a.a(e)); } } } public NativeController(com.mbridge.msdk.mbnative.c.a aVar, NativeListener.NativeTrackingListener nativeTrackingListener, Map<String, Object> map, Context context) { com.mbridge.msdk.mbnative.a.b<String, List<Campaign>> a2; this.i = context; this.d = map; this.f = new com.mbridge.msdk.c.c(); this.g = aVar; this.h = nativeTrackingListener; this.I = new ArrayList(); this.J = new ArrayList(); String str = (String) map.get(MBridgeConstans.PROPERTIES_UNIT_ID); this.j = str; if (TextUtils.isEmpty(str)) { w.c(e, "load error,make sure you have correct unitid"); return; } if (!map.containsKey(MBridgeConstans.PLACEMENT_ID) || map.get(MBridgeConstans.PLACEMENT_ID) == null) { this.k = ""; } else { this.k = (String) map.get(MBridgeConstans.PLACEMENT_ID); } if (map.containsKey(MBridgeConstans.PREIMAGE)) { B = ((Boolean) map.get(MBridgeConstans.PREIMAGE)).booleanValue(); } this.l = new LinkedList(); this.m = new LinkedList(); this.G = new com.mbridge.msdk.foundation.same.e.b(this.i); if (Looper.myLooper() == null) { Looper.prepare(); } this.o = new e(this); if (map.containsKey(MBridgeConstans.PROPERTIES_API_REUQEST_CATEGORY)) { this.w = (String) map.get(MBridgeConstans.PROPERTIES_API_REUQEST_CATEGORY); } try { if (!(b.b().containsKey(this.j) ? b.b().get(this.j).booleanValue() : false)) { if (map.containsKey("ad_num")) { int intValue = ((Integer) map.get("ad_num")).intValue(); intValue = intValue < 1 ? 1 : intValue; intValue = intValue > 10 ? 10 : intValue; this.t = intValue; this.s = intValue; } if (map.containsKey(MBridgeConstans.PROPERTIES_AD_FRAME_NUM)) { this.E = ((Integer) map.get(MBridgeConstans.PROPERTIES_AD_FRAME_NUM)).intValue(); } } else if (b.d().containsKey(this.j)) { this.t = b.d().get(this.j).intValue(); if (map.containsKey("ad_num")) { int intValue2 = ((Integer) map.get("ad_num")).intValue(); this.C = intValue2; this.s = intValue2; } if (map.containsKey(MBridgeConstans.PROPERTIES_AD_FRAME_NUM)) { int intValue3 = ((Integer) map.get(MBridgeConstans.PROPERTIES_AD_FRAME_NUM)).intValue(); this.D = intValue3; this.E = intValue3; } } } catch (Exception e2) { w.d(e, com.mbridge.msdk.mbnative.b.a.a(e2)); } this.p = new com.mbridge.msdk.foundation.same.report.d(this.i); this.r = new com.mbridge.msdk.click.b(this.i, this.j); try { Class.forName("com.mbridge.msdk.nativex.view.MBMediaView"); Class.forName("com.mbridge.msdk.videocommon.download.b"); this.S = true; Map<String, Object> map2 = this.d; if (map2 != null && (map2.containsKey(MBridgeConstans.NATIVE_VIDEO_WIDTH) || this.d.containsKey(MBridgeConstans.NATIVE_VIDEO_HEIGHT) || map.containsKey(MBridgeConstans.NATIVE_VIDEO_SUPPORT))) { this.R = true; } c.a(this.i, this.j); u.b(); if (!TextUtils.isEmpty(this.j)) { com.mbridge.msdk.foundation.db.f.a(i.a(this.i)).a(); int a3 = a(map.containsKey(MBridgeConstans.NATIVE_INFO) ? (String) map.get(MBridgeConstans.NATIVE_INFO) : null); String str2 = this.j; a3 = a3 <= 0 ? this.s : a3; com.mbridge.msdk.c.d e3 = com.mbridge.msdk.c.b.a().e("", str2); this.W = e3; if (e3 == null) { this.W = com.mbridge.msdk.c.d.d(str2); } List<Integer> r2 = this.W.r(); this.a = r2; List<Campaign> b2 = (r2 == null || r2.size() <= 0 || !this.a.contains(1) || (a2 = com.mbridge.msdk.mbnative.a.f.a(1)) == null) ? null : a2.b(str2, a3); if (b2 != null) { ArrayList arrayList = new ArrayList(); for (int i2 = 0; i2 < b2.size(); i2++) { CampaignEx campaignEx = (CampaignEx) b2.get(i2); if (!TextUtils.isEmpty(campaignEx.getVideoUrlEncode())) { arrayList.add(campaignEx); } } if (arrayList.size() > 0) { Class<?> cls = Class.forName("com.mbridge.msdk.videocommon.download.b"); Class<?> cls2 = Class.forName("com.mbridge.msdk.videocommon.listener.a"); Object invoke = cls.getMethod("getInstance", new Class[0]).invoke(null, new Object[0]); cls.getMethod("createUnitCache", Context.class, String.class, List.class, Integer.TYPE, cls2).invoke(invoke, context, this.j, arrayList, 1, null); cls.getMethod(PointCategory.LOAD, String.class).invoke(invoke, this.j); } } } } catch (Throwable unused) { w.d(e, "please import the nativex aar"); } } public NativeController() { } private int a(String str) { if (str == null) { return 0; } try { JSONArray jSONArray = new JSONArray(str); if (jSONArray.length() > 0) { for (int i2 = 0; i2 < jSONArray.length(); i2++) { JSONObject jSONObject = (JSONObject) jSONArray.opt(i2); if (2 == jSONObject.optInt("id", 0)) { return jSONObject.optInt("ad_num"); } } } } catch (Exception e2) { w.d(e, com.mbridge.msdk.mbnative.b.a.a(e2)); } return 0; } public final void a(int i2, String str) { String str2; boolean z2; this.y = false; this.z = false; this.A = false; this.aa = false; this.x = false; this.V = str; this.g.a(!TextUtils.isEmpty(str)); String str3 = null; this.Q = null; Map<String, Long> map = c; if (map != null && map.size() > 0) { c.clear(); } if (!((b.b() == null || !b.b().containsKey(this.j)) ? false : b.b().get(this.j).booleanValue()) || i2 != 1 || !a(i2)) { if (!this.d.containsKey("app_id") || !this.d.containsKey(MBridgeConstans.APP_KEY) || !this.d.containsKey(MBridgeConstans.KEY_WORD)) { str2 = null; } else { str3 = (String) this.d.get("app_id"); str2 = (String) this.d.get(MBridgeConstans.APP_KEY); } this.f.a(this.i, str3, str2, this.j); com.mbridge.msdk.c.d e2 = com.mbridge.msdk.c.b.a().e(str3, this.j); this.W = e2; if (e2 == null) { this.W = com.mbridge.msdk.c.d.d(this.j); } b.e().put(this.j, Integer.valueOf(this.W.v() * this.t)); this.a = this.W.r(); this.b = this.W.s(); this.Z = this.W.p(); this.Y = this.W.q(); this.t = this.s; List<Integer> list = this.a; if (list == null || list.size() == 0) { com.mbridge.msdk.mbnative.c.a aVar = this.g; if (aVar != null) { this.y = true; aVar.onAdLoadError("don't have sorceList"); return; } return; } try { z2 = com.mbridge.msdk.mbjscommon.webEnvCheck.a.a(com.mbridge.msdk.foundation.controller.a.f().j()); } catch (Exception unused) { z2 = false; } if (!z2) { com.mbridge.msdk.mbnative.c.a aVar2 = this.g; if (aVar2 != null) { aVar2.onAdLoadError("webview is not available"); return; } return; } if (this.d.containsKey(MBridgeConstans.NATIVE_INFO) && this.n == null) { String str4 = (String) this.d.get(MBridgeConstans.NATIVE_INFO); this.n = str4; if (str4 != null) { try { JSONArray jSONArray = new JSONArray(this.n); if (jSONArray.length() > 0) { for (int i3 = 0; i3 < jSONArray.length(); i3++) { JSONObject jSONObject = (JSONObject) jSONArray.opt(i3); int optInt = jSONObject.optInt("id", 0); if (2 == optInt) { this.ab = jSONObject.optInt("ad_num"); if (this.Z > 0) { jSONObject.remove("ad_num"); jSONObject.put("ad_num", this.Z); } } else if (3 == optInt) { this.ac = jSONObject.optInt("ad_num"); if (this.Z > 0) { jSONObject.remove("ad_num"); jSONObject.put("ad_num", this.Z); } } } } this.M = Math.max(this.ab, this.ac); this.n = jSONArray.toString(); } catch (JSONException e3) { w.d(e, com.mbridge.msdk.mbnative.b.a.a(e3)); } } } if (!((!this.a.contains(1) || this.a.get(0).intValue() == 1) && i2 == 0 && a(b(this.j, this.t, this.V)))) { this.ad = true; if (this.a.contains(1) && i2 == 0 && this.a.get(0).intValue() != 1) { int intValue = this.a.get(0).intValue(); com.mbridge.msdk.mbnative.a.b<String, List<Campaign>> a2 = com.mbridge.msdk.mbnative.a.f.a(intValue); if (intValue != 2 || !this.d.containsKey(MBridgeConstans.NATIVE_INFO)) { this.t = this.s; } else { this.t = this.M; } if (a2 == null || !a(a(intValue, d(a2.b(this.j, this.t))))) { this.x = false; this.ad = false; try { a((long) (this.b.get(this.a.indexOf(1)).intValue() * 1000), i2, false, this.j, this.V); } catch (Exception unused2) { } } else { return; } } this.o.sendEmptyMessageDelayed(1, (long) (this.W.m() * 1000)); List<Integer> list2 = this.a; if (list2 != null && list2.size() > 0) { Queue<Integer> queue = this.l; if (queue != null && queue.size() > 0) { w.b(e, "setRequestQueue clear requestqueue"); this.l.clear(); } for (Integer num : this.a) { Queue<Integer> queue2 = this.l; if (queue2 != null) { queue2.add(num); } } } List<Integer> list3 = this.b; if (list3 != null && list3.size() > 0) { Queue<Long> queue3 = this.m; if (queue3 != null && queue3.size() > 0) { this.m.clear(); } for (Integer num2 : this.b) { Queue<Long> queue4 = this.m; if (queue4 != null) { queue4.add(Long.valueOf((long) (num2.intValue() * 1000))); } } } b(i2, this.V); } } } private boolean a(int i2) { int i3; int i4; int i5; com.mbridge.msdk.mbnative.c.a aVar; int i6 = 0; if (b.b().containsKey(this.j) && b.b().get(this.j).booleanValue()) { Map<String, Map<Long, Object>> a2 = b.a(); Map<Long, Object> map = a2.get(i2 + "_" + this.j); Integer num = b.d().get(this.j); com.mbridge.msdk.c.a b2 = com.mbridge.msdk.c.b.a().b(com.mbridge.msdk.foundation.controller.a.f().k()); if (num != null) { this.t = num.intValue(); } if (map != null && map.size() > 0) { Long next = map.keySet().iterator().next(); long currentTimeMillis = System.currentTimeMillis(); if (b2 == null) { b2 = com.mbridge.msdk.c.b.a().b(); } if (currentTimeMillis - next.longValue() >= b2.ae() * 1000) { a2.remove(i2 + "_" + this.j); } else if (i2 == 1) { List<Frame> list = (List) map.get(next); if (list == null || list.size() <= 0 || (aVar = this.g) == null) { return false; } if (this.E >= list.size()) { a2.remove(i2 + "_" + this.j); aVar.onAdFramesLoaded(list); return true; } else if (this.E == 0) { return false; } else { List<Frame> subList = list.subList(0, this.D); aVar.onAdFramesLoaded(list); list.removeAll(subList); map.put(next, subList); ArrayList arrayList = new ArrayList(); for (Frame frame : list) { if (i6 >= this.E) { arrayList.add(frame); } i6++; } map.put(next, arrayList); a2.put(i2 + "_" + this.j, map); aVar.onAdFramesLoaded(subList); return true; } } else { List list2 = (List) map.get(next); if (list2 != null && list2.size() > 0) { List<Campaign> arrayList2 = new ArrayList<>(); if (((CampaignEx) list2.get(0)).getType() == 1) { if (TextUtils.isEmpty(this.n)) { i3 = Math.min(this.C, list2.size()); } else { try { JSONArray jSONArray = new JSONArray(this.n); if (jSONArray.length() > 0) { i5 = 0; i4 = 0; for (int i7 = 0; i7 < jSONArray.length(); i7++) { JSONObject jSONObject = (JSONObject) jSONArray.opt(i7); int optInt = jSONObject.optInt("id", 0); if (2 == optInt) { i5 = jSONObject.optInt("ad_num"); } else if (3 == optInt) { i4 = jSONObject.optInt("ad_num"); } } } else { i5 = 0; i4 = 0; } if (3 == ((CampaignEx) list2.get(0)).getTemplate()) { i3 = Math.min(i4, list2.size()); } else { i3 = Math.min(i5, list2.size()); } } catch (Exception unused) { w.d(e, "load from catch error in get nativeinfo adnum"); i3 = 0; } } if (i3 <= 0) { return false; } Iterator it = list2.iterator(); while (it.hasNext() && i6 != i3) { CampaignEx campaignEx = (CampaignEx) it.next(); campaignEx.getTemplate(); arrayList2.add(campaignEx); it.remove(); i6++; } } else { int min = Math.min(this.C, list2.size()); if (min > 0) { Iterator it2 = list2.iterator(); while (it2.hasNext() && i6 != min) { CampaignEx campaignEx2 = (CampaignEx) it2.next(); campaignEx2.getTemplate(); arrayList2.add(campaignEx2); it2.remove(); i6++; } } } a(arrayList2); return true; } } } } return false; } private void b(int i2, String str) { Queue<Integer> queue = this.l; if (queue != null && queue.size() > 0) { int intValue = this.l.poll().intValue(); this.X = (long) MBridgeConstans.REQUEST_TIME_OUT; Queue<Long> queue2 = this.m; if (queue2 != null && queue2.size() > 0) { this.X = this.m.poll().longValue(); } String str2 = e; w.b(str2, "start queue adsource = " + intValue); b(intValue, this.X, i2, str); } else if (!this.y && this.g != null) { w.b(e, "no ad source return"); this.y = true; this.g.onAdLoadError("no ad source"); } } private void b(int i2, long j2, int i3, String str) { com.mbridge.msdk.mbnative.a.b<String, List<Campaign>> a2; if (i3 == 0 && (a2 = com.mbridge.msdk.mbnative.a.f.a(i2)) != null) { if ((i2 == 1 || i2 == 2) && this.d.containsKey(MBridgeConstans.NATIVE_INFO)) { this.t = this.M; } else { this.t = this.s; } if (a(a(i2, d(a2.b(this.j, this.t))))) { return; } } this.x = false; if (i2 == 1) { a(j2, i3, true, this.j, str); } else if (i2 != 2) { a(i2, j2, i3, str); } else { a(2, j2, i3, str); } } public final void a(String str, int i2, String str2) { String str3 = e; w.b(str3, "request error msg = " + str); Queue<Integer> queue = this.l; if ((queue == null || queue.size() > 0) && this.l != null) { w.b(str3, "request queue in request error"); b(i2, str2); return; } com.mbridge.msdk.mbnative.c.a aVar = this.g; if (aVar != null && !this.y) { this.y = true; aVar.onAdLoadError(str); w.b(str3, "requestError return listener isReturn = " + this.y); } } public final synchronized void a(int i2, long j2, int i3, String str) { m mVar; try { if (this.d.containsKey(MBridgeConstans.NATIVE_INFO)) { this.t = Math.max(this.ab, this.ac); } if (i3 == 0) { com.mbridge.msdk.mbnative.a.b<String, List<Campaign>> a2 = com.mbridge.msdk.mbnative.a.f.a(i2); if (this.x) { if (a2 == null || !a(a(1, d(a2.b(this.j, this.t))))) { String str2 = e; w.b(str2, "isGetApiReulst = " + this.aa + " isReturn = " + this.y); a aVar = this.Q; if (aVar != null && !this.aa) { aVar.b(true); } if (this.aa && !this.y) { w.b(str2, "222222"); a("mb load failed", i3, str); } if (!this.ad) { return; } } else { return; } } else if (!(i2 == 1 || a2 == null || !a(a(i2, d(a2.b(this.j, this.t)))))) { return; } } int i4 = this.u; if (i4 == -1) { this.u = i2; } else if (i4 != i2) { this.v = 0; } com.mbridge.msdk.foundation.db.f.a(i.a(this.i)).a(); String str3 = e; w.b(str3, "START LOAD MB MVNATIVE"); com.mbridge.msdk.mbnative.e.a.a aVar2 = new com.mbridge.msdk.mbnative.e.a.a(this.i); com.mbridge.msdk.foundation.same.net.g.d dVar = new com.mbridge.msdk.foundation.same.net.g.d(); String k2 = com.mbridge.msdk.foundation.controller.a.f().k(); String l2 = com.mbridge.msdk.foundation.controller.a.f().l(); Map<String, Object> map = this.d; if (map != null && map.containsKey("app_id") && this.d.containsKey(MBridgeConstans.APP_KEY) && this.d.containsKey(MBridgeConstans.KEY_WORD) && this.d.get(MBridgeConstans.KEY_WORD) != null) { String str4 = null; if (this.d.get("app_id") instanceof String) { k2 = (String) this.d.get("app_id"); } if (this.d.get(MBridgeConstans.APP_KEY) instanceof String) { l2 = (String) this.d.get(MBridgeConstans.APP_KEY); } if (this.d.get(MBridgeConstans.KEY_WORD) instanceof String) { str4 = (String) this.d.get(MBridgeConstans.KEY_WORD); } if (!TextUtils.isEmpty(str4)) { dVar.a("smart", r.a(str4)); } } dVar.a("app_id", k2); dVar.a(MBridgeConstans.PROPERTIES_UNIT_ID, this.j); if (!TextUtils.isEmpty(this.k)) { dVar.a(MBridgeConstans.PLACEMENT_ID, this.k); } dVar.a("req_type", "2"); if (!TextUtils.isEmpty(this.w)) { dVar.a("category", this.w); } dVar.a("sign", SameMD5.getMD5(k2 + l2)); if (this.Z <= 0 || i3 != 0) { dVar.a("ad_num", this.s + ""); } else { dVar.a("ad_num", this.Z + ""); } String e2 = aa.e(this.j); if (!TextUtils.isEmpty(e2)) { dVar.a("j", e2); } dVar.a("only_impression", "1"); dVar.a("ping_mode", "1"); if (this.E != 0) { dVar.a("frame_num", this.E + ""); } if (!TextUtils.isEmpty(this.n)) { dVar.a(MBridgeConstans.NATIVE_INFO, this.n); if (i2 == 1 && !com.mbridge.msdk.click.b.a) { dVar.a("tnum", this.M + ""); } } else if (i2 == 1 && !com.mbridge.msdk.click.b.a) { dVar.a("tnum", this.s + ""); } if (i2 == 1 && !TextUtils.isEmpty(this.N)) { dVar.a("ttc_ids", this.N); } String a3 = com.mbridge.msdk.foundation.same.a.d.a(this.j, "native"); if (!TextUtils.isEmpty(a3)) { dVar.a(com.mbridge.msdk.foundation.same.net.g.d.b, a3); } if (Build.VERSION.SDK_INT >= 14) { if (this.d.containsKey(MBridgeConstans.NATIVE_VIDEO_WIDTH) && (this.d.get(MBridgeConstans.NATIVE_VIDEO_WIDTH) instanceof Integer)) { dVar.a("video_width", ((Integer) this.d.get(MBridgeConstans.NATIVE_VIDEO_WIDTH)).intValue() + ""); } if (this.d.containsKey(MBridgeConstans.NATIVE_VIDEO_HEIGHT) && (this.d.get(MBridgeConstans.NATIVE_VIDEO_HEIGHT) instanceof Integer)) { dVar.a("video_height", ((Integer) this.d.get(MBridgeConstans.NATIVE_VIDEO_HEIGHT)).intValue() + ""); } if (this.d.containsKey(MBridgeConstans.NATIVE_VIDEO_SUPPORT) && (this.d.get(MBridgeConstans.NATIVE_VIDEO_SUPPORT) instanceof Boolean)) { ((Boolean) this.d.get(MBridgeConstans.NATIVE_VIDEO_SUPPORT)).booleanValue(); } dVar.a("video_version", MBridgeConstans.NATIVE_VIDEO_VERSION); } if (com.mbridge.msdk.c.b.a().b(com.mbridge.msdk.foundation.controller.a.f().k()) == null) { com.mbridge.msdk.c.b.a().b(); } if (!a(this.d)) { w.b(str3, "没有param 参数 要传fqci"); JSONArray a4 = aa.a(this.i, this.j); if (a4.length() > 0) { dVar.a(com.mbridge.msdk.foundation.same.net.g.d.c, aa.a(a4)); } } JSONArray jSONArray = new JSONArray(); List<Long> i5 = com.mbridge.msdk.foundation.controller.a.f().i(); if (i5 != null && i5.size() > 0) { for (Long l3 : i5) { jSONArray.put(l3.longValue()); } } if (jSONArray.length() > 0) { dVar.a("install_ids", aa.a(jSONArray)); } if (b.b().containsKey(this.j) && b.b().get(this.j).booleanValue() && b.c().get(this.j) != null && (mVar = b.c().get(this.j)) != null) { if (i2 == 1) { this.v = mVar.b(); } else if (i2 == 2) { this.v = mVar.a(); } } dVar.a(TypedValues.CycleType.S_WAVE_OFFSET, this.v + ""); dVar.a("ad_type", "42"); dVar.a(CampaignEx.JSON_KEY_AD_SOURCE_ID, i2 + ""); if (!TextUtils.isEmpty(this.q)) { dVar.a(com.mbridge.msdk.foundation.same.net.g.d.a, this.q); } a aVar3 = new a(); aVar3.a(b(this.d)); aVar3.d = this.j; aVar3.e = this.k; aVar3.f = 42; if (i2 != 1 || this.x) { aVar3.b(true); } else { this.Q = aVar3; aVar3.b(false); } c cVar = new c(1, aVar3, i3, str); aVar3.a(cVar); aVar3.g(i3); aVar3.a(str); if (i3 == 0) { if (!TextUtils.isEmpty(str)) { dVar.a("token", str); } aVar2.a(1, dVar, aVar3, str); } if (i3 == 1) { aVar2.b(1, com.mbridge.msdk.foundation.same.net.f.d.a().m, dVar, aVar3); } this.o.postDelayed(cVar, j2); } catch (Exception e3) { String str5 = e; w.d(str5, com.mbridge.msdk.mbnative.b.a.a(e3)); w.d(str5, e3.getMessage()); } return; } public final void a(Campaign campaign, View view, List<View> list) { try { if (campaign.getType() != 3) { NativeListener.NativeTrackingListener nativeTrackingListener = this.h; if (nativeTrackingListener != null) { this.r.a(nativeTrackingListener); } com.mbridge.msdk.mbnative.a.f.a(campaign.getType()).a(this.j, campaign, this.V); final CampaignEx campaignEx = (CampaignEx) campaign; Class<?> cls = null; try { cls = Class.forName("com.mbridge.msdk.nativex.view.MBMediaView"); } catch (Throwable unused) { w.d("", "MBMediaView can't found"); } com.mbridge.msdk.foundation.same.a.d.a(this.j, campaignEx, "native"); if (campaignEx != null) { if (view != null) { if (cls == null || !cls.isInstance(view)) { view.setOnClickListener(new com.mbridge.msdk.widget.a() { /* class com.mbridge.msdk.mbnative.controller.NativeController.AnonymousClass1 */ /* access modifiers changed from: protected */ @Override // com.mbridge.msdk.widget.a public final void a(View view) { NativeController.a(NativeController.this, view.getContext(), campaignEx); } }); } else { return; } } if (list != null && list.size() > 0) { for (View view2 : list) { if (cls != null && cls.isInstance(view2)) { break; } view2.setOnClickListener(new com.mbridge.msdk.widget.a() { /* class com.mbridge.msdk.mbnative.controller.NativeController.AnonymousClass8 */ /* access modifiers changed from: protected */ @Override // com.mbridge.msdk.widget.a public final void a(View view) { NativeController.a(NativeController.this, view.getContext(), campaignEx); } }); } } if (!campaignEx.isReport()) { a(campaignEx, view, list); String str = e; Log.e(str, "sendImpression" + campaignEx); } } } } catch (Exception unused2) { w.d(e, "registerview exception!"); } } /* access modifiers changed from: private */ /* access modifiers changed from: public */ private void a(CampaignEx campaignEx) { if (!campaignEx.isReportClick()) { campaignEx.setReportClick(true); if (campaignEx != null && campaignEx.getNativeVideoTracking() != null && campaignEx.getNativeVideoTracking().h() != null) { com.mbridge.msdk.click.b.a(this.i, campaignEx, campaignEx.getCampaignUnitId(), campaignEx.getNativeVideoTracking().h(), false, false); } } } public final void a(Campaign campaign, View view) { try { if (campaign.getType() != 3) { NativeListener.NativeTrackingListener nativeTrackingListener = this.h; if (nativeTrackingListener != null) { this.r.a(nativeTrackingListener); } com.mbridge.msdk.mbnative.a.f.a(campaign.getType()).a(this.j, campaign, this.V); final CampaignEx campaignEx = (CampaignEx) campaign; com.mbridge.msdk.foundation.same.a.d.a(this.j, campaignEx, "native"); if (campaignEx != null) { AnonymousClass10 r0 = new com.mbridge.msdk.widget.a() { /* class com.mbridge.msdk.mbnative.controller.NativeController.AnonymousClass10 */ /* access modifiers changed from: protected */ @Override // com.mbridge.msdk.widget.a public final void a(View view) { NativeController.a(NativeController.this, view.getContext(), campaignEx); } }; try { a(view, r0, Class.forName("com.mbridge.msdk.nativex.view.MBMediaView")); } catch (Throwable unused) { a(view, r0, (Class) null); } if (!campaignEx.isReport()) { ArrayList arrayList = new ArrayList(); arrayList.add(view); a(campaignEx, view, (List<View>) arrayList); String str = e; w.b(str, "sendImpression" + campaignEx); } } } } catch (Exception unused2) { w.d(e, "registerview exception!"); } } private AdSession b(CampaignEx campaignEx) { if (this.L == null) { this.L = new Hashtable<>(); } String requestIdNotice = campaignEx.getRequestIdNotice(); AdSession adSession = this.L.get(requestIdNotice); if (adSession == null && campaignEx.isActiveOm()) { adSession = com.mbridge.msdk.a.b.a(this.i, true, campaignEx.getOmid(), campaignEx.getRequestId(), campaignEx.getId(), this.j, "", campaignEx.getRequestIdNotice()); } if (adSession != null) { this.L.put(requestIdNotice, adSession); } return adSession; } private void a(CampaignEx campaignEx, View view, List<View> list) { AdSession adSession = null; try { if (!(this.i == null || campaignEx == null || (adSession = b(campaignEx)) == null)) { adSession.registerAdView(view); adSession.start(); } com.mbridge.msdk.c.d dVar = this.W; int d2 = dVar != null ? dVar.d() : 0; final f fVar = new f(campaignEx, view, list, this, adSession); if (this.f116K == null) { this.f116K = new CopyOnWriteArrayList<>(); } this.f116K.add(fVar); fVar.setonStateChangeListener(new a.b() { /* class com.mbridge.msdk.mbnative.controller.NativeController.AnonymousClass11 */ @Override // com.mbridge.msdk.foundation.same.e.a.b public final void a(a.EnumC0206a aVar) { if (aVar == a.EnumC0206a.FINISH && NativeController.this.f116K != null && NativeController.this.f116K.size() > 0 && NativeController.this.f116K.contains(fVar)) { NativeController.this.f116K.remove(fVar); } } }); e eVar = this.o; if (eVar != null) { eVar.postDelayed(fVar, (long) (d2 * 1000)); } } catch (Exception e2) { w.d(e, com.mbridge.msdk.mbnative.b.a.a(e2)); } } private void a(View view, View.OnClickListener onClickListener, Class cls) { if (view == null || onClickListener == null) { w.d("", "traverseView subview or mOnClickListener is null"); return; } if (cls != null) { try { if (cls.isInstance(view)) { return; } } catch (Throwable unused) { w.d("", "traverseView failed"); return; } } view.setOnClickListener(onClickListener); if (view instanceof ViewGroup) { ViewGroup viewGroup = (ViewGroup) view; for (int i2 = 0; i2 < viewGroup.getChildCount(); i2++) { a(viewGroup.getChildAt(i2), onClickListener, cls); } } } /* access modifiers changed from: private */ public static class f extends com.mbridge.msdk.foundation.same.e.a { private CampaignEx a; private WeakReference<View> b; private WeakReference<List<View>> c; private WeakReference<NativeController> d; private WeakReference<AdSession> e; @Override // com.mbridge.msdk.foundation.same.e.a public final void cancelTask() { } @Override // com.mbridge.msdk.foundation.same.e.a public final void pauseTask(boolean z) { } public f(CampaignEx campaignEx, View view, List<View> list, NativeController nativeController, AdSession adSession) { this.a = campaignEx; this.b = new WeakReference<>(view); this.c = new WeakReference<>(list); this.d = new WeakReference<>(nativeController); this.e = new WeakReference<>(adSession); } @Override // com.mbridge.msdk.foundation.same.e.a public final void runTask() { WeakReference<View> weakReference; w.d(NativeController.e, "waitSomeTimeToReport run"); try { if (this.d != null && (weakReference = this.b) != null && this.c != null) { View view = weakReference.get(); List<View> list = this.c.get(); NativeController nativeController = this.d.get(); AdSession adSession = null; WeakReference<AdSession> weakReference2 = this.e; if (weakReference2 != null) { adSession = weakReference2.get(); } if (view != null && nativeController != null) { NativeController.a(nativeController, this.a, view, list, adSession); } } } catch (Exception e2) { w.d(NativeController.e, com.mbridge.msdk.mbnative.b.a.a(e2)); } } } public final void b(Campaign campaign, View view) { b(campaign, view, (List<View>) null); } public final void b(Campaign campaign, View view, List<View> list) { if (campaign != null) { int type = campaign.getType(); if (type == 1 || type == 2) { Class<?> cls = null; try { cls = Class.forName("com.mbridge.msdk.nativex.view.MBMediaView"); } catch (Throwable unused) { } if (list != null && list.size() > 0) { for (View view2 : list) { a(view2, cls); } } else if (view != null) { a(view, cls); } } } } private void a(View view, Class cls) { if (view == null) { try { w.d("", "traverseView subview is null"); } catch (Throwable unused) { w.d("", "traverseView failed"); } } else if (cls == null || !cls.isInstance(view)) { view.setOnClickListener(null); if (view instanceof ViewGroup) { ViewGroup viewGroup = (ViewGroup) view; for (int i2 = 0; i2 < viewGroup.getChildCount(); i2++) { a(viewGroup.getChildAt(i2), cls); } } } } public final void a() { com.mbridge.msdk.foundation.same.e.a next; com.mbridge.msdk.foundation.same.e.b bVar = this.G; if (bVar != null) { bVar.a(); this.G = null; } Hashtable<String, AdSession> hashtable = this.L; if (hashtable != null) { for (AdSession adSession : hashtable.values()) { if (adSession != null) { adSession.finish(); } } this.L.clear(); } e eVar = this.o; if (eVar != null) { eVar.removeCallbacksAndMessages(null); } this.h = null; this.r.a(); try { Context context = this.i; if (context != null) { com.mbridge.msdk.foundation.same.c.b.a(context).c(); } List<a> list = this.I; if (list != null && list.size() > 0) { for (a aVar : this.I) { aVar.a(); } this.I.clear(); this.I = null; } List<a.AbstractC0220a> list2 = this.J; if (list2 != null && list2.size() > 0) { for (a.AbstractC0220a aVar2 : this.J) { } this.J.clear(); this.J = null; } CopyOnWriteArrayList<com.mbridge.msdk.foundation.same.e.a> copyOnWriteArrayList = this.f116K; if (copyOnWriteArrayList != null && copyOnWriteArrayList.size() > 0) { Iterator<com.mbridge.msdk.foundation.same.e.a> it = this.f116K.iterator(); if (it.hasNext() && (next = it.next()) != null) { next.cancel(); this.o.removeCallbacks(next); } this.f116K.clear(); } } catch (Exception unused) { } } public class c implements Runnable { private int b; private com.mbridge.msdk.foundation.same.e.c c; private int d; private String e; public c(int i, com.mbridge.msdk.foundation.same.e.c cVar, int i2, String str) { this.b = i; this.c = cVar; this.d = i2; this.e = str; } public final void run() { String str = NativeController.e; w.b(str, "cancel task adsource is = " + this.b); this.c.a(true); int i = this.b; if (i == 1) { NativeController.this.aa = true; if (NativeController.this.x || this.d == 1) { NativeController.this.a("REQUEST_TIMEOUT", this.d, this.e); } } else if (i == 2) { if (!NativeController.this.y || this.d == 1) { NativeController.this.a("REQUEST_TIMEOUT", this.d, this.e); } } } } public class a extends com.mbridge.msdk.mbnative.e.a.b implements com.mbridge.msdk.foundation.same.e.c { private boolean b = false; private Runnable c; private boolean g = true; private List<String> h = null; public a() { } public final void b(boolean z) { this.g = z; } @Override // com.mbridge.msdk.foundation.same.e.c public final void a(boolean z) { this.b = z; } public final void a(List<String> list) { this.h = list; } @Override // com.mbridge.msdk.mbnative.e.a.b public final void a(List<com.mbridge.msdk.foundation.same.net.c.b> list, CampaignUnit campaignUnit) { int i = 1; NativeController.this.aa = true; l a2 = l.a(i.a(NativeController.this.i)); a2.b(); if (this.c != null) { w.b(NativeController.e, "REMOVE CANCEL TASK ON SUCCESS"); NativeController.this.o.removeCallbacks(this.c); } w.d(NativeController.e, "onSuccess"); aa.a((List<CampaignEx>) campaignUnit.getAds()); int i2 = 0; if (campaignUnit == null || campaignUnit.getAds() == null || campaignUnit.getAds().size() <= 0) { this.d = "0_" + this.d; b.b(NativeController.this.u, this.d); NativeController.this.v = 0; return; } NativeController.this.q = campaignUnit.getSessionId(); ArrayList arrayList = new ArrayList(); ArrayList arrayList2 = new ArrayList(); ArrayList arrayList3 = new ArrayList(); if (NativeController.this.Y <= 0) { if (NativeController.this.Y == -3) { NativeController.this.Y = campaignUnit.getAds().size(); } else { NativeController nativeController = NativeController.this; nativeController.Y = nativeController.t; } if (NativeController.this.ab != 0 && campaignUnit.getTemplate() == 2) { NativeController nativeController2 = NativeController.this; nativeController2.Y = nativeController2.ab; } if (NativeController.this.ac != 0 && campaignUnit.getTemplate() == 3) { NativeController nativeController3 = NativeController.this; nativeController3.Y = nativeController3.ac; } } boolean z = false; for (int i3 = 0; i3 < campaignUnit.getAds().size(); i3++) { CampaignEx campaignEx = campaignUnit.getAds().get(i3); campaignEx.setCampaignUnitId(this.d); if (!TextUtils.isEmpty(NativeController.this.V)) { campaignEx.setBidToken(NativeController.this.V); campaignEx.setIsBidCampaign(true); } if (NativeController.B) { campaignEx.loadIconUrlAsyncWithBlock(null); campaignEx.loadImageUrlAsyncWithBlock(null); } if (campaignEx != null) { boolean c2 = aa.c(NativeController.this.i, campaignEx.getPackageName()); if (c2 && com.mbridge.msdk.foundation.controller.a.e() != null) { com.mbridge.msdk.foundation.controller.a.e().add(new com.mbridge.msdk.foundation.entity.i(campaignEx.getId(), campaignEx.getPackageName())); z = true; } if (i3 < NativeController.this.t && campaignEx.getOfferType() != 99) { if (aa.b(campaignEx)) { campaignEx.setRtinsType(c2 ? 1 : 2); } if (campaignEx.getWtick() == 1 || !c2) { arrayList.add(campaignEx); if (!TextUtils.isEmpty(campaignEx.getVideoUrlEncode())) { arrayList3.add(campaignEx); } } else if (aa.b(campaignEx)) { arrayList.add(campaignEx); if (!TextUtils.isEmpty(campaignEx.getVideoUrlEncode())) { arrayList3.add(campaignEx); } } else { aa.a(this.d, campaignEx, com.mbridge.msdk.foundation.same.a.D); } } if (i3 < NativeController.this.Y && campaignEx.getOfferType() != 99) { if (aa.b(campaignEx)) { campaignEx.setRtinsType(c2 ? 1 : 2); } if (!c2) { arrayList2.add(campaignEx); } else if (aa.b(campaignEx)) { arrayList2.add(campaignEx); } } if (!a2.a(campaignEx.getId())) { h hVar = new h(); hVar.a(campaignEx.getId()); hVar.a(campaignEx.getFca()); hVar.b(campaignEx.getFcb()); hVar.d(0); hVar.c(0); hVar.a(System.currentTimeMillis()); a2.a(hVar); } } } NativeController.b(NativeController.this, arrayList3); if (z) { com.mbridge.msdk.foundation.controller.a.f().h(); } int type = campaignUnit.getAds().get(0) != null ? campaignUnit.getAds().get(0).getType() : 1; com.mbridge.msdk.mbnative.a.b<String, List<Campaign>> a3 = com.mbridge.msdk.mbnative.a.f.a(type); if (a3 != null) { a3.a(this.d, arrayList2, NativeController.this.V); } if (arrayList.size() != 0) { if (NativeController.this.x || type != 1) { NativeController nativeController4 = NativeController.this; nativeController4.a((NativeController) nativeController4.a((NativeController) type, (int) nativeController4.d((NativeController) arrayList))); } if (!NativeController.this.y && NativeController.this.z && !NativeController.this.x) { NativeController nativeController5 = NativeController.this; nativeController5.a((NativeController) nativeController5.a((NativeController) type, (int) nativeController5.d((NativeController) arrayList))); } if (!b.b().containsKey(this.d) || !b.b().get(this.d).booleanValue()) { if (b.e().containsKey(this.d)) { i = b.e().get(this.d).intValue(); } int i4 = NativeController.this.t + NativeController.this.v; if (i4 <= i) { i2 = i4; } NativeController.this.v = i2; return; } b.a(NativeController.this.u, this.d); } else if (NativeController.this.x || type != 1) { NativeController.this.a("APP ALREADY INSTALLED", g(), f()); } } @Override // com.mbridge.msdk.mbnative.e.a.b public final void a(int i, String str) { NativeController.this.aa = true; if (!this.b) { if (i == -1) { b.b(NativeController.this.u, this.d); NativeController.this.v = 0; } if (this.c != null) { w.b(NativeController.e, "REMOVE CANCEL TASK ON onFailed"); NativeController.this.o.removeCallbacks(this.c); } if (NativeController.this.y) { return; } if (g() == 1 || this.g) { NativeController.this.a(str, g(), f()); } } else if (!NativeController.this.y && this.g) { w.b(NativeController.e, "onFailed onnative fail"); NativeController.this.a(str, g(), f()); } } public final void a(Runnable runnable) { this.c = runnable; } @Override // com.mbridge.msdk.mbnative.e.a.b public final void b(List<Frame> list) { if (!this.b) { if (this.c != null) { w.b(NativeController.e, "REMOVE CANCEL TASK ON onAdLoaded"); NativeController.this.o.removeCallbacks(this.c); } if (list != null && list.size() != 0) { for (Frame frame : list) { List<CampaignEx> campaigns = frame.getCampaigns(); if (campaigns != null && campaigns.size() != 0) { for (CampaignEx campaignEx : campaigns) { if (NativeController.B) { campaignEx.loadImageUrlAsyncWithBlock(null); campaignEx.loadIconUrlAsyncWithBlock(null); } } } else if (NativeController.this.g != null) { NativeController.this.y = true; NativeController.this.g.onAdLoadError("ads in frame is empty"); return; } else { return; } } if (NativeController.this.g != null) { NativeController.this.g.onAdFramesLoaded(list); } } else if (NativeController.this.g != null) { NativeController.this.y = true; NativeController.this.g.onAdLoadError("frame is empty"); } } } } public final List<Campaign> b(String str, int i2, String str2) { int i3; int i4; List<Campaign> list = null; if (this.a != null) { ArrayList arrayList = new ArrayList(this.a); for (int i5 = 0; i5 < arrayList.size(); i5++) { com.mbridge.msdk.mbnative.a.b<String, List<Campaign>> a2 = com.mbridge.msdk.mbnative.a.f.a(((Integer) arrayList.get(i5)).intValue()); if (a2 != null) { if ((((Integer) arrayList.get(i5)).intValue() == 1 || ((Integer) arrayList.get(i5)).intValue() == 2) && this.d.containsKey(MBridgeConstans.NATIVE_INFO)) { i4 = this.M; } else { i4 = this.s; } list = a(((Integer) arrayList.get(i5)).intValue(), a2.b(str, i4)); if (list != null) { break; } } } if (list == null) { for (int i6 = 0; i6 < arrayList.size(); i6++) { com.mbridge.msdk.mbnative.a.b<String, List<Campaign>> a3 = com.mbridge.msdk.mbnative.a.f.a(((Integer) arrayList.get(i6)).intValue()); if ((((Integer) arrayList.get(i6)).intValue() == 1 || ((Integer) arrayList.get(i6)).intValue() == 2) && this.d.containsKey(MBridgeConstans.NATIVE_INFO)) { i3 = this.M; } else { i3 = this.s; } list = a(((Integer) arrayList.get(i6)).intValue(), a3.a(str, i3)); if (list != null) { break; } } } } return d(list); } /* access modifiers changed from: private */ /* access modifiers changed from: public */ private boolean a(final List<Campaign> list) { if (!(TextUtils.isEmpty(this.V) || list == null || list.size() != 0) || list == null || list.size() <= 0) { return false; } final com.mbridge.msdk.mbnative.c.a aVar = this.g; if (aVar == null) { return true; } CampaignEx campaignEx = (CampaignEx) list.get(0); final int template = campaignEx != null ? campaignEx.getTemplate() : 2; l a2 = l.a(i.a(this.i)); a2.b(); for (int i2 = 0; i2 < list.size(); i2++) { CampaignEx campaignEx2 = (CampaignEx) list.get(i2); if (!a2.a(campaignEx2.getId())) { h hVar = new h(); hVar.a(campaignEx2.getId()); hVar.a(campaignEx2.getFca()); hVar.b(campaignEx2.getFcb()); hVar.d(0); hVar.c(0); hVar.a(System.currentTimeMillis()); a2.a(hVar); } } int type = campaignEx.getType(); if (!this.S || !this.R || type == 3 || type == 6 || type == 7) { if (list == null || list.size() <= 0) { a(aVar, "has no ads"); return true; } for (Campaign campaign : list) { campaign.setVideoLength(0); } a(list, template, aVar); return true; } else if (e().h() == 3) { final List<Campaign> b2 = b(list); if (list == null || list.size() <= 0) { a(aVar, "has no ads"); return true; } a(list, new b() { /* class com.mbridge.msdk.mbnative.controller.NativeController.AnonymousClass13 */ @Override // com.mbridge.msdk.mbnative.controller.NativeController.b public final void a() { List a2 = NativeController.a(NativeController.this, b2, true); if (a2 == null || a2.size() <= 0) { NativeController.this.a((NativeController) aVar, (NativeListener.NativeAdListener) "has no ads"); } else { NativeController.this.a((NativeController) a2, (List) template, (int) aVar); } } }); return true; } else { List<Campaign> c2 = c(list); if (c2 == null || c2.size() <= 0) { a(list, template, aVar); return true; } a(c2, new b() { /* class com.mbridge.msdk.mbnative.controller.NativeController.AnonymousClass14 */ @Override // com.mbridge.msdk.mbnative.controller.NativeController.b public final void a() { List a2 = NativeController.a(NativeController.this, list, false); if (a2 == null || a2.size() <= 0) { NativeController.this.a((NativeController) aVar, (NativeListener.NativeAdListener) "has no ads"); } else { NativeController.this.a((NativeController) a2, (List) template, (int) aVar); } } }); return true; } } /* access modifiers changed from: private */ /* access modifiers changed from: public */ private void a(final List<Campaign> list, final int i2, final NativeListener.NativeAdListener nativeAdListener) { this.o.post(new Runnable() { /* class com.mbridge.msdk.mbnative.controller.NativeController.AnonymousClass15 */ public final void run() { List list = list; if (list != null && list.size() > 0) { NativeController.this.T = ((CampaignEx) list.get(0)).getRequestId(); } NativeController.this.y = true; nativeAdListener.onAdLoaded(list, i2); com.mbridge.msdk.mbnative.d.a.a(NativeController.this.i, list, NativeController.this.j); } }); } /* access modifiers changed from: private */ /* access modifiers changed from: public */ private void a(final NativeListener.NativeAdListener nativeAdListener, final String str) { this.o.post(new Runnable() { /* class com.mbridge.msdk.mbnative.controller.NativeController.AnonymousClass2 */ public final void run() { nativeAdListener.onAdLoadError(str); } }); } /* access modifiers changed from: private */ /* access modifiers changed from: public */ private List<Campaign> a(int i2, List<Campaign> list) { int i3; int i4; int i5 = 1; if (i2 != 1 || !this.d.containsKey(MBridgeConstans.NATIVE_INFO) || list == null || list.size() <= 0) { return list; } CampaignEx campaignEx = (CampaignEx) list.get(0); if (campaignEx != null) { i5 = campaignEx.getTemplate(); } if (i5 != 2) { return (i5 != 3 || list == null || list.size() < (i3 = this.ac)) ? list : list.subList(0, i3); } if (list == null || list.size() < (i4 = this.ab)) { return list; } return list.subList(0, i4); } private void a(final long j2, final int i2, final boolean z2, final String str, final String str2) { final UUID D2 = s.D(); if (D2 == null) { Map<String, Boolean> map = this.H; map.put(str + "_" + z2 + "_ttc", false); Map<String, Boolean> map2 = this.H; map2.put(str + "_" + z2 + "_post", false); } else { Map<String, Boolean> map3 = this.H; map3.put(D2 + str + "_" + z2 + "_ttc", false); Map<String, Boolean> map4 = this.H; map4.put(D2 + str + "_" + z2 + "_post", false); } final AnonymousClass3 r14 = new com.mbridge.msdk.foundation.same.e.a() { /* class com.mbridge.msdk.mbnative.controller.NativeController.AnonymousClass3 */ @Override // com.mbridge.msdk.foundation.same.e.a public final void cancelTask() { } @Override // com.mbridge.msdk.foundation.same.e.a public final void pauseTask(boolean z) { } @Override // com.mbridge.msdk.foundation.same.e.a public final void runTask() { if (NativeController.this.O == null) { NativeController nativeController = NativeController.this; nativeController.O = i.a(nativeController.i); } com.mbridge.msdk.foundation.db.c a2 = com.mbridge.msdk.foundation.db.c.a(NativeController.this.O); a2.a(); NativeController.this.N = a2.a(str); if (NativeController.this.H != null && !NativeController.this.H.isEmpty()) { if (D2 == null) { Map map = NativeController.this.H; if (map.containsKey(str + "_" + z2 + "_ttc")) { Map map2 = NativeController.this.H; map2.put(str + "_" + z2 + "_ttc", true); return; } } if (D2 != null) { Map map3 = NativeController.this.H; if (map3.containsKey(D2 + str + "_" + z2 + "_ttc")) { Map map4 = NativeController.this.H; map4.put(D2 + str + "_" + z2 + "_ttc", true); } } } } }; this.o.postDelayed(new com.mbridge.msdk.foundation.same.e.a() { /* class com.mbridge.msdk.mbnative.controller.NativeController.AnonymousClass4 */ @Override // com.mbridge.msdk.foundation.same.e.a public final void cancelTask() { } @Override // com.mbridge.msdk.foundation.same.e.a public final void pauseTask(boolean z) { } @Override // com.mbridge.msdk.foundation.same.e.a public final void runTask() { boolean z = false; if (NativeController.this.H != null && !NativeController.this.H.isEmpty()) { Map map = NativeController.this.H; if (map.containsKey(str + "_" + z2 + "_ttc")) { Map map2 = NativeController.this.H; z = ((Boolean) map2.get(str + "_" + z2 + "_ttc")).booleanValue(); Map map3 = NativeController.this.H; map3.remove(str + "_" + z2 + "_ttc"); } Map map4 = NativeController.this.H; if (map4.containsKey(D2 + str + "_" + z2 + "_ttc")) { Map map5 = NativeController.this.H; z = ((Boolean) map5.get(D2 + str + "_" + z2 + "_ttc")).booleanValue(); Map map6 = NativeController.this.H; map6.remove(D2 + str + "_" + z2 + "_ttc"); } } if (!z) { NativeController.this.o.post(new Runnable() { /* class com.mbridge.msdk.mbnative.controller.NativeController.AnonymousClass4.AnonymousClass1 */ public final void run() { if (NativeController.this.H != null && !NativeController.this.H.isEmpty()) { Map map = NativeController.this.H; if (map.containsKey(str + "_" + z2 + "_post")) { Map map2 = NativeController.this.H; map2.put(str + "_" + z2 + "_post", true); } Map map3 = NativeController.this.H; if (map3.containsKey(D2 + str + "_" + z2 + "_post")) { Map map4 = NativeController.this.H; map4.put(D2 + str + "_" + z2 + "_post", true); } } if (z2) { NativeController.this.x = true; } else { NativeController.this.x = false; } if (NativeController.this.G != null) { NativeController.this.G.a(r14); } NativeController.this.a(1, j2, i2, str2); } }); } } }, 90000); AnonymousClass5 r9 = new a.b() { /* class com.mbridge.msdk.mbnative.controller.NativeController.AnonymousClass5 */ @Override // com.mbridge.msdk.foundation.same.e.a.b public final void a(a.EnumC0206a aVar) { if (aVar == a.EnumC0206a.FINISH) { NativeController.this.o.post(new Runnable() { /* class com.mbridge.msdk.mbnative.controller.NativeController.AnonymousClass5.AnonymousClass1 */ public final void run() { if (z2) { NativeController.this.x = true; } boolean z = false; if (NativeController.this.H != null && !NativeController.this.H.isEmpty()) { Map map = NativeController.this.H; if (map.containsKey(str + "_" + z2 + "_post")) { Map map2 = NativeController.this.H; z = ((Boolean) map2.get(str + "_" + z2 + "_post")).booleanValue(); Map map3 = NativeController.this.H; map3.remove(str + "_" + z2 + "_post"); } Map map4 = NativeController.this.H; if (map4.containsKey(D2 + str + "_" + z2 + "_post")) { Map map5 = NativeController.this.H; z = ((Boolean) map5.get(D2 + str + "_" + z2 + "_post")).booleanValue(); Map map6 = NativeController.this.H; map6.remove(D2 + str + "_" + z2 + "_post"); } } if (!z) { NativeController.this.a(1, j2, i2, str2); } } }); } } }; if (this.G == null) { this.G = new com.mbridge.msdk.foundation.same.e.b(this.i); } com.mbridge.msdk.foundation.same.e.b bVar = this.G; if (bVar != null) { bVar.a(r14, r9); } } public static boolean a(Map<String, Object> map) { if (map != null) { try { if (map.containsKey("app_id") && map.containsKey(MBridgeConstans.APP_KEY) && map.containsKey(MBridgeConstans.KEY_WORD) && map.get(MBridgeConstans.KEY_WORD) != null) { w.b(e, "有smart 参数"); return true; } } catch (Exception e2) { w.d(e, com.mbridge.msdk.mbnative.b.a.a(e2)); } } w.b(e, "木有smart 参数"); return false; } public static List<String> b(Map<String, Object> map) { Exception e2; ArrayList arrayList = null; try { if (!(map.get(MBridgeConstans.KEY_WORD) instanceof String)) { return null; } String str = (String) map.get(MBridgeConstans.KEY_WORD); if (TextUtils.isEmpty(str)) { return null; } JSONArray jSONArray = new JSONArray(str); if (jSONArray.length() == 0) { return null; } ArrayList arrayList2 = new ArrayList(); for (int i2 = 0; i2 < jSONArray.length(); i2++) { try { JSONObject optJSONObject = jSONArray.optJSONObject(i2); if (optJSONObject != null) { String optString = optJSONObject.optString("p"); if (!TextUtils.isEmpty(optString)) { arrayList2.add(optString); } } } catch (Exception e3) { e2 = e3; arrayList = arrayList2; w.d(e, com.mbridge.msdk.mbnative.b.a.a(e2)); return arrayList; } } return arrayList2; } catch (Exception e4) { e2 = e4; w.d(e, com.mbridge.msdk.mbnative.b.a.a(e2)); return arrayList; } } /* access modifiers changed from: private */ public static class d implements H5DownLoadManager.IH5SourceDownloadListener { private String a; private CampaignEx b; private long c = System.currentTimeMillis(); private boolean d = true; public d(String str, CampaignEx campaignEx, boolean z) { this.a = str; this.b = campaignEx; this.d = z; } @Override // com.mbridge.msdk.foundation.download.download.H5DownLoadManager.H5ResDownloadListerInter public final void onSuccess(String str) { try { if (this.d) { long currentTimeMillis = System.currentTimeMillis() - this.c; t.a(i.a(com.mbridge.msdk.foundation.controller.a.f().j())); p pVar = new p("2000043", 20, currentTimeMillis + "", str, this.b.getId(), this.a, "", "2"); CampaignEx campaignEx = this.b; if (campaignEx != null && !TextUtils.isEmpty(campaignEx.getId())) { pVar.n(this.b.getId()); } CampaignEx campaignEx2 = this.b; if (campaignEx2 != null) { pVar.b(campaignEx2.getAdSpaceT()); pVar.k(this.b.getRequestId()); pVar.l(this.b.getRequestIdNotice()); } pVar.h("1"); com.mbridge.msdk.foundation.same.report.c.a(pVar, this.a); } } catch (Exception e) { w.d(NativeController.e, com.mbridge.msdk.mbnative.b.a.a(e)); } } @Override // com.mbridge.msdk.foundation.download.download.H5DownLoadManager.H5ResDownloadListerInter public final void onFailed(String str, String str2) { try { if (this.d) { long currentTimeMillis = System.currentTimeMillis() - this.c; t.a(i.a(com.mbridge.msdk.foundation.controller.a.f().j())); p pVar = new p("2000043", 21, currentTimeMillis + "", str, this.b.getId(), this.a, str2, "2"); pVar.k(this.b.getRequestId()); pVar.l(this.b.getRequestIdNotice()); CampaignEx campaignEx = this.b; if (campaignEx != null && !TextUtils.isEmpty(campaignEx.getId())) { pVar.n(this.b.getId()); } CampaignEx campaignEx2 = this.b; if (campaignEx2 != null) { pVar.b(campaignEx2.getAdSpaceT()); } pVar.h("1"); com.mbridge.msdk.foundation.same.report.c.a(pVar, this.a); } } catch (Exception e) { w.d(NativeController.e, com.mbridge.msdk.mbnative.b.a.a(e)); } } } /* access modifiers changed from: private */ public static final class g implements H5DownLoadManager.ZipDownloadListener { String a; CampaignEx b; private long c = System.currentTimeMillis(); private boolean d = true; public g(String str, CampaignEx campaignEx, boolean z) { this.a = str; this.b = campaignEx; this.d = z; } @Override // com.mbridge.msdk.foundation.download.download.H5DownLoadManager.H5ResDownloadListerInter public final void onSuccess(String str) { try { if (this.d) { long currentTimeMillis = System.currentTimeMillis() - this.c; t.a(i.a(com.mbridge.msdk.foundation.controller.a.f().j())); p pVar = new p("2000043", 14, currentTimeMillis + "", str, this.b.getId(), this.a, "", "1"); CampaignEx campaignEx = this.b; if (campaignEx != null && !TextUtils.isEmpty(campaignEx.getId())) { pVar.n(this.b.getId()); } CampaignEx campaignEx2 = this.b; if (campaignEx2 != null) { pVar.b(campaignEx2.getAdSpaceT()); pVar.k(this.b.getRequestId()); pVar.l(this.b.getRequestIdNotice()); } pVar.h("2"); com.mbridge.msdk.foundation.same.report.c.a(pVar, this.a); } } catch (Exception e) { w.d(NativeController.e, com.mbridge.msdk.mbnative.b.a.a(e)); } } @Override // com.mbridge.msdk.foundation.download.download.H5DownLoadManager.H5ResDownloadListerInter public final void onFailed(String str, String str2) { try { if (this.d) { long currentTimeMillis = System.currentTimeMillis() - this.c; t.a(i.a(com.mbridge.msdk.foundation.controller.a.f().j())); p pVar = new p("2000043", 3, currentTimeMillis + "", str2, this.b.getId(), this.a, str, "1"); CampaignEx campaignEx = this.b; if (campaignEx != null && !TextUtils.isEmpty(campaignEx.getId())) { pVar.n(this.b.getId()); } CampaignEx campaignEx2 = this.b; if (campaignEx2 != null) { pVar.b(campaignEx2.getAdSpaceT()); pVar.k(this.b.getRequestId()); pVar.l(this.b.getRequestIdNotice()); } pVar.h("2"); com.mbridge.msdk.foundation.same.report.c.a(pVar, this.a); } } catch (Exception e) { w.d(NativeController.e, com.mbridge.msdk.mbnative.b.a.a(e)); } } } public static void insertExcludeId(String str, CampaignEx campaignEx) { if (!TextUtils.isEmpty(str) && campaignEx != null && com.mbridge.msdk.foundation.controller.a.f().j() != null) { k a2 = k.a(i.a(com.mbridge.msdk.foundation.controller.a.f().j())); com.mbridge.msdk.foundation.entity.g gVar = new com.mbridge.msdk.foundation.entity.g(); gVar.a(System.currentTimeMillis()); gVar.b(str); gVar.a(campaignEx.getId()); a2.a(gVar); } } /* access modifiers changed from: private */ /* access modifiers changed from: public */ private com.mbridge.msdk.c.d e() { com.mbridge.msdk.c.d e2 = com.mbridge.msdk.c.b.a().e("", this.j); this.W = e2; if (e2 == null) { this.W = com.mbridge.msdk.c.d.d(this.j); } return this.W; } private List<Campaign> b(List<Campaign> list) { if (list != null) { CampaignEx campaignEx = null; for (int size = list.size() - 1; size >= 0; size--) { try { campaignEx = (CampaignEx) list.get(size); } catch (Throwable th) { th.printStackTrace(); } if (campaignEx != null && TextUtils.isEmpty(campaignEx.getVideoUrlEncode())) { Campaign remove = list.remove(size); com.mbridge.msdk.mbnative.a.f.a(campaignEx.getType()).a(this.j, remove, this.V); w.a(e, "remove no videoURL ads:" + remove); } } } return list; } private List<Campaign> c(List<Campaign> list) { ArrayList arrayList = null; if (list != null) { for (Campaign campaign : list) { if (campaign instanceof CampaignEx) { CampaignEx campaignEx = (CampaignEx) campaign; if (TextUtils.isEmpty(campaignEx.getImageUrl()) && !TextUtils.isEmpty(campaignEx.getVideoUrlEncode())) { if (arrayList == null) { arrayList = new ArrayList(); } arrayList.add(campaign); } } } } return arrayList; } private void a(final List<Campaign> list, final b bVar) { f(); final long currentTimeMillis = System.currentTimeMillis(); Timer timer = new Timer(); this.U = timer; timer.schedule(new TimerTask() { /* class com.mbridge.msdk.mbnative.controller.NativeController.AnonymousClass7 */ public final void run() { boolean z; w.a(NativeController.e, "search campain status"); if (System.currentTimeMillis() - currentTimeMillis >= 60000) { bVar.a(); NativeController.this.f(); return; } int D = s.D(NativeController.this.i); int k = NativeController.this.e().k(); if (D != 9 && k == 2) { bVar.a(); NativeController.this.f(); } else if (k == 3) { bVar.a(); NativeController.this.f(); } else { loop0: while (true) { z = false; for (Campaign campaign : list) { String id = campaign.getId(); if (campaign instanceof CampaignEx) { StringBuilder sb = new StringBuilder(); sb.append(id); CampaignEx campaignEx = (CampaignEx) campaign; sb.append(campaignEx.getVideoUrlEncode()); sb.append(campaignEx.getBidToken()); id = sb.toString(); } com.mbridge.msdk.videocommon.download.a a2 = com.mbridge.msdk.videocommon.download.b.getInstance().a(NativeController.this.j, id); if (a2 != null && com.mbridge.msdk.videocommon.download.d.a(a2, NativeController.this.e().f())) { z = true; } } break loop0; } if (z) { bVar.a(); NativeController.this.f(); } } } }, 0, 1000); } /* access modifiers changed from: private */ /* access modifiers changed from: public */ private void f() { Timer timer = this.U; if (timer != null) { timer.cancel(); this.U = null; } } /* access modifiers changed from: private */ /* access modifiers changed from: public */ private List<Campaign> d(List<Campaign> list) { if (list == null) { return null; } ArrayList arrayList = new ArrayList(list.size()); ArrayList arrayList2 = new ArrayList(list.size()); for (Campaign campaign : list) { if (campaign instanceof CampaignEx) { CampaignEx campaignEx = (CampaignEx) campaign; if (TextUtils.isEmpty(this.V) && TextUtils.isEmpty(campaignEx.getBidToken()) && !campaignEx.isBidCampaign()) { arrayList2.add(campaignEx); } else if (!TextUtils.isEmpty(this.V) && TextUtils.equals(campaignEx.getBidToken(), this.V)) { arrayList.add(campaign); } } else { arrayList2.add(campaign); } } return TextUtils.isEmpty(this.V) ? arrayList2 : arrayList; } public final String b() { return this.T; } static /* synthetic */ void a(NativeController nativeController, Context context, final CampaignEx campaignEx) { if (campaignEx != null) { try { if (campaignEx.needShowIDialog()) { AnonymousClass9 r6 = new com.mbridge.msdk.widget.dialog.a() { /* class com.mbridge.msdk.mbnative.controller.NativeController.AnonymousClass9 */ @Override // com.mbridge.msdk.widget.dialog.a public final void b() { } @Override // com.mbridge.msdk.widget.dialog.a public final void a() { com.mbridge.msdk.click.b unused = NativeController.this.r; com.mbridge.msdk.click.b.a = false; NativeController.this.r.a(campaignEx, NativeController.this.g); NativeController.this.a((NativeController) campaignEx); } @Override // com.mbridge.msdk.widget.dialog.a public final void c() { a(); } }; if (com.mbridge.msdk.click.c.a(campaignEx) && campaignEx.needShowIDialog()) { if (!nativeController.r.b(campaignEx)) { com.mbridge.msdk.mbjscommon.confirmation.e.a().a("", campaignEx, context, nativeController.j, r6); return; } nativeController.a(campaignEx); nativeController.g.onAdClick(campaignEx); return; } } } catch (Throwable th) { w.a(e, th.getMessage()); } } com.mbridge.msdk.click.b bVar = nativeController.r; com.mbridge.msdk.click.b.a = false; nativeController.r.a(campaignEx, nativeController.g); nativeController.a(campaignEx); } static /* synthetic */ void a(NativeController nativeController, final CampaignEx campaignEx, View view, List list, AdSession adSession) { try { w.d(e, "trackView start"); AnonymousClass12 r0 = new a.AbstractC0220a() { /* class com.mbridge.msdk.mbnative.controller.NativeController.AnonymousClass12 */ @Override // com.mbridge.msdk.mbnative.controller.a.AbstractC0220a public final void a(ArrayList<View> arrayList, ArrayList<View> arrayList2) { w.d(NativeController.e, "trackView onVisibilityChanged"); if (arrayList != null && arrayList.size() > 0) { w.d(NativeController.e, "trackView send"); com.mbridge.msdk.mbnative.d.b.a(campaignEx, NativeController.this.i, NativeController.this.j, NativeController.this.g); } } }; a aVar = new a(list, r0, new Handler(Looper.getMainLooper())); aVar.a(view); List<a> list2 = nativeController.I; if (list2 != null) { list2.add(aVar); } List<a.AbstractC0220a> list3 = nativeController.J; if (list3 != null) { list3.add(r0); } if (adSession != null) { AdEvents.createAdEvents(adSession).impressionOccurred(); } } catch (Exception unused) { } } static /* synthetic */ void b(NativeController nativeController, List list) { if (list != null) { try { if (list.size() > 0) { w.b(e, "===创建下载任务"); try { Class.forName("com.mbridge.msdk.nativex.view.MBMediaView"); Class.forName("com.mbridge.msdk.videocommon.download.b"); Class<?> cls = Class.forName("com.mbridge.msdk.videocommon.download.b"); Class<?> cls2 = Class.forName("com.mbridge.msdk.videocommon.listener.a"); Object invoke = cls.getMethod("getInstance", new Class[0]).invoke(null, new Object[0]); if (invoke != null) { cls.getMethod("createUnitCache", Context.class, String.class, List.class, Integer.TYPE, cls2).invoke(invoke, nativeController.i, nativeController.j, list, 1, null); cls.getMethod(PointCategory.LOAD, String.class).invoke(invoke, nativeController.j); } Iterator it = list.iterator(); while (it.hasNext()) { CampaignEx campaignEx = (CampaignEx) it.next(); if (campaignEx != null && !TextUtils.isEmpty(campaignEx.getImageUrl())) { com.mbridge.msdk.foundation.same.c.b.a(com.mbridge.msdk.foundation.controller.a.f().j()).a(campaignEx.getImageUrl(), new com.mbridge.msdk.foundation.same.c.c() { /* class com.mbridge.msdk.mbnative.controller.NativeController.AnonymousClass6 */ @Override // com.mbridge.msdk.foundation.same.c.c public final void onFailedLoad(String str, String str2) { } @Override // com.mbridge.msdk.foundation.same.c.c public final void onSuccessLoad(Bitmap bitmap, String str) { } }); } try { String str = campaignEx.getendcard_url(); if (!TextUtils.isEmpty(str)) { if (!str.contains(".zip") || !str.contains(ResourceManager.KEY_MD5FILENAME)) { H5DownLoadManager.getInstance().downloadH5Res(str, new d(nativeController.j, campaignEx, TextUtils.isEmpty(HTMLResourceManager.getInstance().getHtmlContentFromUrl(str)))); } else { H5DownLoadManager.getInstance().downloadH5Res(str, new g(nativeController.j, campaignEx, TextUtils.isEmpty(H5DownLoadManager.getInstance().getH5ResAddress(str)))); } } } catch (Exception unused) { } } return; } catch (Throwable unused2) { w.d(e, "please import the videocommon and nativex aar"); return; } } } catch (Throwable th) { if (MBridgeConstans.DEBUG) { th.printStackTrace(); return; } return; } } w.b(e, "onload 不用下载视频素材 size为0"); } static /* synthetic */ List a(NativeController nativeController, List list, boolean z2) { if (list != null) { for (int size = list.size() - 1; size >= 0; size--) { Campaign campaign = (Campaign) list.get(size); String id = campaign.getId(); boolean z3 = campaign instanceof CampaignEx; if (z3) { StringBuilder sb = new StringBuilder(); sb.append(id); CampaignEx campaignEx = (CampaignEx) campaign; sb.append(campaignEx.getVideoUrlEncode()); sb.append(campaignEx.getBidToken()); id = sb.toString(); } com.mbridge.msdk.videocommon.download.a a2 = com.mbridge.msdk.videocommon.download.b.getInstance().a(nativeController.j, id); if (z2) { if (a2 == null || !com.mbridge.msdk.videocommon.download.d.a(a2, nativeController.e().f())) { com.mbridge.msdk.mbnative.a.f.a(campaign.getType()).a(nativeController.j, (Campaign) list.remove(size), nativeController.V); } } else if (z3) { CampaignEx campaignEx2 = (CampaignEx) campaign; if (TextUtils.isEmpty(campaignEx2.getImageUrl()) && !TextUtils.isEmpty(campaignEx2.getVideoUrlEncode()) && (a2 == null || !com.mbridge.msdk.videocommon.download.d.a(a2, nativeController.e().f()))) { com.mbridge.msdk.mbnative.a.f.a(campaign.getType()).a(nativeController.j, (Campaign) list.remove(size), nativeController.V); } } } } return list; } }