- 28,932 files - Full Java source code - Smali files - Resources Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
295 lines
12 KiB
Java
295 lines
12 KiB
Java
package com.tapjoy;
|
|
|
|
import android.content.Context;
|
|
import android.text.TextUtils;
|
|
import com.tapjoy.TapjoyErrorMessage;
|
|
import com.tapjoy.internal.d3;
|
|
import com.tapjoy.internal.s2;
|
|
import java.lang.ref.WeakReference;
|
|
import java.util.HashMap;
|
|
import java.util.Iterator;
|
|
import java.util.List;
|
|
import java.util.Map;
|
|
import java.util.UUID;
|
|
import org.json.JSONException;
|
|
import org.json.JSONObject;
|
|
|
|
/* loaded from: classes4.dex */
|
|
public class TJCorePlacement {
|
|
public Context b;
|
|
public Map c;
|
|
public final TJPlacementData d;
|
|
public TJCurrencyParameters e;
|
|
public final String f;
|
|
public long g;
|
|
public final TJAdUnit h;
|
|
public boolean k;
|
|
public final HashMap a = new HashMap();
|
|
public boolean i = false;
|
|
public boolean j = false;
|
|
public volatile boolean l = false;
|
|
public volatile boolean m = false;
|
|
public volatile boolean n = false;
|
|
public volatile boolean o = false;
|
|
|
|
public TJCorePlacement(String str, String str2) {
|
|
a0 a0Var = new a0(this);
|
|
Context context = com.tapjoy.internal.j.a;
|
|
if (context == null) {
|
|
WeakReference weakReference = com.tapjoy.internal.j.c.a;
|
|
context = (Context) (weakReference != null ? weakReference.get() : null);
|
|
}
|
|
this.b = context;
|
|
if (context == null) {
|
|
TapjoyLog.d("TJCorePlacement", "context is NULL.");
|
|
}
|
|
TJPlacementData tJPlacementData = new TJPlacementData(str2, getPlacementContentUrl());
|
|
this.d = tJPlacementData;
|
|
tJPlacementData.setPlacementName(str);
|
|
this.e = new TJCurrencyParameters(this.b);
|
|
this.f = UUID.randomUUID().toString();
|
|
TJAdUnit tJAdUnit = new TJAdUnit();
|
|
this.h = tJAdUnit;
|
|
tJAdUnit.setWebViewListener(a0Var);
|
|
}
|
|
|
|
public final void a(String str, TJPlacement tJPlacement) {
|
|
synchronized (this.a) {
|
|
try {
|
|
this.a.put(str, tJPlacement);
|
|
if (tJPlacement != null) {
|
|
TapjoyLog.d("TJCorePlacement", "Setting " + str + " placement: " + tJPlacement.getGUID());
|
|
}
|
|
} catch (Throwable th) {
|
|
throw th;
|
|
}
|
|
}
|
|
}
|
|
|
|
public TJAdUnit getAdUnit() {
|
|
return this.h;
|
|
}
|
|
|
|
public Context getContext() {
|
|
return this.b;
|
|
}
|
|
|
|
public String getPlacementContentUrl() {
|
|
String appID = TapjoyConnectCore.getInstance().getAppID();
|
|
if (TextUtils.isEmpty(appID)) {
|
|
TapjoyLog.i("TJCorePlacement", "Placement content URL cannot be generated for null app ID");
|
|
return "";
|
|
}
|
|
return TapjoyConnectCore.getInstance().getPlacementURL() + "v1/apps/" + appID + "/content?";
|
|
}
|
|
|
|
public TJPlacementData getPlacementData() {
|
|
return this.d;
|
|
}
|
|
|
|
public boolean isContentAvailable() {
|
|
return this.n;
|
|
}
|
|
|
|
public boolean isContentReady() {
|
|
return this.o;
|
|
}
|
|
|
|
public final synchronized void c(String str) {
|
|
float f;
|
|
com.tapjoy.internal.k kVar;
|
|
long parseLong;
|
|
long parseLong2;
|
|
long parseLong3;
|
|
double parseDouble;
|
|
if (this.l) {
|
|
TapjoyLog.i("TJCorePlacement", "Placement " + this.d.getPlacementName() + " is already requesting content");
|
|
return;
|
|
}
|
|
this.d.resetPlacementRequestData();
|
|
this.h.resetContentLoadState();
|
|
this.l = false;
|
|
this.m = false;
|
|
this.n = false;
|
|
this.o = false;
|
|
this.l = true;
|
|
TJPlacement a = a("REQUEST");
|
|
Map<String, String> baseURLParams = TapjoyConnectCore.getInstance().getBaseURLParams();
|
|
this.c = baseURLParams;
|
|
TJCurrencyParameters tJCurrencyParameters = this.e;
|
|
tJCurrencyParameters.getClass();
|
|
HashMap hashMap = new HashMap();
|
|
Context context = tJCurrencyParameters.a;
|
|
if (context != null && !tJCurrencyParameters.f) {
|
|
tJCurrencyParameters.c = new TJKeyValueStorage(context, TapjoyConstants.TJC_PREFERENCE).getInt(TapjoyConstants.PREF_SERVER_CURRENCY_BALANCE, -9999);
|
|
}
|
|
if (tJCurrencyParameters.i.size() > 0 && !tJCurrencyParameters.f && tJCurrencyParameters.c >= 0) {
|
|
TapjoyUtil.safePut(hashMap, TapjoyConstants.TJC_CURRENCY_ID_BALANCE, (String) tJCurrencyParameters.i.get(0), true);
|
|
TapjoyUtil.safePut(hashMap, TapjoyConstants.TJC_CURRENCY_BALANCE, Integer.toString(tJCurrencyParameters.c), true);
|
|
} else if (tJCurrencyParameters.i.contains(tJCurrencyParameters.b) && tJCurrencyParameters.f && tJCurrencyParameters.c >= 0) {
|
|
TapjoyUtil.safePut(hashMap, TapjoyConstants.TJC_CURRENCY_ID_BALANCE, tJCurrencyParameters.b, true);
|
|
TapjoyUtil.safePut(hashMap, TapjoyConstants.TJC_CURRENCY_BALANCE, Integer.toString(tJCurrencyParameters.c), true);
|
|
}
|
|
if (tJCurrencyParameters.i.contains(tJCurrencyParameters.d) && tJCurrencyParameters.e > 0) {
|
|
TapjoyUtil.safePut(hashMap, TapjoyConstants.TJC_CURRENCY_ID_REQUIRED, tJCurrencyParameters.d, true);
|
|
TapjoyUtil.safePut(hashMap, TapjoyConstants.TJC_CURRENCY_AMOUNT_REQUIRED, Integer.toString(tJCurrencyParameters.e), true);
|
|
}
|
|
baseURLParams.putAll(hashMap);
|
|
TapjoyUtil.safePut(this.c, TJAdUnitConstants.PARAM_PLACEMENT_NAME, this.d.getPlacementName(), true);
|
|
TapjoyUtil.safePut(this.c, TJAdUnitConstants.PARAM_PLACEMENT_PRELOAD, String.valueOf(true), true);
|
|
TapjoyUtil.safePut(this.c, "debug", Boolean.toString(TapjoyLog.isLoggingEnabled()), true);
|
|
TapjoyUtil.safePut(this.c, TJAdUnitConstants.PARAM_PLACEMENT_BY_SDK, String.valueOf(this.k), true);
|
|
if (a.getEntryPoint() != null) {
|
|
TapjoyUtil.safePut(this.c, TJAdUnitConstants.PARAM_ENTRY_POINT, a.getEntryPoint().getValue(), true);
|
|
}
|
|
if (!TextUtils.isEmpty(TapjoyConnectCore.getInstance().getCustomParameter())) {
|
|
TapjoyUtil.safePut(this.c, "cp", TapjoyConnectCore.getInstance().getCustomParameter(), true);
|
|
}
|
|
Iterator it = s2.c.a.a.iterator();
|
|
while (true) {
|
|
if (!it.hasNext()) {
|
|
f = 0.0f;
|
|
break;
|
|
}
|
|
Map map = ((com.tapjoy.internal.n) it.next()).a;
|
|
Object obj = map != null ? map.get("placement_request_content_retry_timeout") : null;
|
|
if (obj != null) {
|
|
if (obj instanceof Number) {
|
|
f = ((Number) obj).floatValue();
|
|
break;
|
|
} else if (obj instanceof String) {
|
|
try {
|
|
f = Float.parseFloat((String) obj);
|
|
break;
|
|
} catch (IllegalArgumentException unused) {
|
|
continue;
|
|
}
|
|
} else {
|
|
continue;
|
|
}
|
|
}
|
|
}
|
|
d3 d3Var = new d3((long) f);
|
|
Iterator it2 = s2.c.a.a.iterator();
|
|
while (true) {
|
|
if (!it2.hasNext()) {
|
|
kVar = com.tapjoy.internal.k.f;
|
|
break;
|
|
}
|
|
Map map2 = ((com.tapjoy.internal.n) it2.next()).a;
|
|
Object obj2 = map2 != null ? map2.get("placement_request_content_retry_backoff") : null;
|
|
if (obj2 instanceof List) {
|
|
List list = (List) obj2;
|
|
try {
|
|
Object obj3 = list.get(0);
|
|
if (obj3 instanceof Number) {
|
|
parseLong = ((Number) obj3).longValue();
|
|
} else {
|
|
if (!(obj3 instanceof String)) {
|
|
throw new IllegalArgumentException();
|
|
}
|
|
parseLong = Long.parseLong((String) obj3);
|
|
}
|
|
long j = parseLong;
|
|
Object obj4 = list.get(1);
|
|
if (obj4 instanceof Number) {
|
|
parseLong2 = ((Number) obj4).longValue();
|
|
} else {
|
|
if (!(obj4 instanceof String)) {
|
|
throw new IllegalArgumentException();
|
|
}
|
|
parseLong2 = Long.parseLong((String) obj4);
|
|
}
|
|
Object obj5 = list.get(2);
|
|
if (obj5 instanceof Number) {
|
|
parseLong3 = ((Number) obj5).longValue();
|
|
} else {
|
|
if (!(obj5 instanceof String)) {
|
|
throw new IllegalArgumentException();
|
|
}
|
|
parseLong3 = Long.parseLong((String) obj5);
|
|
}
|
|
Object obj6 = list.get(3);
|
|
if (obj6 instanceof Number) {
|
|
parseDouble = ((Number) obj6).doubleValue();
|
|
} else {
|
|
if (!(obj6 instanceof String)) {
|
|
throw new IllegalArgumentException();
|
|
}
|
|
parseDouble = Double.parseDouble((String) obj6);
|
|
}
|
|
kVar = new com.tapjoy.internal.k(j, parseLong2, parseLong3, parseDouble);
|
|
} catch (RuntimeException unused2) {
|
|
}
|
|
}
|
|
}
|
|
new c0(this, str, a, d3Var, kVar).start();
|
|
}
|
|
|
|
public void setContext(Context context) {
|
|
this.b = context;
|
|
this.e = new TJCurrencyParameters(context);
|
|
}
|
|
|
|
public final void b(String str) {
|
|
if (str != null) {
|
|
try {
|
|
TapjoyLog.d("TJCorePlacement", "Disable preload flag is set for placement " + this.d.getPlacementName());
|
|
this.d.setRedirectURL(new JSONObject(str).getString(TapjoyConstants.TJC_REDIRECT_URL));
|
|
this.d.setPreloadDisabled(true);
|
|
this.d.setHasProgressSpinner(true);
|
|
TapjoyLog.d("TJCorePlacement", "redirect_url:" + this.d.getRedirectURL());
|
|
return;
|
|
} catch (JSONException unused) {
|
|
throw new TapjoyException("TJPlacement request failed, malformed server response");
|
|
}
|
|
}
|
|
throw new TapjoyException("TJPlacement request failed due to null response");
|
|
}
|
|
|
|
public final TJPlacement a(String str) {
|
|
TJPlacement tJPlacement;
|
|
synchronized (this.a) {
|
|
try {
|
|
tJPlacement = (TJPlacement) this.a.get(str);
|
|
if (tJPlacement != null) {
|
|
TapjoyLog.d("TJCorePlacement", "Returning " + str + " placement: " + tJPlacement.getGUID());
|
|
}
|
|
} catch (Throwable th) {
|
|
throw th;
|
|
}
|
|
}
|
|
return tJPlacement;
|
|
}
|
|
|
|
public final void a(TJPlacement tJPlacement) {
|
|
if (tJPlacement == null || tJPlacement.getListener() == null) {
|
|
return;
|
|
}
|
|
TapjoyLog.i("TJCorePlacement", "Content request delivered successfully for placement " + this.d.getPlacementName() + ", contentAvailable: " + isContentAvailable());
|
|
tJPlacement.getListener().onRequestSuccess(tJPlacement);
|
|
}
|
|
|
|
public final void a(TJPlacement tJPlacement, TapjoyErrorMessage.ErrorType errorType, TJError tJError) {
|
|
TapjoyLog.e("TJCorePlacement", new TapjoyErrorMessage(errorType, "Content request failed for placement " + this.d.getPlacementName() + "; Reason= " + tJError.message));
|
|
if (tJPlacement == null || tJPlacement.getListener() == null) {
|
|
return;
|
|
}
|
|
tJPlacement.getListener().onRequestFailure(tJPlacement, tJError);
|
|
}
|
|
|
|
public final void a() {
|
|
if (this.m) {
|
|
return;
|
|
}
|
|
this.o = true;
|
|
TapjoyLog.i("TJCorePlacement", "Content is ready for placement " + this.d.getPlacementName());
|
|
TJPlacement a = a("REQUEST");
|
|
if (a == null || a.getListener() == null) {
|
|
return;
|
|
}
|
|
a.getListener().onContentReady(a);
|
|
this.m = true;
|
|
}
|
|
}
|