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/Common |
+init
Diffstat (limited to 'Client/Assembly-CSharp/GoogleMobileAds/Common')
11 files changed, 530 insertions, 0 deletions
diff --git a/Client/Assembly-CSharp/GoogleMobileAds/Common/DummyClient.cs b/Client/Assembly-CSharp/GoogleMobileAds/Common/DummyClient.cs new file mode 100644 index 0000000..91587cc --- /dev/null +++ b/Client/Assembly-CSharp/GoogleMobileAds/Common/DummyClient.cs @@ -0,0 +1,185 @@ +using System; +using System.Reflection; +using GoogleMobileAds.Api; +using UnityEngine; + +namespace GoogleMobileAds.Common +{ + public class DummyClient : IBannerClient, IInterstitialClient, IRewardBasedVideoAdClient, IAdLoaderClient, IMobileAdsClient + { + public string UserId + { + get + { + Debug.Log("Dummy " + MethodBase.GetCurrentMethod().Name); + return "UserId"; + } + set + { + Debug.Log("Dummy " + MethodBase.GetCurrentMethod().Name); + } + } + + public event EventHandler<EventArgs> OnAdLoaded; + + public event EventHandler<AdFailedToLoadEventArgs> OnAdFailedToLoad; + + public event EventHandler<EventArgs> OnAdOpening; + + public event EventHandler<EventArgs> OnAdStarted; + + public event EventHandler<EventArgs> OnAdClosed; + + public event EventHandler<Reward> OnAdRewarded; + + public event EventHandler<EventArgs> OnAdLeavingApplication; + + public event EventHandler<EventArgs> OnAdCompleted; + + public event EventHandler<CustomNativeEventArgs> OnCustomNativeTemplateAdLoaded; + + public DummyClient() + { + Debug.Log("Dummy " + MethodBase.GetCurrentMethod().Name); + } + + public void Initialize(string appId) + { + Debug.Log("Dummy " + MethodBase.GetCurrentMethod().Name); + } + + public void SetApplicationMuted(bool muted) + { + Debug.Log("Dummy " + MethodBase.GetCurrentMethod().Name); + } + + public void SetApplicationVolume(float volume) + { + Debug.Log("Dummy " + MethodBase.GetCurrentMethod().Name); + } + + public void SetiOSAppPauseOnBackground(bool pause) + { + Debug.Log("Dummy " + MethodBase.GetCurrentMethod().Name); + } + + public void CreateBannerView(string adUnitId, AdSize adSize, AdPosition position) + { + Debug.Log("Dummy " + MethodBase.GetCurrentMethod().Name); + } + + public void CreateBannerView(string adUnitId, AdSize adSize, int positionX, int positionY) + { + Debug.Log("Dummy " + MethodBase.GetCurrentMethod().Name); + } + + public void LoadAd(AdRequest request) + { + Debug.Log("Dummy " + MethodBase.GetCurrentMethod().Name); + } + + public void ShowBannerView() + { + Debug.Log("Dummy " + MethodBase.GetCurrentMethod().Name); + } + + public void HideBannerView() + { + Debug.Log("Dummy " + MethodBase.GetCurrentMethod().Name); + } + + public void DestroyBannerView() + { + Debug.Log("Dummy " + MethodBase.GetCurrentMethod().Name); + } + + public float GetHeightInPixels() + { + Debug.Log("Dummy " + MethodBase.GetCurrentMethod().Name); + return 0f; + } + + public float GetWidthInPixels() + { + Debug.Log("Dummy " + MethodBase.GetCurrentMethod().Name); + return 0f; + } + + public void SetPosition(AdPosition adPosition) + { + Debug.Log("Dummy " + MethodBase.GetCurrentMethod().Name); + } + + public void SetPosition(int x, int y) + { + Debug.Log("Dummy " + MethodBase.GetCurrentMethod().Name); + } + + public void CreateInterstitialAd(string adUnitId) + { + Debug.Log("Dummy " + MethodBase.GetCurrentMethod().Name); + } + + public bool IsLoaded() + { + Debug.Log("Dummy " + MethodBase.GetCurrentMethod().Name); + return true; + } + + public void ShowInterstitial() + { + Debug.Log("Dummy " + MethodBase.GetCurrentMethod().Name); + } + + public void DestroyInterstitial() + { + Debug.Log("Dummy " + MethodBase.GetCurrentMethod().Name); + } + + public void CreateRewardBasedVideoAd() + { + Debug.Log("Dummy " + MethodBase.GetCurrentMethod().Name); + } + + public void SetUserId(string userId) + { + Debug.Log("Dummy " + MethodBase.GetCurrentMethod().Name); + } + + public void LoadAd(AdRequest request, string adUnitId) + { + Debug.Log("Dummy " + MethodBase.GetCurrentMethod().Name); + } + + public void DestroyRewardBasedVideoAd() + { + Debug.Log("Dummy " + MethodBase.GetCurrentMethod().Name); + } + + public void ShowRewardBasedVideoAd() + { + Debug.Log("Dummy " + MethodBase.GetCurrentMethod().Name); + } + + public void CreateAdLoader(AdLoader.Builder builder) + { + Debug.Log("Dummy " + MethodBase.GetCurrentMethod().Name); + } + + public void Load(AdRequest request) + { + Debug.Log("Dummy " + MethodBase.GetCurrentMethod().Name); + } + + public void SetAdSize(AdSize adSize) + { + Debug.Log("Dummy " + MethodBase.GetCurrentMethod().Name); + } + + public string MediationAdapterClassName() + { + Debug.Log("Dummy " + MethodBase.GetCurrentMethod().Name); + return null; + } + } +} diff --git a/Client/Assembly-CSharp/GoogleMobileAds/Common/IAdLoaderClient.cs b/Client/Assembly-CSharp/GoogleMobileAds/Common/IAdLoaderClient.cs new file mode 100644 index 0000000..4f9f332 --- /dev/null +++ b/Client/Assembly-CSharp/GoogleMobileAds/Common/IAdLoaderClient.cs @@ -0,0 +1,14 @@ +using System; +using GoogleMobileAds.Api; + +namespace GoogleMobileAds.Common +{ + public interface IAdLoaderClient + { + event EventHandler<AdFailedToLoadEventArgs> OnAdFailedToLoad; + + event EventHandler<CustomNativeEventArgs> OnCustomNativeTemplateAdLoaded; + + void LoadAd(AdRequest request); + } +} diff --git a/Client/Assembly-CSharp/GoogleMobileAds/Common/IBannerClient.cs b/Client/Assembly-CSharp/GoogleMobileAds/Common/IBannerClient.cs new file mode 100644 index 0000000..96f2d37 --- /dev/null +++ b/Client/Assembly-CSharp/GoogleMobileAds/Common/IBannerClient.cs @@ -0,0 +1,40 @@ +using System; +using GoogleMobileAds.Api; + +namespace GoogleMobileAds.Common +{ + public interface IBannerClient + { + event EventHandler<EventArgs> OnAdLoaded; + + event EventHandler<AdFailedToLoadEventArgs> OnAdFailedToLoad; + + event EventHandler<EventArgs> OnAdOpening; + + event EventHandler<EventArgs> OnAdClosed; + + event EventHandler<EventArgs> OnAdLeavingApplication; + + void CreateBannerView(string adUnitId, AdSize adSize, AdPosition position); + + void CreateBannerView(string adUnitId, AdSize adSize, int x, int y); + + void LoadAd(AdRequest request); + + void ShowBannerView(); + + void HideBannerView(); + + void DestroyBannerView(); + + float GetHeightInPixels(); + + float GetWidthInPixels(); + + void SetPosition(AdPosition adPosition); + + void SetPosition(int x, int y); + + string MediationAdapterClassName(); + } +} diff --git a/Client/Assembly-CSharp/GoogleMobileAds/Common/ICustomNativeTemplateClient.cs b/Client/Assembly-CSharp/GoogleMobileAds/Common/ICustomNativeTemplateClient.cs new file mode 100644 index 0000000..8c5ae57 --- /dev/null +++ b/Client/Assembly-CSharp/GoogleMobileAds/Common/ICustomNativeTemplateClient.cs @@ -0,0 +1,20 @@ +using System; +using System.Collections.Generic; + +namespace GoogleMobileAds.Common +{ + public interface ICustomNativeTemplateClient + { + string GetTemplateId(); + + byte[] GetImageByteArray(string key); + + List<string> GetAvailableAssetNames(); + + string GetText(string key); + + void PerformClick(string assetName); + + void RecordImpression(); + } +} diff --git a/Client/Assembly-CSharp/GoogleMobileAds/Common/IInterstitialClient.cs b/Client/Assembly-CSharp/GoogleMobileAds/Common/IInterstitialClient.cs new file mode 100644 index 0000000..cd4e35a --- /dev/null +++ b/Client/Assembly-CSharp/GoogleMobileAds/Common/IInterstitialClient.cs @@ -0,0 +1,30 @@ +using System; +using GoogleMobileAds.Api; + +namespace GoogleMobileAds.Common +{ + public interface IInterstitialClient + { + event EventHandler<EventArgs> OnAdLoaded; + + event EventHandler<AdFailedToLoadEventArgs> OnAdFailedToLoad; + + event EventHandler<EventArgs> OnAdOpening; + + event EventHandler<EventArgs> OnAdClosed; + + event EventHandler<EventArgs> OnAdLeavingApplication; + + void CreateInterstitialAd(string adUnitId); + + void LoadAd(AdRequest request); + + bool IsLoaded(); + + void ShowInterstitial(); + + void DestroyInterstitial(); + + string MediationAdapterClassName(); + } +} diff --git a/Client/Assembly-CSharp/GoogleMobileAds/Common/IMobileAdsClient.cs b/Client/Assembly-CSharp/GoogleMobileAds/Common/IMobileAdsClient.cs new file mode 100644 index 0000000..a7735f2 --- /dev/null +++ b/Client/Assembly-CSharp/GoogleMobileAds/Common/IMobileAdsClient.cs @@ -0,0 +1,15 @@ +using System; + +namespace GoogleMobileAds.Common +{ + public interface IMobileAdsClient + { + void Initialize(string appId); + + void SetApplicationVolume(float volume); + + void SetApplicationMuted(bool muted); + + void SetiOSAppPauseOnBackground(bool pause); + } +} diff --git a/Client/Assembly-CSharp/GoogleMobileAds/Common/IRewardBasedVideoAdClient.cs b/Client/Assembly-CSharp/GoogleMobileAds/Common/IRewardBasedVideoAdClient.cs new file mode 100644 index 0000000..2e4589d --- /dev/null +++ b/Client/Assembly-CSharp/GoogleMobileAds/Common/IRewardBasedVideoAdClient.cs @@ -0,0 +1,36 @@ +using System; +using GoogleMobileAds.Api; + +namespace GoogleMobileAds.Common +{ + public interface IRewardBasedVideoAdClient + { + event EventHandler<EventArgs> OnAdLoaded; + + event EventHandler<AdFailedToLoadEventArgs> OnAdFailedToLoad; + + event EventHandler<EventArgs> OnAdOpening; + + event EventHandler<EventArgs> OnAdStarted; + + event EventHandler<Reward> OnAdRewarded; + + event EventHandler<EventArgs> OnAdClosed; + + event EventHandler<EventArgs> OnAdLeavingApplication; + + event EventHandler<EventArgs> OnAdCompleted; + + void CreateRewardBasedVideoAd(); + + void LoadAd(AdRequest request, string adUnitId); + + bool IsLoaded(); + + string MediationAdapterClassName(); + + void ShowRewardBasedVideoAd(); + + void SetUserId(string userId); + } +} diff --git a/Client/Assembly-CSharp/GoogleMobileAds/Common/IRewardedAdClient.cs b/Client/Assembly-CSharp/GoogleMobileAds/Common/IRewardedAdClient.cs new file mode 100644 index 0000000..10a8a6c --- /dev/null +++ b/Client/Assembly-CSharp/GoogleMobileAds/Common/IRewardedAdClient.cs @@ -0,0 +1,32 @@ +using System; +using GoogleMobileAds.Api; + +namespace GoogleMobileAds.Common +{ + public interface IRewardedAdClient + { + event EventHandler<EventArgs> OnAdLoaded; + + event EventHandler<AdErrorEventArgs> OnAdFailedToLoad; + + event EventHandler<AdErrorEventArgs> OnAdFailedToShow; + + event EventHandler<EventArgs> OnAdOpening; + + event EventHandler<Reward> OnUserEarnedReward; + + event EventHandler<EventArgs> OnAdClosed; + + void CreateRewardedAd(string adUnitId); + + void LoadAd(AdRequest request); + + bool IsLoaded(); + + string MediationAdapterClassName(); + + void Show(); + + void SetServerSideVerificationOptions(ServerSideVerificationOptions serverSideVerificationOptions); + } +} diff --git a/Client/Assembly-CSharp/GoogleMobileAds/Common/MobileAdsEventExecutor.cs b/Client/Assembly-CSharp/GoogleMobileAds/Common/MobileAdsEventExecutor.cs new file mode 100644 index 0000000..8afa69c --- /dev/null +++ b/Client/Assembly-CSharp/GoogleMobileAds/Common/MobileAdsEventExecutor.cs @@ -0,0 +1,72 @@ +using System; +using System.Collections.Generic; +using UnityEngine; + +namespace GoogleMobileAds.Common +{ + public class MobileAdsEventExecutor : MonoBehaviour + { + public static MobileAdsEventExecutor instance = null; + + private static List<Action> adEventsQueue = new List<Action>(); + + private static volatile bool adEventsQueueEmpty = true; + + public static void Initialize() + { + if (MobileAdsEventExecutor.IsActive()) + { + return; + } + GameObject gameObject = new GameObject("MobileAdsMainThreadExecuter"); + gameObject.hideFlags = HideFlags.HideAndDontSave; + UnityEngine.Object.DontDestroyOnLoad(gameObject); + MobileAdsEventExecutor.instance = gameObject.AddComponent<MobileAdsEventExecutor>(); + } + + public static bool IsActive() + { + return MobileAdsEventExecutor.instance != null; + } + + public void Awake() + { + UnityEngine.Object.DontDestroyOnLoad(base.gameObject); + } + + public static void ExecuteInUpdate(Action action) + { + List<Action> obj = MobileAdsEventExecutor.adEventsQueue; + lock (obj) + { + MobileAdsEventExecutor.adEventsQueue.Add(action); + MobileAdsEventExecutor.adEventsQueueEmpty = false; + } + } + + public void Update() + { + if (MobileAdsEventExecutor.adEventsQueueEmpty) + { + return; + } + List<Action> list = new List<Action>(); + List<Action> obj = MobileAdsEventExecutor.adEventsQueue; + lock (obj) + { + list.AddRange(MobileAdsEventExecutor.adEventsQueue); + MobileAdsEventExecutor.adEventsQueue.Clear(); + MobileAdsEventExecutor.adEventsQueueEmpty = true; + } + foreach (Action action in list) + { + action(); + } + } + + public void OnDisable() + { + MobileAdsEventExecutor.instance = null; + } + } +} diff --git a/Client/Assembly-CSharp/GoogleMobileAds/Common/RewardedAdDummyClient.cs b/Client/Assembly-CSharp/GoogleMobileAds/Common/RewardedAdDummyClient.cs new file mode 100644 index 0000000..1271c6d --- /dev/null +++ b/Client/Assembly-CSharp/GoogleMobileAds/Common/RewardedAdDummyClient.cs @@ -0,0 +1,59 @@ +using System; +using System.Reflection; +using GoogleMobileAds.Api; +using UnityEngine; + +namespace GoogleMobileAds.Common +{ + public class RewardedAdDummyClient : IRewardedAdClient + { + public event EventHandler<EventArgs> OnAdLoaded; + + public event EventHandler<AdErrorEventArgs> OnAdFailedToLoad; + + public event EventHandler<AdErrorEventArgs> OnAdFailedToShow; + + public event EventHandler<EventArgs> OnAdOpening; + + public event EventHandler<EventArgs> OnAdClosed; + + public event EventHandler<Reward> OnUserEarnedReward; + + public RewardedAdDummyClient() + { + Debug.Log("Dummy " + MethodBase.GetCurrentMethod().Name); + } + + public void CreateRewardedAd(string adUnitId) + { + Debug.Log("Dummy " + MethodBase.GetCurrentMethod().Name); + } + + public void LoadAd(AdRequest request) + { + Debug.Log("Dummy " + MethodBase.GetCurrentMethod().Name); + } + + public bool IsLoaded() + { + Debug.Log("Dummy " + MethodBase.GetCurrentMethod().Name); + return true; + } + + public void Show() + { + Debug.Log("Dummy " + MethodBase.GetCurrentMethod().Name); + } + + public string MediationAdapterClassName() + { + Debug.Log("Dummy " + MethodBase.GetCurrentMethod().Name); + return null; + } + + public void SetServerSideVerificationOptions(ServerSideVerificationOptions serverSideVerificationOptions) + { + Debug.Log("Dummy " + MethodBase.GetCurrentMethod().Name); + } + } +} diff --git a/Client/Assembly-CSharp/GoogleMobileAds/Common/Utils.cs b/Client/Assembly-CSharp/GoogleMobileAds/Common/Utils.cs new file mode 100644 index 0000000..cd20f95 --- /dev/null +++ b/Client/Assembly-CSharp/GoogleMobileAds/Common/Utils.cs @@ -0,0 +1,27 @@ +using System; +using UnityEngine; + +namespace GoogleMobileAds.Common +{ + internal class Utils + { + public static void CheckInitialization() + { + if (!MobileAdsEventExecutor.IsActive()) + { + Debug.Log("You intitialized an ad object but have not yet called MobileAds.Initialize(). We highly recommend you call MobileAds.Initialize() before interacting with the Google Mobile Ads SDK."); + } + MobileAdsEventExecutor.Initialize(); + } + + public static Texture2D GetTexture2DFromByteArray(byte[] img) + { + Texture2D texture2D = new Texture2D(1, 1); + if (!texture2D.LoadImage(img)) + { + throw new InvalidOperationException("Could not load custom native template\n image asset as texture"); + } + return texture2D; + } + } +} |