package com.tapjoy; import android.content.Context; import android.text.TextUtils; import com.tapjoy.internal.h3; /* loaded from: classes4.dex */ public class TJPlacementManager { public static final h3 a = new h3(); public static int b = 0; public static int c = 0; public static int d = 3; public static int e = 3; public static boolean canCachePlacement() { return getCachedPlacementCount() < getCachedPlacementLimit(); } public static boolean canPreRenderPlacement() { return getPreRenderedPlacementCount() < getPreRenderedPlacementLimit(); } public static TJPlacement createPlacement(Context context, String str, boolean z, TJPlacementListener tJPlacementListener) { TJCorePlacement a2 = a(str, z); a2.k = z; a2.setContext(context); return new TJPlacement(a2, tJPlacementListener); } public static void decrementPlacementPreRenderCount() { int i = c - 1; c = i; if (i < 0) { c = 0; } } public static void dismissContentShowing() { TJAdUnitActivity tJAdUnitActivity = TJAdUnitActivity.i; if (tJAdUnitActivity != null) { tJAdUnitActivity.a(true); } } public static int getCachedPlacementCount() { return b; } public static int getCachedPlacementLimit() { return d; } public static int getPreRenderedPlacementCount() { return c; } public static int getPreRenderedPlacementLimit() { return e; } public static void incrementPlacementPreRenderCount() { int i = c + 1; c = i; int i2 = e; if (i > i2) { c = i2; } } public static void printPlacementCacheInformation() { TapjoyLog.i("TJPlacementManager", "Space available in placement cache: " + b + " out of " + d); } public static void printPlacementPreRenderInformation() { TapjoyLog.i("TJPlacementManager", "Space available for placement pre-render: " + c + " out of " + e); } public static void setCachedPlacementLimit(int i) { d = i; } public static void setPreRenderedPlacementLimit(int i) { e = i; } public static TJCorePlacement a(String str, boolean z) { TJCorePlacement a2; StringBuilder sb = new StringBuilder(); sb.append(z ? "!SYSTEM!" : ""); sb.append(!TextUtils.isEmpty(str) ? str : ""); String sb2 = sb.toString(); TapjoyLog.d("TJPlacementManager", "TJCorePlacement key=" + sb2); h3 h3Var = a; synchronized (h3Var) { try { a2 = a(sb2); if (a2 == null) { a2 = new TJCorePlacement(str, sb2); h3Var.put(sb2, a2); TapjoyLog.d("TJPlacementManager", "Created TJCorePlacement with GUID: " + a2.f); } } catch (Throwable th) { throw th; } } return a2; } public static void decrementPlacementCacheCount() { int i = b - 1; b = i; if (i < 0) { b = 0; } printPlacementCacheInformation(); } public static void incrementPlacementCacheCount() { int i = b + 1; b = i; int i2 = d; if (i > i2) { b = i2; } printPlacementCacheInformation(); } public static TJCorePlacement a(String str) { TJCorePlacement tJCorePlacement; h3 h3Var = a; synchronized (h3Var) { tJCorePlacement = (TJCorePlacement) h3Var.get(str); } return tJCorePlacement; } }