package com.mbridge.msdk.videocommon.d; import android.text.TextUtils; import com.mbridge.msdk.foundation.db.g; import com.mbridge.msdk.foundation.entity.CampaignEx; import com.mbridge.msdk.foundation.entity.RewardPlus; import com.mbridge.msdk.foundation.tools.z; import com.mbridge.msdk.newreward.function.common.MBridgeCommon; import java.util.ArrayList; import java.util.Iterator; import java.util.LinkedList; import java.util.List; import java.util.Queue; import org.json.JSONArray; import org.json.JSONObject; /* loaded from: classes4.dex */ public final class c { private static g H; public static String a; private int F; private int I; private JSONArray W; private JSONObject X; private String b; private String c; private List d; private long e; private ArrayList u; private int f = -1; private int g = 0; private int h = 0; private int i = 1; private int j = 1; private int k = 1; private int l = 1; private int m = 5; private int n = 1; private int o = 3; private int p = 80; private int q = 100; private int r = 0; private double s = 1.0d; private int t = -1; private int v = 3; private int w = 1; private int x = 100; private int y = 60; private int z = 0; private int A = 70; private int B = 0; private int C = -1; private int D = -1; private int E = -1; private int G = 20; private int J = 0; private int K = 1; private String L = ""; private int M = 1; private String N = ""; private int O = 1; private String P = "Virtual Item"; private String Q = ""; private String R = ""; private int S = 0; private int T = 1; private int U = 60; private String V = ""; private void y(int i) { if (i <= 0) { this.M = 1; } else { this.M = i; } } public final int A() { return this.v; } public final int C() { return this.T; } public final int D() { return this.U; } public final int F() { return this.A; } public final JSONArray G() { return this.W; } public final int a() { return this.x; } public final void a(int i) { this.z = i; } public final void a(String str) { this.b = str; } public final void a(ArrayList arrayList) { this.u = arrayList; } public final void a(List list) { this.d = list; } public final int b() { return this.y; } public final void b(int i) { this.B = i; } public final void b(String str) { this.c = str; } public final int c() { return this.z; } public final void c(int i) { this.C = i; } public final int d() { return this.B; } public final void d(int i) { this.D = i; } public final int e() { return this.C; } public final void e(int i) { this.E = i; } public final int f() { return this.D; } public final void f(int i) { this.F = i; } public final int g() { return this.E; } public final void g(int i) { this.I = i; } public final int h() { return this.f; } public final void h(int i) { this.o = i; } public final int i() { return this.h; } public final void i(int i) { this.p = i; } public final String j() { return this.V; } public final void j(int i) { this.q = i; } public final String k() { return this.Q; } public final void k(int i) { this.r = i; } public final String l() { return this.R; } public final void l(int i) { this.j = i; } public final int m() { return this.M; } public final void m(int i) { this.k = i; } public final String n() { return this.P; } public final void n(int i) { this.l = i; } public final int o() { return this.G; } public final void o(int i) { this.m = i; } public final int p() { return this.F; } public final void p(int i) { this.n = i; } public final int q() { return this.I; } public final void q(int i) { this.i = i; } public final int r() { return this.q; } public final void r(int i) { this.w = i; } public final int s() { return this.r; } public final int t() { return this.j; } public final void t(int i) { this.v = i; } public final int u() { return this.k; } public final void u(int i) { this.S = i; } public final int v() { return this.m; } public final void v(int i) { this.T = i; } public final int w() { return this.n; } public final void w(int i) { this.U = i; } public final long x() { return this.e; } public final void x(int i) { this.A = i; } public final int y() { return this.w; } public final String z() { return this.c; } private void d(String str) { this.Q = str; com.mbridge.msdk.foundation.controller.a.b.put(this.b, str); } private void e(String str) { if (TextUtils.isEmpty(str)) { this.P = this.L; } else { this.P = str; } } public final boolean s(int i) { ArrayList arrayList = this.u; if (arrayList == null || arrayList.size() <= 0) { return false; } return this.u.contains(Integer.valueOf(i)); } public final Queue B() { LinkedList linkedList; Exception e; List list; try { list = this.d; } catch (Exception e2) { linkedList = null; e = e2; } if (list == null || list.size() <= 0) { return null; } linkedList = new LinkedList(); for (int i = 0; i < this.d.size(); i++) { try { linkedList.add(Integer.valueOf(this.d.get(i).b())); } catch (Exception e3) { e = e3; e.printStackTrace(); return linkedList; } } return linkedList; } public static c c(String str) { JSONObject optJSONObject; if (H == null) { H = g.a(com.mbridge.msdk.foundation.controller.c.m().c()); } c cVar = null; if (!TextUtils.isEmpty(str)) { try { JSONObject jSONObject = new JSONObject(str); String optString = jSONObject.optString("vtag", ""); String optString2 = jSONObject.optString("rid", ""); JSONArray optJSONArray = jSONObject.optJSONArray("unitSetting"); if (optJSONArray == null || (optJSONObject = optJSONArray.optJSONObject(0)) == null) { return null; } String optString3 = optJSONObject.optString("unitId"); if (TextUtils.isEmpty(optString3)) { return null; } c cVar2 = new c(); try { cVar2.V = optString; cVar2.R = optString2; List a2 = com.mbridge.msdk.videocommon.b.b.a(optJSONObject.optJSONArray("adSourceList")); cVar2.b = optString3; cVar2.d = a2; cVar2.i = optJSONObject.optInt("callbackType"); int optInt = optJSONObject.optInt("aqn", 1); if (optInt <= 0) { optInt = 1; } cVar2.j = optInt; int optInt2 = optJSONObject.optInt("acn", 1); if (optInt2 < 0) { optInt2 = 1; } cVar2.k = optInt2; cVar2.l = optJSONObject.optInt("vcn", 5); cVar2.m = optJSONObject.optInt("offset", 5); cVar2.n = optJSONObject.optInt("dlnet", 1); cVar2.I = optJSONObject.optInt("endscreen_type", 2); cVar2.o = optJSONObject.optInt("tv_start", 3); cVar2.p = optJSONObject.optInt("tv_end", 80); cVar2.q = optJSONObject.optInt(CampaignEx.JSON_KEY_READY_RATE, 100); cVar2.r = optJSONObject.optInt("cd_rate", 0); cVar2.e = jSONObject.optLong("current_time"); cVar2.z = optJSONObject.optInt("orientation", 0); cVar2.B = optJSONObject.optInt("daily_play_cap", 0); cVar2.C = optJSONObject.optInt("video_skip_time", -1); cVar2.D = optJSONObject.optInt("video_skip_result", 2); cVar2.E = optJSONObject.optInt("video_interactive_type", -1); cVar2.F = optJSONObject.optInt("close_button_delay", 1); cVar2.f = optJSONObject.optInt("playclosebtn_tm", -1); cVar2.g = optJSONObject.optInt("play_ctdown", 0); cVar2.h = optJSONObject.optInt("close_alert", 0); cVar2.G = optJSONObject.optInt("rdrct", 20); cVar2.A = optJSONObject.optInt("load_global_timeout", 70); cVar2.t = optJSONObject.optInt("rfpv", -1); cVar2.s = optJSONObject.optDouble("vdcmp", 1.0d); a = optJSONObject.optString("atzu"); JSONArray optJSONArray2 = optJSONObject.optJSONArray("atl_type"); ArrayList arrayList = new ArrayList<>(); try { if (optJSONArray2 != null) { for (int i = 0; i < optJSONArray2.length(); i++) { arrayList.add(Integer.valueOf(optJSONArray2.getInt(i))); } } else { arrayList.add(4); arrayList.add(6); } cVar2.u = arrayList; } catch (Exception e) { e.printStackTrace(); } int optInt3 = optJSONObject.optInt("atl_dyt", 0); cVar2.v = optInt3 > 0 ? optInt3 : 3; int optInt4 = optJSONObject.optInt("tmorl", 1); if (optInt4 > 2 || optInt4 <= 0) { optInt4 = 1; } cVar2.w = optInt4; cVar2.c = optJSONObject.optString("placementid"); cVar2.x = optJSONObject.optInt("ltafemty", 10); cVar2.y = optJSONObject.optInt("ltorwc", 60); cVar2.d(optJSONObject.optString("ab_id")); cVar2.J = optJSONObject.optInt(RewardPlus.AMOUNT_MAX, 0); cVar2.K = optJSONObject.optInt(RewardPlus.CALLBACK_RULE, 1); cVar2.L = optJSONObject.optString(RewardPlus.VIRTUAL_CURRENCY, ""); cVar2.y(optJSONObject.optInt("amount", 1)); cVar2.N = optJSONObject.optString("icon", ""); cVar2.O = optJSONObject.optInt("currency_id", 1); cVar2.e(optJSONObject.optString("name", "Virtual Item")); cVar2.T = optJSONObject.optInt("video_error_rule", 1); cVar2.U = optJSONObject.optInt("loadtmo", 60); cVar2.W = optJSONObject.optJSONArray("local_cache_info"); try { String optString4 = optJSONObject.optString(MBridgeCommon.SettingConfig.KEY_SETTING_CONFIG_RETRY_STRATEGY); if (!TextUtils.isEmpty(optString4)) { String a3 = z.a(optString4); if (!TextUtils.isEmpty(a3)) { cVar2.X = new JSONObject(a3); } } } catch (Exception unused) { } return cVar2; } catch (Exception e2) { e = e2; cVar = cVar2; e.printStackTrace(); return cVar; } } catch (Exception e3) { e = e3; } } return cVar; } public final JSONObject E() { JSONObject jSONObject = new JSONObject(); try { jSONObject.put("unitId", this.b); jSONObject.put("callbackType", this.i); List list = this.d; if (list != null && list.size() > 0) { JSONArray jSONArray = new JSONArray(); for (com.mbridge.msdk.videocommon.b.b bVar : this.d) { JSONObject jSONObject2 = new JSONObject(); jSONObject2.put("id", bVar.a()); jSONObject2.put("timeout", bVar.b()); jSONArray.put(jSONObject2); } jSONObject.put("adSourceList", jSONArray); } jSONObject.put("aqn", this.j); jSONObject.put("acn", this.k); jSONObject.put("vcn", this.l); jSONObject.put("offset", this.m); jSONObject.put("dlnet", this.n); jSONObject.put("tv_start", this.o); jSONObject.put("tv_end", this.p); jSONObject.put(CampaignEx.JSON_KEY_READY_RATE, this.q); jSONObject.put("endscreen_type", this.I); jSONObject.put("daily_play_cap", this.B); jSONObject.put("video_skip_time", this.C); jSONObject.put("video_skip_result", this.D); jSONObject.put("video_interactive_type", this.E); jSONObject.put("orientation", this.z); jSONObject.put("close_button_delay", this.F); jSONObject.put("playclosebtn_tm", this.f); jSONObject.put("play_ctdown", this.g); jSONObject.put("close_alert", this.h); jSONObject.put("rfpv", this.t); jSONObject.put("vdcmp", this.s); JSONArray jSONArray2 = new JSONArray(); ArrayList arrayList = this.u; if (arrayList != null) { if (arrayList.size() > 0) { Iterator it = this.u.iterator(); while (it.hasNext()) { jSONArray2.put(it.next()); } } jSONObject.put("atl_type", jSONArray2); } jSONObject.put("atl_dyt", this.v); jSONObject.put("tmorl", this.w); jSONObject.put("placementid", this.c); jSONObject.put("ltafemty", this.x); jSONObject.put("ltorwc", this.y); jSONObject.put(RewardPlus.AMOUNT_MAX, this.J); jSONObject.put(RewardPlus.CALLBACK_RULE, this.K); jSONObject.put(RewardPlus.VIRTUAL_CURRENCY, this.L); jSONObject.put("amount", this.M); jSONObject.put("icon", this.N); jSONObject.put("currency_id", this.O); jSONObject.put("name", this.P); jSONObject.put("isDefault", this.S); jSONObject.put("video_error_rule", this.T); jSONObject.put("loadtmo", this.U); jSONObject.put("vtag", this.V); } catch (Exception e) { e.printStackTrace(); } return jSONObject; } public static c a(JSONObject jSONObject) { c cVar; c cVar2 = null; if (jSONObject == null) { return null; } try { cVar = new c(); } catch (Exception e) { e = e; } try { cVar.d = com.mbridge.msdk.videocommon.b.b.a(jSONObject.optJSONArray("adSourceList")); cVar.i = jSONObject.optInt("callbackType"); int optInt = jSONObject.optInt("aqn", 1); if (optInt <= 0) { optInt = 1; } cVar.j = optInt; int optInt2 = jSONObject.optInt("acn", 1); if (optInt2 < 0) { optInt2 = 1; } cVar.k = optInt2; cVar.l = jSONObject.optInt("vcn", 5); cVar.m = jSONObject.optInt("offset", 5); cVar.n = jSONObject.optInt("dlnet", 1); cVar.I = jSONObject.optInt("endscreen_type", 2); cVar.o = jSONObject.optInt("tv_start", 3); cVar.p = jSONObject.optInt("tv_end", 80); cVar.q = jSONObject.optInt(CampaignEx.JSON_KEY_READY_RATE, 100); cVar.e = jSONObject.optLong("current_time"); cVar.z = jSONObject.optInt("orientation", 0); cVar.B = jSONObject.optInt("daily_play_cap", 0); cVar.C = jSONObject.optInt("video_skip_time", -1); cVar.D = jSONObject.optInt("video_skip_result", 2); cVar.E = jSONObject.optInt("video_interactive_type", -1); cVar.F = jSONObject.optInt("close_button_delay", 1); cVar.f = jSONObject.optInt("playclosebtn_tm", -1); cVar.g = jSONObject.optInt("play_ctdown", 0); cVar.h = jSONObject.optInt("close_alert", 0); cVar.G = jSONObject.optInt("rdrct", 20); cVar.t = jSONObject.optInt("rfpv", -1); cVar.s = jSONObject.optDouble("vdcmp", 1.0d); cVar.A = jSONObject.optInt("load_global_timeout", 70); JSONArray optJSONArray = jSONObject.optJSONArray("atl_type"); ArrayList arrayList = new ArrayList<>(); try { if (optJSONArray != null) { for (int i = 0; i < optJSONArray.length(); i++) { arrayList.add(Integer.valueOf(optJSONArray.getInt(i))); } } else { arrayList.add(4); arrayList.add(6); } cVar.u = arrayList; } catch (Exception e2) { e2.printStackTrace(); } cVar.v = jSONObject.optInt("atl_dyt", 3); int optInt3 = jSONObject.optInt("tmorl", 1); if (optInt3 > 2 || optInt3 <= 0) { optInt3 = 1; } cVar.w = optInt3; cVar.c = jSONObject.optString("placementid"); cVar.x = jSONObject.optInt("ltafemty", 10); cVar.y = jSONObject.optInt("ltorwc", 60); cVar.d(jSONObject.optString("ab_id")); cVar.R = jSONObject.optString("rid", ""); cVar.J = jSONObject.optInt(RewardPlus.AMOUNT_MAX, 0); cVar.K = jSONObject.optInt(RewardPlus.CALLBACK_RULE, 1); cVar.L = jSONObject.optString(RewardPlus.VIRTUAL_CURRENCY, ""); cVar.y(jSONObject.optInt("amount", 1)); cVar.N = jSONObject.optString("icon", ""); cVar.O = jSONObject.optInt("currency_id", 1); cVar.e(jSONObject.optString("name", "Virtual Item")); cVar.T = jSONObject.optInt("video_error_rule", 1); cVar.U = jSONObject.optInt("loadtmo", 60); cVar.V = jSONObject.optString("vtag", ""); cVar.W = jSONObject.optJSONArray("local_cache_info"); try { String optString = jSONObject.optString(MBridgeCommon.SettingConfig.KEY_SETTING_CONFIG_RETRY_STRATEGY); if (!TextUtils.isEmpty(optString)) { String a2 = z.a(optString); if (!TextUtils.isEmpty(a2)) { cVar.X = new JSONObject(a2); } } } catch (Exception unused) { } return cVar; } catch (Exception e3) { e = e3; cVar2 = cVar; e.printStackTrace(); return cVar2; } } }