Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add adaptive ad format #5

Merged
merged 3 commits into from
Sep 8, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,8 @@
Note the first digit of every adapter version corresponds to the major version of the Chartboost Mediation SDK compatible with that adapter.
Adapters are compatible with any Chartboost Mediation SDK version within that major version.

### 4.2.17.0.1
- Updated to handle recent AdFormat changes.

### 4.2.17.0.0
- This version of the adapter has been certified with HyBid SDK 2.17.0.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ The Chartboost Mediation Verve adapter mediates HyBid via the Chartboost Mediati

In your `build.gradle`, add the following entry:
```
implementation "com.chartboost:chartboost-mediation-adapter-verve:4.2.17.0.0"
implementation "com.chartboost:chartboost-mediation-adapter-verve:4.2.17.0.1"
```

## Contributions
Expand Down
2 changes: 1 addition & 1 deletion VerveAdapter/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ android {
minSdk = 21
targetSdk = 33
// If you touch the following line, don't forget to update scripts/get_rc_version.zsh
android.defaultConfig.versionName = System.getenv("VERSION_OVERRIDE") ?: "4.2.17.0.0"
android.defaultConfig.versionName = System.getenv("VERSION_OVERRIDE") ?: "4.2.17.0.1"
buildConfigField("String", "CHARTBOOST_MEDIATION_VERVE_ADAPTER_VERSION", "\"${android.defaultConfig.versionName}\"")

consumerProguardFiles("proguard-rules.pro")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -187,9 +187,9 @@ class VerveAdapter : PartnerAdapter {
): Result<PartnerAd> {
PartnerLogController.log(LOAD_STARTED)

return when (request.format) {
AdFormat.BANNER -> loadBannerAd(context, request, partnerAdListener)
AdFormat.INTERSTITIAL, AdFormat.REWARDED -> loadFullscreenAd(context, request, partnerAdListener)
return when (request.format.key) {
AdFormat.BANNER.key, "adaptive_banner" -> loadBannerAd(context, request, partnerAdListener)
AdFormat.INTERSTITIAL.key, AdFormat.REWARDED.key -> loadFullscreenAd(context, request, partnerAdListener)
else -> {
PartnerLogController.log(LOAD_FAILED)
Result.failure(ChartboostMediationAdException(ChartboostMediationError.CM_LOAD_FAILURE_UNSUPPORTED_AD_FORMAT))
Expand Down Expand Up @@ -217,20 +217,20 @@ class VerveAdapter : PartnerAdapter {
}
}

return when (partnerAd.request.format) {
AdFormat.BANNER -> {
return when (partnerAd.request.format.key) {
AdFormat.BANNER.key, "adaptive_banner" -> {
PartnerLogController.log(SHOW_SUCCEEDED)
Result.success(partnerAd)
}
AdFormat.INTERSTITIAL -> {
AdFormat.INTERSTITIAL.key -> {
loadIdToHyBidInterstitialAds[partnerAd.request.identifier]?.let {
showAdIfReady(it::isReady, it::show)
} ?: run {
PartnerLogController.log(SHOW_FAILED, "Ad is null.")
Result.failure(ChartboostMediationAdException(ChartboostMediationError.CM_INVALIDATE_FAILURE_AD_NOT_FOUND))
}
}
AdFormat.REWARDED -> {
AdFormat.REWARDED.key -> {
loadIdToHyBidRewardedAds[partnerAd.request.identifier]?.let {
showAdIfReady(it::isReady, it::show)
} ?: run {
Expand All @@ -255,9 +255,9 @@ class VerveAdapter : PartnerAdapter {
override suspend fun invalidate(partnerAd: PartnerAd): Result<PartnerAd> {
PartnerLogController.log(INVALIDATE_STARTED)

return when (partnerAd.request.format) {
AdFormat.BANNER -> destroyBannerAd(partnerAd)
AdFormat.INTERSTITIAL, AdFormat.REWARDED -> destroyFullscreenAd(partnerAd)
return when (partnerAd.request.format.key) {
AdFormat.BANNER.key, "adaptive_banner" -> destroyBannerAd(partnerAd)
AdFormat.INTERSTITIAL.key, AdFormat.REWARDED.key -> destroyFullscreenAd(partnerAd)
else -> {
PartnerLogController.log(INVALIDATE_SUCCEEDED)
Result.success(partnerAd)
Expand Down Expand Up @@ -444,8 +444,8 @@ class VerveAdapter : PartnerAdapter {
listener: PartnerAdListener
): Result<PartnerAd> {
return suspendCancellableCoroutine { continuation ->
when(request.format) {
AdFormat.INTERSTITIAL -> {
when(request.format.key) {
AdFormat.INTERSTITIAL.key -> {
HyBidInterstitialAd(
context,
request.partnerPlacement,
Expand All @@ -459,7 +459,7 @@ class VerveAdapter : PartnerAdapter {
}
}
}
AdFormat.REWARDED -> {
AdFormat.REWARDED.key -> {
HyBidRewardedAd(
context,
request.partnerPlacement,
Expand Down Expand Up @@ -618,16 +618,16 @@ class VerveAdapter : PartnerAdapter {
return Result.success(partnerAd)
}

return when (partnerAd.request.format) {
AdFormat.INTERSTITIAL -> {
return when (partnerAd.request.format.key) {
AdFormat.INTERSTITIAL.key -> {
loadIdToHyBidInterstitialAds.remove(partnerAd.request.identifier)?.let {
destroyAd(it::destroy)
} ?: run {
PartnerLogController.log(INVALIDATE_SUCCEEDED, "Ad is already null.")
Result.success(partnerAd)
}
}
AdFormat.REWARDED-> {
AdFormat.REWARDED.key-> {
loadIdToHyBidRewardedAds.remove(partnerAd.request.identifier)?.let {
destroyAd(it::destroy)
} ?: run {
Expand Down