package com.duoyou.task.pro.g; import android.app.Activity; import android.content.Context; import android.net.Uri; import android.os.Build; import android.os.Bundle; import android.text.TextUtils; import android.util.Log; import android.view.View; import com.duoyou.api.oaid.DeviceID; import com.duoyou.api.oaid.IGetter; import com.duoyou.task.openapi.IDyAdApi; import com.duoyou.task.openapi.OnCommonCallback; import com.duoyou.task.openapi.OnDownloadListener; import com.duoyou.task.openapi.OnHttpCallback; import com.duoyou.task.openapi.OnNeedLoginCallback; import com.duoyou.task.openapi.OnPayInterceptorCallback; import com.duoyou.task.openapi.TaskListParams; import com.duoyou.task.openapi.WebViewObject; import com.duoyou.task.sdk.PlayGameActivity; import com.duoyou.task.sdk.WebViewActivity; import com.duoyou.task.sdk.WebViewFragment; import com.duoyou.task.sdk.entity.GameInfo; import com.duoyou.task.sdk.view.dialog.LoadingUtils; import com.duoyou.task.sdk.xutils.common.Callback; import com.duoyou.task.sdk.xutils.x; import com.mbridge.msdk.MBridgeConstans; import com.mbridge.msdk.foundation.entity.CampaignEx; import com.ss.android.download.api.constant.BaseConstants; import com.umeng.analytics.pro.am; import java.io.File; import java.util.ArrayList; import java.util.HashMap; import java.util.List; import java.util.Map; import org.json.JSONArray; import org.json.JSONObject; public final class d implements IDyAdApi { public static d E; public OnPayInterceptorCallback A; public boolean B; public boolean C; public OnCommonCallback D; public String a; public String b; public String c; public String d; public int e = -1; public int f = -1; public int g = -1; public String h; public String i; public int j = -1; public int k = -1; public String l; public View.OnClickListener m; public boolean n = true; public Context o; public Map<String, String> p = new HashMap(); public List<com.duoyou.task.pro.e.c> q = new ArrayList(); public int r = -1; public String s; public List<com.duoyou.task.pro.e.a> t; public int u = -1; public int v = -1; public OnNeedLoginCallback w; public WebViewObject x; public String y; public String z; public class a extends com.duoyou.task.pro.f.a { public final /* synthetic */ OnHttpCallback a; public a(d dVar, OnHttpCallback onHttpCallback) { this.a = onHttpCallback; } @Override // com.duoyou.task.pro.f.a public void onFailure(String str, String str2) { OnHttpCallback onHttpCallback = this.a; if (onHttpCallback != null) { onHttpCallback.onFailure(str, str2); } } /* JADX DEBUG: Method arguments types fixed to match base method, original types: [java.lang.Object] */ @Override // com.duoyou.task.sdk.xutils.common.Callback.CommonCallback, com.duoyou.task.pro.f.a public void onSuccess(String str) { try { JSONObject jSONObject = new JSONObject(str); String optString = jSONObject.optString("status_code"); String optString2 = jSONObject.optString("message"); if ("200".equals(optString)) { JSONArray optJSONArray = jSONObject.optJSONArray("data"); if (optJSONArray == null) { optJSONArray = new JSONArray(); } OnHttpCallback onHttpCallback = this.a; if (onHttpCallback != null) { onHttpCallback.onSuccess(optJSONArray); return; } return; } OnHttpCallback onHttpCallback2 = this.a; if (onHttpCallback2 != null) { onHttpCallback2.onFailure(optString, optString2); } } catch (Exception e) { e.printStackTrace(); OnHttpCallback onHttpCallback3 = this.a; if (onHttpCallback3 != null) { onHttpCallback3.onFailure("-1", e.getMessage()); } } } @Override // com.duoyou.task.pro.f.a public void onSuccess(String str) { try { JSONObject jSONObject = new JSONObject(str); String optString = jSONObject.optString("status_code"); String optString2 = jSONObject.optString("message"); if ("200".equals(optString)) { JSONArray optJSONArray = jSONObject.optJSONArray("data"); if (optJSONArray == null) { optJSONArray = new JSONArray(); } OnHttpCallback onHttpCallback = this.a; if (onHttpCallback != null) { onHttpCallback.onSuccess(optJSONArray); return; } return; } OnHttpCallback onHttpCallback2 = this.a; if (onHttpCallback2 != null) { onHttpCallback2.onFailure(optString, optString2); } } catch (Exception e) { e.printStackTrace(); OnHttpCallback onHttpCallback3 = this.a; if (onHttpCallback3 != null) { onHttpCallback3.onFailure("-1", e.getMessage()); } } } } public class b implements IGetter { public b() { } @Override // com.duoyou.api.oaid.IGetter public void onOAIDGetComplete(String str) { Log.i("json", "oaid third = " + str); if (!TextUtils.isEmpty(str)) { d.this.setOAID(str); } } @Override // com.duoyou.api.oaid.IGetter public void onOAIDGetError(Exception exc) { } } public class c extends com.duoyou.task.pro.f.a { public final /* synthetic */ Activity a; public final /* synthetic */ String b; public final /* synthetic */ String c; public c(Activity activity, String str, String str2) { this.a = activity; this.b = str; this.c = str2; } @Override // com.duoyou.task.pro.f.a public void onFailure(String str, String str2) { LoadingUtils.hideLoading(); d.this.jumpAdDetail(this.a, this.b, this.c); } /* JADX DEBUG: Method arguments types fixed to match base method, original types: [java.lang.Object] */ @Override // com.duoyou.task.sdk.xutils.common.Callback.CommonCallback, com.duoyou.task.pro.f.a public void onSuccess(String str) { String str2 = str; LoadingUtils.hideLoading(); if (com.duoyou.task.pro.b.a.c(str2)) { try { JSONObject optJSONObject = com.duoyou.task.pro.b.a.a(str2).optJSONObject("advert"); String optString = optJSONObject.optString("h5_game_url"); String optString2 = optJSONObject.optString("product_name"); String optString3 = optJSONObject.optString("package_url"); String optString4 = optJSONObject.optString("product_icon"); Map<String, String> a2 = b.a(this.a); ((HashMap) a2).put("id", this.c); String a3 = b.a(a2, d.c().b()); if (TextUtils.isEmpty(optString)) { d.this.jumpAdDetail(this.a, this.b, this.c); return; } GameInfo gameInfo = new GameInfo(); gameInfo.gameId = Uri.parse(optString).getQueryParameter("game_id"); gameInfo.playUrl = optString; gameInfo.gameIcon = optString4; gameInfo.gameName = optString2; gameInfo.downloadUrl = optString3; gameInfo.taskParams = a3; PlayGameActivity.a(this.a, gameInfo); return; } catch (Exception e) { e.printStackTrace(); } } d.this.jumpAdDetail(this.a, this.b, this.c); } @Override // com.duoyou.task.pro.f.a public void onSuccess(String str) { LoadingUtils.hideLoading(); if (!com.duoyou.task.pro.b.a.c(str)) { d.this.jumpAdDetail(this.a, this.b, this.c); return; } try { JSONObject optJSONObject = com.duoyou.task.pro.b.a.a(str).optJSONObject("advert"); String optString = optJSONObject.optString("h5_game_url"); String optString2 = optJSONObject.optString("product_name"); String optString3 = optJSONObject.optString("package_url"); String optString4 = optJSONObject.optString("product_icon"); Map<String, String> a2 = b.a(this.a); ((HashMap) a2).put("id", this.c); String a3 = b.a(a2, d.c().b()); if (TextUtils.isEmpty(optString)) { d.this.jumpAdDetail(this.a, this.b, this.c); return; } GameInfo gameInfo = new GameInfo(); gameInfo.gameId = Uri.parse(optString).getQueryParameter("game_id"); gameInfo.playUrl = optString; gameInfo.gameIcon = optString4; gameInfo.gameName = optString2; gameInfo.downloadUrl = optString3; gameInfo.taskParams = a3; PlayGameActivity.a(this.a, gameInfo); } catch (Exception e) { e.printStackTrace(); d.this.jumpAdDetail(this.a, this.b, this.c); } } } /* renamed from: com.duoyou.task.pro.g.d$d reason: collision with other inner class name */ public class C0047d extends com.duoyou.task.pro.c.c { public final /* synthetic */ OnDownloadListener a; public C0047d(d dVar, OnDownloadListener onDownloadListener) { this.a = onDownloadListener; } @Override // com.duoyou.task.pro.c.c public void a(int i, long j, long j2, long j3) { OnDownloadListener onDownloadListener = this.a; if (onDownloadListener != null) { onDownloadListener.onProgress(i, j, j2, j3); } } @Override // com.duoyou.task.pro.c.c /* renamed from: a */ public void onSuccess(File file) { OnDownloadListener onDownloadListener = this.a; if (onDownloadListener != null) { onDownloadListener.onSuccess(file); } } @Override // com.duoyou.task.pro.c.c public void a(String str, String str2) { OnDownloadListener onDownloadListener = this.a; if (onDownloadListener != null) { onDownloadListener.onFailure(str, str2); } } @Override // com.duoyou.task.sdk.xutils.common.Callback.CommonCallback, com.duoyou.task.pro.c.c public void onCancelled(Callback.CancelledException cancelledException) { } @Override // com.duoyou.task.sdk.xutils.common.Callback.ProgressCallback, com.duoyou.task.pro.c.c public void onWaiting() { OnDownloadListener onDownloadListener = this.a; if (onDownloadListener != null) { onDownloadListener.onWaiting(); } } } public static d c() { if (E == null) { E = new d(); } return E; } public String a() { if (TextUtils.isEmpty(this.a)) { this.a = com.duoyou.task.pro.b.a.a(this.o, "media_id", ""); } return this.a; } public void a(int i2, String str, int i3) { try { com.duoyou.task.pro.e.a aVar = d().get(i2); aVar.a = str; aVar.b = i3; } catch (Exception e2) { e2.printStackTrace(); } } public void a(Context context, boolean z2) { if (Build.VERSION.SDK_INT >= 29 && this.n) { if (TextUtils.isEmpty(com.duoyou.task.pro.b.a.a(context, "oaid", "")) || z2) { try { DeviceID.getOAID(context, new b()); } catch (Exception e2) { e2.printStackTrace(); } } } } @Override // com.duoyou.task.openapi.IDyAdApi public IDyAdApi addWebViewJavascriptInterface(WebViewObject webViewObject, String str) { this.x = webViewObject; this.y = str; return this; } public String b() { if (TextUtils.isEmpty(this.b)) { this.b = com.duoyou.task.pro.b.a.a(this.o, MBridgeConstans.APP_KEY, ""); } return this.b; } @Override // com.duoyou.task.openapi.IDyAdApi public IDyAdApi changeTaskDetailHost(String str) { this.s = str; com.duoyou.task.pro.b.a.c(this.o, "task_detail_host", str); return this; } @Override // com.duoyou.task.openapi.IDyAdApi public int checkAppInstalled(Context context, String str) { return com.duoyou.task.pro.b.a.g(context, str) ? 1 : 0; } public List<com.duoyou.task.pro.e.a> d() { if (this.t == null) { this.t = new ArrayList(); } if (this.t.size() == 0) { this.t.add(new com.duoyou.task.pro.e.a()); this.t.add(new com.duoyou.task.pro.e.a()); this.t.add(new com.duoyou.task.pro.e.a()); } return this.t; } @Override // com.duoyou.task.openapi.IDyAdApi public void download(Context context, String str, String str2, OnDownloadListener onDownloadListener) { com.duoyou.task.pro.c.a.a().a(context, com.duoyou.task.pro.c.b.a(str, str2), new C0047d(this, onDownloadListener)); } public String e() { if (TextUtils.isEmpty(this.h)) { this.h = com.duoyou.task.pro.b.a.a(this.o, CampaignEx.JSON_KEY_TITLE, ""); } return this.h; } public String f() { if (TextUtils.isEmpty(this.d)) { this.d = com.duoyou.task.pro.b.a.a(this.o, "user_id", ""); } return this.d; } @Override // com.duoyou.task.openapi.IDyAdApi public WebViewFragment getAdListFragment(int i2) { this.e = i2; com.duoyou.task.pro.b.a.b(this.o, "task_type", i2); Bundle bundle = new Bundle(); bundle.putInt("taskType", i2); WebViewFragment webViewFragment = new WebViewFragment(); webViewFragment.setArguments(bundle); return webViewFragment; } @Override // com.duoyou.task.openapi.IDyAdApi public WebViewFragment getAdListFragment(String str, int i2) { this.d = str; this.e = i2; com.duoyou.task.pro.b.a.c(this.o, "user_id", str); com.duoyou.task.pro.b.a.b(this.o, "task_type", i2); Bundle bundle = new Bundle(); bundle.putString("userId", str); bundle.putInt("taskType", i2); WebViewFragment webViewFragment = new WebViewFragment(); webViewFragment.setArguments(bundle); return webViewFragment; } @Override // com.duoyou.task.openapi.IDyAdApi public String getSdkVersion() { return "2.2.9"; } @Override // com.duoyou.task.openapi.IDyAdApi public IDyAdApi getTaskList(String str, TaskListParams taskListParams, OnHttpCallback onHttpCallback) { String a2 = a(); String b2 = b(); try { HashMap hashMap = new HashMap(); hashMap.put("media_id", a2); hashMap.put("user_id", str); hashMap.put(am.ai, "2"); String a3 = f.a(hashMap, b2); HashMap hashMap2 = new HashMap(); hashMap2.put("media_id", a2); hashMap2.put("user_id", str); hashMap2.put(am.ai, "2"); hashMap2.put("sign", a3); if (taskListParams != null) { if (!TextUtils.isEmpty(taskListParams.type)) { hashMap2.put("type", taskListParams.type); } if (taskListParams.page > 0) { hashMap2.put("page", taskListParams.page + ""); } if (taskListParams.size > 0) { hashMap2.put("size", taskListParams.size + ""); } if (!TextUtils.isEmpty(taskListParams.extra)) { hashMap2.put(BaseConstants.EVENT_LABEL_EXTRA, taskListParams.extra); } } com.duoyou.task.pro.b.a.a("https://api.ads66.com/api/list", hashMap2, new a(this, onHttpCallback)); return this; } catch (Exception e2) { e2.printStackTrace(); if (onHttpCallback != null) { onHttpCallback.onFailure("-1", "签名失败"); } return this; } } @Override // com.duoyou.task.openapi.IDyAdApi public IDyAdApi init(Context context, String str, String str2, String str3) { init(context, str, str2, str3, true); return this; } @Override // com.duoyou.task.openapi.IDyAdApi public IDyAdApi init(Context context, String str, String str2, String str3, boolean z2) { this.a = str; this.b = str2; this.o = context; this.n = z2; x.Ext.init(context); a(context, true); com.duoyou.task.pro.b.a.c(context, "media_id", str); com.duoyou.task.pro.b.a.c(context, MBridgeConstans.APP_KEY, str2); com.duoyou.task.pro.b.a.c(context, "channel", str3); return this; } @Override // com.duoyou.task.openapi.IDyAdApi public void jumpAdDetail(Context context, String str, String str2) { String str3; String str4; StringBuilder sb; String str5; this.d = str; this.c = str2; if (TextUtils.isEmpty(str)) { str3 = "缺少用户ID"; } else if ("null".equals(str) || "NULL".equals(str)) { str3 = "用户ID不能为null或者NULL"; } else if (TextUtils.isEmpty(str2)) { str3 = "缺少广告ID"; } else { a(context, false); com.duoyou.task.pro.b.a.c(context, "user_id", str); com.duoyou.task.pro.b.a.c(context, "task_id", str2); com.duoyou.task.pro.b.a.a(context, "en", 1); if (TextUtils.isEmpty(this.s)) { str4 = String.format("tasks/%s", str2); } else { String str6 = this.s; if (str6.contains("?")) { sb = new StringBuilder(); sb.append(str6); str5 = "&isHideTitle=1"; } else { sb = new StringBuilder(); sb.append(str6); str5 = "?isHideTitle=1"; } sb.append(str5); str4 = sb.toString(); } WebViewActivity.a(context, com.duoyou.task.pro.b.a.b(str4), true); return; } com.duoyou.task.pro.b.a.k(context, str3); } @Override // com.duoyou.task.openapi.IDyAdApi public void jumpAdDetail(Context context, String str, String str2, Map<String, String> map) { this.p = map; jumpAdDetail(context, str, str2); } @Override // com.duoyou.task.openapi.IDyAdApi public void jumpAdList(Context context, int i2) { this.e = i2; a(context, false); com.duoyou.task.pro.b.a.b(context, "task_type", i2); com.duoyou.task.pro.b.a.a(context, "en", 1); WebViewActivity.a(context, com.duoyou.task.pro.b.a.b("home")); } @Override // com.duoyou.task.openapi.IDyAdApi public void jumpAdList(Context context, String str, int i2) { this.d = str; this.e = i2; if (TextUtils.isEmpty(str)) { com.duoyou.task.pro.b.a.k(context, "缺少用户ID"); } if ("null".equals(str) || "NULL".equals(str)) { com.duoyou.task.pro.b.a.k(context, "用户ID不能为null或者NULL"); } a(context, false); com.duoyou.task.pro.b.a.c(context, "user_id", str); com.duoyou.task.pro.b.a.b(context, "task_type", i2); com.duoyou.task.pro.b.a.a(context, "en", 1); WebViewActivity.a(context, com.duoyou.task.pro.b.a.b("home")); } @Override // com.duoyou.task.openapi.IDyAdApi public IDyAdApi jumpCPAList(Context context, String str) { this.d = str; com.duoyou.task.pro.b.a.c(this.o, "user_id", str); a(context, false); WebViewActivity.a(context, ""); return this; } @Override // com.duoyou.task.openapi.IDyAdApi public void jumpMine(Context context, String str) { this.d = str; if (TextUtils.isEmpty(str)) { com.duoyou.task.pro.b.a.k(context, "缺少用户ID"); } else if ("null".equals(str) || "NULL".equals(str)) { com.duoyou.task.pro.b.a.k(context, "用户ID不能为null或者NULL"); } else { com.duoyou.task.pro.b.a.c(context, "user_id", str); a(context, false); com.duoyou.task.pro.b.a.a(context, "en", 1); WebViewActivity.a(context, com.duoyou.task.pro.b.a.b("participates")); } } @Override // com.duoyou.task.openapi.IDyAdApi public void launchLittleProgram(Activity activity, String str, String str2) { if (TextUtils.isEmpty(str2)) { com.duoyou.task.pro.b.a.j(activity, "任务Id为空"); return; } if (this.o == null) { this.o = activity; x.Ext.init(activity); } this.c = str2; com.duoyou.task.pro.b.a.c(activity, "task_id", str2); LoadingUtils.showLoading(activity); c cVar = new c(activity, str, str2); String a2 = b.a(activity, "https://h5.ads66.com/index.php/tasks"); HashMap hashMap = new HashMap(); hashMap.put("id", str2); com.duoyou.task.pro.b.a.a(a2, hashMap, cVar); } @Override // com.duoyou.task.openapi.IDyAdApi public IDyAdApi putOAID(Context context, String str) { return setOAID(str); } @Override // com.duoyou.task.openapi.IDyAdApi public IDyAdApi setCommonCallback(OnCommonCallback onCommonCallback) { this.D = onCommonCallback; return this; } @Override // com.duoyou.task.openapi.IDyAdApi public IDyAdApi setDebug(boolean z2) { this.C = z2; return this; } @Override // com.duoyou.task.openapi.IDyAdApi public IDyAdApi setExtra(String str) { this.z = str; return this; } @Override // com.duoyou.task.openapi.IDyAdApi public IDyAdApi setInstallNotStart(boolean z2) { this.B = z2; return this; } @Override // com.duoyou.task.openapi.IDyAdApi public IDyAdApi setIsLikeLittleProgram(boolean z2) { return this; } @Override // com.duoyou.task.openapi.IDyAdApi public IDyAdApi setOAID(String str) { if (!TextUtils.isEmpty(str)) { com.duoyou.task.pro.b.a.c(this.o, "oaid", str); } return this; } @Override // com.duoyou.task.openapi.IDyAdApi public void setOnNeedLoginCallback(OnNeedLoginCallback onNeedLoginCallback) { this.w = onNeedLoginCallback; } @Override // com.duoyou.task.openapi.IDyAdApi public void setOnPayInterceptorCallback(OnPayInterceptorCallback onPayInterceptorCallback) { this.A = onPayInterceptorCallback; } @Override // com.duoyou.task.openapi.IDyAdApi public IDyAdApi setParamsMap(Map<String, String> map) { this.p = map; return this; } @Override // com.duoyou.task.openapi.IDyAdApi public IDyAdApi setRightText(String str, View.OnClickListener onClickListener) { this.l = str; this.m = onClickListener; return this; } @Override // com.duoyou.task.openapi.IDyAdApi public IDyAdApi setSplashLandscapeImageResource(int i2) { this.k = i2; return this; } @Override // com.duoyou.task.openapi.IDyAdApi public IDyAdApi setSplashPortraitImageResource(int i2) { this.j = i2; return this; } @Override // com.duoyou.task.openapi.IDyAdApi public IDyAdApi setTitle(String str) { this.h = str; com.duoyou.task.pro.b.a.c(this.o, CampaignEx.JSON_KEY_TITLE, str); return this; } @Override // com.duoyou.task.openapi.IDyAdApi public IDyAdApi setTitleBarColor(int i2) { this.f = i2; com.duoyou.task.pro.b.a.b(this.o, "title_bar_color", i2); return this; } @Override // com.duoyou.task.openapi.IDyAdApi public IDyAdApi setTitleBarColor(int i2, int i3, boolean z2) { this.f = i2; this.g = i3; com.duoyou.task.pro.b.a.b(this.o, "title_bar_color", i2); com.duoyou.task.pro.b.a.b(this.o, "title_color", i3); com.duoyou.task.pro.b.a.b(this.o, "is_dark", z2); return this; } @Override // com.duoyou.task.openapi.IDyAdApi public IDyAdApi setUserId(String str) { this.d = str; com.duoyou.task.pro.b.a.c(this.o, "user_id", str); return this; } @Override // com.duoyou.task.openapi.IDyAdApi public void startApp(Context context, String str) { if (TextUtils.isEmpty(str)) { com.duoyou.task.pro.b.a.k(context, "包名为空"); return; } com.duoyou.task.pro.b.a.k(context, "即将打开应用..."); if (!com.duoyou.task.pro.c.a.a().b(context, str)) { com.duoyou.task.pro.b.a.k(context, "该应用不存在!请稍后再试"); } } @Override // com.duoyou.task.openapi.IDyAdApi public void startWebViewActivity(Context context, String str) { WebViewActivity.a(context, str); } }