Check if interstital is loading before load a new one

This commit is contained in:
FalsinSoft
2019-01-31 23:25:10 +01:00
parent 6f727f56fb
commit 563c3ecefe
3 changed files with 8 additions and 4 deletions

View File

@@ -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()

View File

@@ -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();
}
}
}

View File

@@ -1,5 +1,5 @@
# QtAndroidTools
QtAndroidTools is a library that allows to simplify access to some native Android features from Qt C++ and QML.
QtAndroidTools is a library that allows to simplify access to some native Android features from QML.
# The tools