Ejemplo n.º 1
0
        public void OnUnifiedNativeAdLoaded(UnifiedNativeAd ad)
        {
            try
            {
                NativeTemplateStyle styles = new NativeTemplateStyle.Builder().Build();

                if (Template.GetTemplateTypeName() == TemplateView.BigTemplate)
                {
                    ActivityContext.RunOnUiThread(() =>
                    {
                        Template.PopulateUnifiedNativeAdView(ad);
                    });
                }
                else
                {
                    Template.SetStyles(styles);
                    ActivityContext.RunOnUiThread(() =>
                    {
                        Template.SetNativeAd(ad);
                    });
                }

                ActivityContext.RunOnUiThread(() =>
                {
                    try
                    {
                        Template.Visibility = ViewStates.Visible;

                        if (AppSettings.SetTabDarkTheme)
                        {
                            Template.SetBackgroundResource(Resource.Drawable.Shape_Radius_Black_Btn);
                        }
                    }
                    catch (Exception e)
                    {
                        Console.WriteLine(e);
                    }
                });
            }
            catch (Exception e)
            {
                Console.WriteLine(e);
            }
        }
Ejemplo n.º 2
0
        public void OnUnifiedNativeAdLoaded(UnifiedNativeAd ad)
        {
            // TODO: Show the ad.
            var view = Element as AdMobNativeView;

            if (adLoader.IsLoading)
            {
                // The AdLoader is still loading ads.
                // Expect more adLoaded or onAdFailedToLoad callbacks.
                view.TriggerAdLoading();
            }
            else
            {
                // The AdLoader has finished loading ads.
                var styles = new NativeTemplateStyle
                {
                };

                var template = new TemplateView(Context);
                var aview    = template.InitView(Context, null, view.NativeTemplate);
                SetNativeControl(aview);
                template.SetStyles(styles);
                template.SetNativeAd(ad);
                view.TriggerAdRendered();
                //var inflater = Context.GetSystemService(Context.LayoutInflaterService)
                //    as LayoutInflater;
                //
                //var root = new UnifiedNativeAdView(Context);
                //var nativeAdView = (UnifiedNativeAdView)
                //    inflater.Inflate(Resource.Layout.gnt_medium_template_view, root);
                //
                //nativeAdView.MediaView = nativeAdView.FindViewById<MediaView>(Resource.Id.media_view);
                //
                //nativeAdView.SetNativeAd(ad);
            }
        }