Skip to content

Commit

Permalink
[HB-5107] 3rd round listener fixes and hardening (#37)
Browse files Browse the repository at this point in the history
* [HB-5107] 3rd round listener fixes and hardening
* .1 updates for CM sdk 4.0.0 hard peg
  • Loading branch information
bichenwang authored Mar 24, 2023
1 parent 64afae0 commit a8633e1
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 8 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,14 @@
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.6.12.1.1
- Update the dependency on Chartboost Mediation SDK to 4.0.0.

### 4.6.12.1.0
- This version of the adapter has been certified with Vungle SDK 6.12.1.

### 4.6.12.0.1
- Update the dependency on Chartboost Mediation SDK to 4.0.0.

### 4.6.12.0.0
- This version of the adapter has been certified with Vungle SDK 6.12.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 Vungle adapter mediates Vungle via the Chartboost Media

In your `build.gradle`, add the following entry:
```
implementation "com.chartboost:chartboost-mediation-adapter-vungle:4.6.12.0.0"
implementation "com.chartboost:chartboost-mediation-adapter-vungle:4.6.12.1.1"
```

## Contributions
Expand Down
4 changes: 2 additions & 2 deletions VungleAdapter/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,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.6.12.1.0"
android.defaultConfig.versionName = System.getenv("VERSION_OVERRIDE") ?: "4.6.12.1.1"
buildConfigField("String", "CHARTBOOST_MEDIATION_VUNGLE_ADAPTER_VERSION", "\"${android.defaultConfig.versionName}\"")

testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
Expand Down Expand Up @@ -67,7 +67,7 @@ dependencies {

// For external usage, please use the following production dependency.
// You may choose a different release version.
"remoteImplementation"("com.chartboost:chartboost-mediation-sdk:4.+")
"remoteImplementation"("com.chartboost:chartboost-mediation-sdk:4.0.0")

// Partner SDK
implementation("com.vungle:publisher-sdk-android:6.12.1")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ class VungleAdapter : PartnerAdapter {
}

/**
* A map of Chartboost Mediation's listeners for the corresponding Chartboost placements.
* A map of Chartboost Mediation's listeners for the corresponding load identifier.
*/
private val listeners = mutableMapOf<String, PartnerAdListener>()

Expand Down Expand Up @@ -359,6 +359,10 @@ class VungleAdapter : PartnerAdapter {
AdFormat.INTERSTITIAL, AdFormat.REWARDED -> {
loadFullscreenAd(request, partnerAdListener)
}
else -> {
PartnerLogController.log(LOAD_FAILED)
Result.failure(ChartboostMediationAdException(ChartboostMediationError.CM_LOAD_FAILURE_UNSUPPORTED_AD_FORMAT))
}
}
}

Expand All @@ -373,7 +377,7 @@ class VungleAdapter : PartnerAdapter {
override suspend fun show(context: Context, partnerAd: PartnerAd): Result<PartnerAd> {
PartnerLogController.log(SHOW_STARTED)

val listener = listeners.remove(partnerAd.request.chartboostPlacement)
val listener = listeners.remove(partnerAd.request.identifier)

return when (partnerAd.request.format) {
// Banner ads do not have a separate "show" mechanism.
Expand All @@ -382,6 +386,10 @@ class VungleAdapter : PartnerAdapter {
Result.success(partnerAd)
}
AdFormat.INTERSTITIAL, AdFormat.REWARDED -> showFullscreenAd(partnerAd, listener)
else -> {
PartnerLogController.log(SHOW_FAILED)
Result.failure(ChartboostMediationAdException(ChartboostMediationError.CM_SHOW_FAILURE_UNSUPPORTED_AD_FORMAT))
}
}
}

Expand All @@ -395,7 +403,7 @@ class VungleAdapter : PartnerAdapter {
override suspend fun invalidate(partnerAd: PartnerAd): Result<PartnerAd> {
PartnerLogController.log(INVALIDATE_STARTED)

listeners.remove(partnerAd.request.chartboostPlacement)
listeners.remove(partnerAd.request.identifier)
adms.remove(partnerAd.request.partnerPlacement)

return when (partnerAd.request.format) {
Expand All @@ -405,7 +413,7 @@ class VungleAdapter : PartnerAdapter {
* have an ad in PartnerAd to invalidate.
*/
AdFormat.BANNER -> destroyBannerAd(partnerAd)
AdFormat.INTERSTITIAL, AdFormat.REWARDED -> {
else -> {
PartnerLogController.log(INVALIDATE_SUCCEEDED)
Result.success(partnerAd)
}
Expand Down Expand Up @@ -593,7 +601,7 @@ class VungleAdapter : PartnerAdapter {
listener: PartnerAdListener
): Result<PartnerAd> {
// Save the listener for later use.
listeners[request.chartboostPlacement] = listener
listeners[request.identifier] = listener

// Vungle needs a nullable adm instead of an empty string for non-programmatic ads.
val adm = if (request.adm?.isEmpty() == true) null else request.adm
Expand Down

0 comments on commit a8633e1

Please sign in to comment.