mirror of
https://github.com/allankoechke/QtAndroidTools.git
synced 2026-12-03 01:06:44 +00:00
Check if interstital is loading before load a new one
This commit is contained in:
@@ -44,6 +44,7 @@ public class AdMobInterstitial
|
||||
private final InterstitialListener mInterstitialListener;
|
||||
|
||||
private InterstitialAd mInterstitialAd = null;
|
||||
private boolean mInterstitialAdLoaded = false;
|
||||
|
||||
public AdMobInterstitial(Activity ActivityInstance)
|
||||
{
|
||||
@@ -83,13 +84,14 @@ public class AdMobInterstitial
|
||||
AdRequest.Builder InterstitialRequest = new AdRequest.Builder();
|
||||
mInterstitialAd.loadAd(InterstitialRequest.build());
|
||||
interstitialEvent(EVENT_LOADING);
|
||||
mInterstitialAdLoaded = false;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public void show()
|
||||
{
|
||||
if(mInterstitialAd == null)
|
||||
if(mInterstitialAd == null || mInterstitialAdLoaded == false)
|
||||
{
|
||||
return;
|
||||
}
|
||||
@@ -149,6 +151,7 @@ public class AdMobInterstitial
|
||||
{
|
||||
public void runOnUIThread()
|
||||
{
|
||||
mInterstitialAdLoaded = false;
|
||||
mInterstitialAd = null;
|
||||
}
|
||||
});
|
||||
@@ -160,6 +163,7 @@ public class AdMobInterstitial
|
||||
public void onAdLoaded()
|
||||
{
|
||||
interstitialEvent(EVENT_LOADED);
|
||||
mInterstitialAdLoaded = true;
|
||||
}
|
||||
|
||||
public void onAdClosed()
|
||||
|
||||
@@ -39,12 +39,12 @@ Page {
|
||||
Button {
|
||||
anchors.horizontalCenter: parent.horizontalCenter
|
||||
text: "Load interstitial"
|
||||
onClicked: banner1.load();
|
||||
onClicked: interstitial.load();
|
||||
}
|
||||
Button {
|
||||
anchors.horizontalCenter: parent.horizontalCenter
|
||||
text: "Show interstitial"
|
||||
onClicked: banner1.show();
|
||||
onClicked: interstitial.show();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user