summaryrefslogtreecommitdiff
path: root/Client/Assembly-CSharp/GoogleMobileAds/Api/BannerView.cs
diff options
context:
space:
mode:
Diffstat (limited to 'Client/Assembly-CSharp/GoogleMobileAds/Api/BannerView.cs')
-rw-r--r--Client/Assembly-CSharp/GoogleMobileAds/Api/BannerView.cs121
1 files changed, 121 insertions, 0 deletions
diff --git a/Client/Assembly-CSharp/GoogleMobileAds/Api/BannerView.cs b/Client/Assembly-CSharp/GoogleMobileAds/Api/BannerView.cs
new file mode 100644
index 0000000..7ad2724
--- /dev/null
+++ b/Client/Assembly-CSharp/GoogleMobileAds/Api/BannerView.cs
@@ -0,0 +1,121 @@
+using System;
+using System.Reflection;
+using GoogleMobileAds.Common;
+
+namespace GoogleMobileAds.Api
+{
+ public class BannerView
+ {
+ 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 IBannerClient client;
+
+ public BannerView(string adUnitId, AdSize adSize, AdPosition position)
+ {
+ MethodInfo method = Type.GetType("GoogleMobileAds.GoogleMobileAdsClientFactory,Assembly-CSharp").GetMethod("BuildBannerClient", BindingFlags.Static | BindingFlags.Public);
+ this.client = (IBannerClient)method.Invoke(null, null);
+ this.client.CreateBannerView(adUnitId, adSize, position);
+ this.ConfigureBannerEvents();
+ }
+
+ public BannerView(string adUnitId, AdSize adSize, int x, int y)
+ {
+ MethodInfo method = Type.GetType("GoogleMobileAds.GoogleMobileAdsClientFactory,Assembly-CSharp").GetMethod("BuildBannerClient", BindingFlags.Static | BindingFlags.Public);
+ this.client = (IBannerClient)method.Invoke(null, null);
+ this.client.CreateBannerView(adUnitId, adSize, x, y);
+ this.ConfigureBannerEvents();
+ }
+
+ public void LoadAd(AdRequest request)
+ {
+ this.client.LoadAd(request);
+ }
+
+ public void Hide()
+ {
+ this.client.HideBannerView();
+ }
+
+ public void Show()
+ {
+ this.client.ShowBannerView();
+ }
+
+ public void Destroy()
+ {
+ this.client.DestroyBannerView();
+ }
+
+ public float GetHeightInPixels()
+ {
+ return this.client.GetHeightInPixels();
+ }
+
+ public float GetWidthInPixels()
+ {
+ return this.client.GetWidthInPixels();
+ }
+
+ public void SetPosition(AdPosition adPosition)
+ {
+ this.client.SetPosition(adPosition);
+ }
+
+ public void SetPosition(int x, int y)
+ {
+ this.client.SetPosition(x, y);
+ }
+
+ private void ConfigureBannerEvents()
+ {
+ 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 string MediationAdapterClassName()
+ {
+ return this.client.MediationAdapterClassName();
+ }
+ }
+}