Last active
July 4, 2019 08:05
-
-
Save arohim/404ef7e739436eb02e04123e0e238631 to your computer and use it in GitHub Desktop.
Ad Publisher maker with Adomik
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
private fun makePublisherAdView(context: Context, adUnitId: String, adomik: String): PublisherAdView { | |
val publisherAdView = PublisherAdView(context) | |
publisherAdView.adUnitId = adUnitId | |
publisherAdView.setAdSizes(AdSize.MEDIUM_RECTANGLE) | |
val adRequest = PublisherAdRequest.Builder().addCustomTargeting("ad_group", adomik) | |
publisherAdView.loadAd(adRequest.build()) | |
return publisherAdView | |
} | |
/** | |
* Adomik | |
* | |
*/ | |
fun adomikSplitAdGroup(): String { | |
val randomNum = Random().nextInt(98).toDouble() / 100 | |
return when { | |
randomNum < 0.09 -> "ad_ex" + floor(100 * randomNum).toInt().toString() | |
randomNum < 0.10 -> "ad_bc" | |
else -> "ad_opt" | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment