package com.vungle.ads; import android.content.Context; import com.vungle.ads.internal.ConfigManager; import com.vungle.ads.internal.model.Placement; import com.vungle.ads.internal.protos.Sdk; import com.vungle.ads.internal.util.ViewUtility; import kotlin.jvm.internal.DefaultConstructorMarker; import kotlin.jvm.internal.Intrinsics; /* loaded from: classes4.dex */ public final class VungleAdSize { private final int height; private boolean isAdaptiveHeight; private boolean isAdaptiveWidth; private final int width; public static final Companion Companion = new Companion(null); public static final VungleAdSize BANNER = new VungleAdSize(Sdk.SDKError.Reason.WEBVIEW_ERROR_VALUE, 50); public static final VungleAdSize BANNER_SHORT = new VungleAdSize(300, 50); public static final VungleAdSize BANNER_LEADERBOARD = new VungleAdSize(728, 90); public static final VungleAdSize MREC = new VungleAdSize(300, 250); public static final VungleAdSize getAdSizeWithWidth(Context context, int i) { return Companion.getAdSizeWithWidth(context, i); } public static final VungleAdSize getAdSizeWithWidthAndHeight(int i, int i2) { return Companion.getAdSizeWithWidthAndHeight(i, i2); } public static final VungleAdSize getAdSizeWithWidthAndMaxHeight(int i, int i2) { return Companion.getAdSizeWithWidthAndMaxHeight(i, i2); } public static final VungleAdSize getValidAdSizeFromSize(int i, int i2, String str) { return Companion.getValidAdSizeFromSize(i, i2, str); } public final int getHeight() { return this.height; } public final int getWidth() { return this.width; } public final boolean isAdaptiveHeight$vungle_ads_release() { return this.isAdaptiveHeight; } public final boolean isAdaptiveWidth$vungle_ads_release() { return this.isAdaptiveWidth; } public final boolean isValidSize$vungle_ads_release() { return this.width >= 0 && this.height >= 0; } public final void setAdaptiveHeight$vungle_ads_release(boolean z) { this.isAdaptiveHeight = z; } public final void setAdaptiveWidth$vungle_ads_release(boolean z) { this.isAdaptiveWidth = z; } public VungleAdSize(int i, int i2) { this.width = i; this.height = i2; } public static final class Companion { public /* synthetic */ Companion(DefaultConstructorMarker defaultConstructorMarker) { this(); } private Companion() { } public final VungleAdSize getAdSizeWithWidth(Context context, int i) { Intrinsics.checkNotNullParameter(context, "context"); int intValue = ((Number) ViewUtility.INSTANCE.getDeviceWidthAndHeightWithOrientation(context, 0).component2()).intValue(); if (i < 0) { i = 0; } VungleAdSize vungleAdSize = new VungleAdSize(i, intValue); if (vungleAdSize.getWidth() == 0) { vungleAdSize.setAdaptiveWidth$vungle_ads_release(true); } vungleAdSize.setAdaptiveHeight$vungle_ads_release(true); return vungleAdSize; } public final VungleAdSize getAdSizeWithWidthAndMaxHeight(int i, int i2) { if (i < 0) { i = 0; } if (i2 < 0) { i2 = 0; } VungleAdSize vungleAdSize = new VungleAdSize(i, i2); if (vungleAdSize.getWidth() == 0) { vungleAdSize.setAdaptiveWidth$vungle_ads_release(true); } vungleAdSize.setAdaptiveHeight$vungle_ads_release(true); return vungleAdSize; } public final VungleAdSize getAdSizeWithWidthAndHeight(int i, int i2) { if (i < 0) { i = 0; } if (i2 < 0) { i2 = 0; } VungleAdSize vungleAdSize = new VungleAdSize(i, i2); if (vungleAdSize.getWidth() == 0) { vungleAdSize.setAdaptiveWidth$vungle_ads_release(true); } if (vungleAdSize.getHeight() == 0) { vungleAdSize.setAdaptiveHeight$vungle_ads_release(true); } return vungleAdSize; } public final VungleAdSize getValidAdSizeFromSize(int i, int i2, String placementId) { Intrinsics.checkNotNullParameter(placementId, "placementId"); Placement placement = ConfigManager.INSTANCE.getPlacement(placementId); if (placement != null) { if (!placement.isInline()) { placement = null; } if (placement != null) { return VungleAdSize.Companion.getAdSizeWithWidthAndHeight(i, i2); } } VungleAdSize vungleAdSize = VungleAdSize.MREC; if (i >= vungleAdSize.getWidth() && i2 >= vungleAdSize.getHeight()) { return vungleAdSize; } VungleAdSize vungleAdSize2 = VungleAdSize.BANNER_LEADERBOARD; if (i >= vungleAdSize2.getWidth() && i2 >= vungleAdSize2.getHeight()) { return vungleAdSize2; } VungleAdSize vungleAdSize3 = VungleAdSize.BANNER; if (i >= vungleAdSize3.getWidth() && i2 >= vungleAdSize3.getHeight()) { return vungleAdSize3; } VungleAdSize vungleAdSize4 = VungleAdSize.BANNER_SHORT; return (i < vungleAdSize4.getWidth() || i2 < vungleAdSize4.getHeight()) ? getAdSizeWithWidthAndHeight(i, i2) : vungleAdSize4; } } public String toString() { return "VungleAdSize(width=" + this.width + ", height=" + this.height + ')'; } }