From e9ea621b93fbb58d9edfca8375918791637bbd52 Mon Sep 17 00:00:00 2001 From: chai Date: Wed, 30 Dec 2020 20:59:04 +0800 Subject: +init --- .../GoogleMobileAds/Api/RewardBasedVideoAd.cs | 125 +++++++++++++++++++++ 1 file changed, 125 insertions(+) create mode 100644 Client/Assembly-CSharp/GoogleMobileAds/Api/RewardBasedVideoAd.cs (limited to 'Client/Assembly-CSharp/GoogleMobileAds/Api/RewardBasedVideoAd.cs') diff --git a/Client/Assembly-CSharp/GoogleMobileAds/Api/RewardBasedVideoAd.cs b/Client/Assembly-CSharp/GoogleMobileAds/Api/RewardBasedVideoAd.cs new file mode 100644 index 0000000..90f069a --- /dev/null +++ b/Client/Assembly-CSharp/GoogleMobileAds/Api/RewardBasedVideoAd.cs @@ -0,0 +1,125 @@ +using System; +using System.Reflection; +using GoogleMobileAds.Common; + +namespace GoogleMobileAds.Api +{ + public class RewardBasedVideoAd + { + public static RewardBasedVideoAd Instance + { + get + { + return RewardBasedVideoAd.instance; + } + } + + public event EventHandler OnAdLoaded; + + public event EventHandler OnAdFailedToLoad; + + public event EventHandler OnAdOpening; + + public event EventHandler OnAdStarted; + + public event EventHandler OnAdClosed; + + public event EventHandler OnAdRewarded; + + public event EventHandler OnAdLeavingApplication; + + public event EventHandler OnAdCompleted; + + private IRewardBasedVideoAdClient client; + + private static readonly RewardBasedVideoAd instance = new RewardBasedVideoAd(); + + private RewardBasedVideoAd() + { + MethodInfo method = Type.GetType("GoogleMobileAds.GoogleMobileAdsClientFactory,Assembly-CSharp").GetMethod("BuildRewardBasedVideoAdClient", BindingFlags.Static | BindingFlags.Public); + this.client = (IRewardBasedVideoAdClient)method.Invoke(null, null); + this.client.CreateRewardBasedVideoAd(); + 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.OnAdStarted += delegate(object sender, EventArgs args) + { + if (this.OnAdStarted != null) + { + this.OnAdStarted(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); + } + }; + this.client.OnAdRewarded += delegate(object sender, Reward args) + { + if (this.OnAdRewarded != null) + { + this.OnAdRewarded(this, args); + } + }; + this.client.OnAdCompleted += delegate(object sender, EventArgs args) + { + if (this.OnAdCompleted != null) + { + this.OnAdCompleted(this, args); + } + }; + } + + public void LoadAd(AdRequest request, string adUnitId) + { + this.client.LoadAd(request, adUnitId); + } + + public bool IsLoaded() + { + return this.client.IsLoaded(); + } + + public void Show() + { + this.client.ShowRewardBasedVideoAd(); + } + + public void SetUserId(string userId) + { + this.client.SetUserId(userId); + } + + public string MediationAdapterClassName() + { + return this.client.MediationAdapterClassName(); + } + } +} -- cgit v1.1-26-g67d0