package com.vungle.ads.internal; import android.content.Context; import com.vungle.ads.AnalyticsClient; import com.vungle.ads.VungleAdSize; import com.vungle.ads.VungleError; import com.vungle.ads.internal.AdInternal; import com.vungle.ads.internal.model.AdPayload; import com.vungle.ads.internal.model.Placement; import com.vungle.ads.internal.presenter.AdPlayCallback; import com.vungle.ads.internal.presenter.AdPlayCallbackWrapper; import com.vungle.ads.internal.util.ViewUtility; import kotlin.Pair; import kotlin.jvm.internal.Intrinsics; /* loaded from: classes4.dex */ public final class BannerAdInternal extends AdInternal { private final VungleAdSize adSize; private VungleAdSize updatedAdSize; @Override // com.vungle.ads.internal.AdInternal public VungleAdSize getAdSizeForAdRequest() { return this.adSize; } public final VungleAdSize getUpdatedAdSize$vungle_ads_release() { return this.updatedAdSize; } public final void setUpdatedAdSize$vungle_ads_release(VungleAdSize vungleAdSize) { this.updatedAdSize = vungleAdSize; } /* JADX WARN: 'super' call moved to the top of the method (can break code semantics) */ public BannerAdInternal(Context context, VungleAdSize adSize) { super(context); Intrinsics.checkNotNullParameter(context, "context"); Intrinsics.checkNotNullParameter(adSize, "adSize"); this.adSize = adSize; } public final AdPlayCallbackWrapper wrapCallback$vungle_ads_release(final AdPlayCallback adPlayCallback) { Intrinsics.checkNotNullParameter(adPlayCallback, "adPlayCallback"); return new AdPlayCallbackWrapper(adPlayCallback) { // from class: com.vungle.ads.internal.BannerAdInternal$wrapCallback$1 @Override // com.vungle.ads.internal.presenter.AdPlayCallbackWrapper, com.vungle.ads.internal.presenter.AdPlayCallback public void onAdStart(String str) { this.setAdState(AdInternal.AdState.PLAYING); super.onAdStart(str); } @Override // com.vungle.ads.internal.presenter.AdPlayCallbackWrapper, com.vungle.ads.internal.presenter.AdPlayCallback public void onAdEnd(String str) { this.setAdState(AdInternal.AdState.FINISHED); super.onAdEnd(str); } @Override // com.vungle.ads.internal.presenter.AdPlayCallbackWrapper, com.vungle.ads.internal.presenter.AdPlayCallback public void onFailure(VungleError error) { Intrinsics.checkNotNullParameter(error, "error"); this.setAdState(AdInternal.AdState.ERROR); super.onFailure(error); } }; } @Override // com.vungle.ads.internal.AdInternal public boolean isValidAdTypeForPlacement(Placement placement) { Intrinsics.checkNotNullParameter(placement, "placement"); return placement.isBanner() || placement.isMREC() || placement.isInline(); } @Override // com.vungle.ads.internal.AdInternal public boolean isValidAdSize(VungleAdSize vungleAdSize) { boolean isValidSize$vungle_ads_release = vungleAdSize != null ? vungleAdSize.isValidSize$vungle_ads_release() : false; if (!isValidSize$vungle_ads_release) { AnalyticsClient analyticsClient = AnalyticsClient.INSTANCE; String str = "Invalidate size " + vungleAdSize + " for banner ad"; Placement placement = getPlacement(); String referenceId = placement != null ? placement.getReferenceId() : null; AdPayload advertisement = getAdvertisement(); analyticsClient.logError$vungle_ads_release(500, str, (r13 & 4) != 0 ? null : referenceId, (r13 & 8) != 0 ? null : null, (r13 & 16) != 0 ? null : advertisement != null ? advertisement.eventId() : null); } return isValidSize$vungle_ads_release; } @Override // com.vungle.ads.internal.AdInternal public void adLoadedAndUpdateConfigure$vungle_ads_release(AdPayload advertisement) { Intrinsics.checkNotNullParameter(advertisement, "advertisement"); super.adLoadedAndUpdateConfigure$vungle_ads_release(advertisement); if (this.adSize.isAdaptiveWidth$vungle_ads_release() || this.adSize.isAdaptiveHeight$vungle_ads_release()) { Pair deviceWidthAndHeightWithOrientation = ViewUtility.INSTANCE.getDeviceWidthAndHeightWithOrientation(getContext(), 0); int intValue = ((Number) deviceWidthAndHeightWithOrientation.component1()).intValue(); int intValue2 = ((Number) deviceWidthAndHeightWithOrientation.component2()).intValue(); int adWidth = this.adSize.isAdaptiveWidth$vungle_ads_release() ? advertisement.adWidth() : this.adSize.getWidth(); int adHeight = this.adSize.isAdaptiveHeight$vungle_ads_release() ? advertisement.adHeight() : this.adSize.getHeight(); int min = Math.min(intValue, adWidth); int min2 = Math.min(intValue2, adHeight); if (this.adSize.isAdaptiveHeight$vungle_ads_release() && this.adSize.getHeight() > 0) { min2 = Math.min(this.adSize.getHeight(), min2); } this.updatedAdSize = new VungleAdSize(min, min2); } } }