diff options
author | chai <chaifix@163.com> | 2020-12-30 20:59:04 +0800 |
---|---|---|
committer | chai <chaifix@163.com> | 2020-12-30 20:59:04 +0800 |
commit | e9ea621b93fbb58d9edfca8375918791637bbd52 (patch) | |
tree | 19ce3b1c1f2d51eda6878c9d0f2c9edc27f13650 /Client/Assembly-CSharp/GoogleMobileAds/Api/InterstitialAd.cs |
+init
Diffstat (limited to 'Client/Assembly-CSharp/GoogleMobileAds/Api/InterstitialAd.cs')
-rw-r--r-- | Client/Assembly-CSharp/GoogleMobileAds/Api/InterstitialAd.cs | 88 |
1 files changed, 88 insertions, 0 deletions
diff --git a/Client/Assembly-CSharp/GoogleMobileAds/Api/InterstitialAd.cs b/Client/Assembly-CSharp/GoogleMobileAds/Api/InterstitialAd.cs new file mode 100644 index 0000000..e9817bb --- /dev/null +++ b/Client/Assembly-CSharp/GoogleMobileAds/Api/InterstitialAd.cs @@ -0,0 +1,88 @@ +using System; +using System.Reflection; +using GoogleMobileAds.Common; + +namespace GoogleMobileAds.Api +{ + public class InterstitialAd + { + public event EventHandler<EventArgs> OnAdLoaded; + + public event EventHandler<AdFailedToLoadEventArgs> OnAdFailedToLoad; + + public event EventHandler<EventArgs> OnAdOpening; + + public event EventHandler<EventArgs> OnAdClosed; + + public event EventHandler<EventArgs> OnAdLeavingApplication; + + private IInterstitialClient client; + + public InterstitialAd(string adUnitId) + { + MethodInfo method = Type.GetType("GoogleMobileAds.GoogleMobileAdsClientFactory,Assembly-CSharp").GetMethod("BuildInterstitialClient", BindingFlags.Static | BindingFlags.Public); + this.client = (IInterstitialClient)method.Invoke(null, null); + this.client.CreateInterstitialAd(adUnitId); + this.client.OnAdLoaded += delegate(object sender, EventArgs args) + { + if (this.OnAdLoaded != null) + { + this.OnAdLoaded(this, args); + } + }; + this.client.OnAdFailedToLoad += delegate(object sender, AdFailedToLoadEventArgs args) + { + if (this.OnAdFailedToLoad != null) + { + this.OnAdFailedToLoad(this, args); + } + }; + this.client.OnAdOpening += delegate(object sender, EventArgs args) + { + if (this.OnAdOpening != null) + { + this.OnAdOpening(this, args); + } + }; + this.client.OnAdClosed += delegate(object sender, EventArgs args) + { + if (this.OnAdClosed != null) + { + this.OnAdClosed(this, args); + } + }; + this.client.OnAdLeavingApplication += delegate(object sender, EventArgs args) + { + if (this.OnAdLeavingApplication != null) + { + this.OnAdLeavingApplication(this, args); + } + }; + } + + public void LoadAd(AdRequest request) + { + this.client.LoadAd(request); + } + + public bool IsLoaded() + { + return this.client.IsLoaded(); + } + + public void Show() + { + this.client.ShowInterstitial(); + } + + public void Destroy() + { + this.client.DestroyInterstitial(); + } + + public string MediationAdapterClassName() + { + return this.client.MediationAdapterClassName(); + } + } +} |