Skip to content

Instantly share code, notes, and snippets.

@Majirefy
Created March 20, 2017 01:58
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Majirefy/c77a2031d443e38f5be1a8837907e9ed to your computer and use it in GitHub Desktop.
Save Majirefy/c77a2031d443e38f5be1a8837907e9ed to your computer and use it in GitHub Desktop.
constructor(adView: AdView?, context: Context) {
this.adView = adView
this.context = context
interstitialAd = InterstitialAd(context)
interstitialAd.adUnitId = GameSettings.ADMOB_INTERSTITIAL_ID
interstitialAd.adListener = object : AdListener() {
override fun onAdClosed() {
requestNewInterstitial()
super.onAdClosed()
}
}
requestNewInterstitial()
handler = object : Handler() {
override fun handleMessage(msg: Message) {
when (msg.what) {
HIDE -> {
adView?.visibility = View.GONE
}
SHOW -> {
adView?.visibility = View.VISIBLE
}
}
}
}
}
private fun requestNewInterstitial() {
val adRequestBuilder = AdRequest.Builder()
adRequestBuilder.addTestDevice(AdRequest.DEVICE_ID_EMULATOR)
interstitialAd.loadAd(adRequestBuilder.build())
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment