Пример #1
0
        public bool Show(AdPosition position)
        {
            double y = 0; // default y-asix to 0

            switch (position)
            {
            case AdPosition.TOP: {
                break;
            }

            case AdPosition.BOTTOM: {
                y = AdUtility.Height() - AdView.HeightFromType(this, size);
                break;
            }

            case AdPosition.CUSTOM: {
                Debug.LogWarning("Use Show(double y) instead");
                break;
            }
            }
            return(Show(y));
        }
        public override int Create(string placementId, AdView adView, AdSize size)
        {
            AdUtility.prepare();
            AndroidJavaClass  class2 = new AndroidJavaClass("com.unity3d.player.UnityPlayer");
            AndroidJavaObject obj3   = class2.GetStatic <AndroidJavaObject>("currentActivity").Call <AndroidJavaObject>("getApplicationContext", new object[0]);

            object[]                  args          = new object[] { obj3, placementId, this.javaAdSizeFromAdSize(size) };
            AndroidJavaObject         bridgedAdView = new AndroidJavaObject("com.facebook.ads.AdView", args);
            AdViewBridgeListenerProxy proxy         = new AdViewBridgeListenerProxy(adView, bridgedAdView);

            object[] objArray2 = new object[] { proxy };
            bridgedAdView.Call("setAdListener", objArray2);
            AdViewContainer container = new AdViewContainer(adView)
            {
                bridgedAdView = bridgedAdView,
                listenerProxy = proxy
            };
            int lastKey = AdViewBridgeAndroid.lastKey;

            adViews.Add(lastKey, container);
            AdViewBridgeAndroid.lastKey++;
            return(lastKey);
        }
        #pragma warning restore 0414

        public AdViewBridgeImpressionListenerProxy(AdView adView, AndroidJavaObject bridgedAdView)
            : base("com.facebook.ads.ImpressionListener")
        {
            this.adView = adView;
            this.bridgedAdView = bridgedAdView;
        }
 internal AdViewContainer (AdView adView)
 {
     this.adView = adView;
 }
        public override int Create (string placementId,
                                    AdView adView,
                                    AdSize size)
        {
            int uniqueId = AdViewBridgeIOS.FBAdViewBridgeCreate (placementId, intFromAdSize(size));
            AdViewBridgeIOS.adViews.Add (uniqueId, new AdViewContainer(adView));
            AdViewBridgeIOS.FBAdViewBridgeOnLoad (uniqueId, adViewDidLoadBridgeCallback);
            AdViewBridgeIOS.FBAdViewBridgeOnImpression (uniqueId, adViewWillLogImpressionBridgeCallback);
            AdViewBridgeIOS.FBAdViewBridgeOnClick (uniqueId, adViewDidClickBridgeCallback);
            AdViewBridgeIOS.FBAdViewBridgeOnError (uniqueId, adViewDidFailWithErrorBridgeCallback);
            AdViewBridgeIOS.FBAdViewBridgeOnFinishedClick (uniqueId, adViewDidFinishClickBridgeCallback);

            return uniqueId;
        }
        public override int Create (string placementId,
                                    AdView adView,
                                    AdSize size)
        {
            AdUtility.prepare ();
            AndroidJavaClass unityPlayer = new AndroidJavaClass("com.unity3d.player.UnityPlayer");
            AndroidJavaObject currentActivity = unityPlayer.GetStatic<AndroidJavaObject>("currentActivity");
            AndroidJavaObject context = currentActivity.Call<AndroidJavaObject>("getApplicationContext");

            AndroidJavaObject bridgedAdView = new AndroidJavaObject("com.facebook.ads.AdView",
                                                                    context,
                                                                    placementId,
                                                                    javaAdSizeFromAdSize (size));

            AdViewBridgeListenerProxy proxy = new AdViewBridgeListenerProxy (adView, bridgedAdView);
            bridgedAdView.Call ("setAdListener", proxy);

            AdViewBridgeImpressionListenerProxy impressionListenerProxy = new AdViewBridgeImpressionListenerProxy (adView, bridgedAdView);
            bridgedAdView.Call ("setImpressionListener", impressionListenerProxy);

            AdViewContainer adViewContainer = new AdViewContainer (adView);
            adViewContainer.bridgedAdView = bridgedAdView;
            adViewContainer.listenerProxy = proxy;
            adViewContainer.impressionListenerProxy = impressionListenerProxy;

            int key = AdViewBridgeAndroid.lastKey;
            AdViewBridgeAndroid.adViews.Add(key, adViewContainer);
            AdViewBridgeAndroid.lastKey++;
            return key;
        }
 public virtual int Create (string placementId,
                            AdView AdView,
                            AdSize size)
 {
     return 123;
 }
Пример #8
0
        #pragma warning restore 0414

        public AdViewBridgeListenerProxy(AdView adView, AndroidJavaObject bridgedAdView)
            : base("com.facebook.ads.AdListener")
        {
            this.adView        = adView;
            this.bridgedAdView = bridgedAdView;
        }
Пример #9
0
 internal AdViewContainer(AdView adView)
 {
     this.adView = adView;
 }
Пример #10
0
 public virtual int Create(string placementId,
                           AdView AdView,
                           AdSize size)
 {
     return(123);
 }
Пример #11
0
 public bool Show(double x,
                  double y)
 {
     return(Show(x, y, AdUtility.Width(), AdView.HeightFromType(this, size)));
 }
Пример #12
0
 public virtual int Create(string placementId, AdView AdView, AdSize size) =>
 0x7b;