diff --git a/src/comic_dl/comic_dl.UWP/comic_dl.UWP.csproj b/src/comic_dl/comic_dl.UWP/comic_dl.UWP.csproj index 1b89617..eb75df5 100644 --- a/src/comic_dl/comic_dl.UWP/comic_dl.UWP.csproj +++ b/src/comic_dl/comic_dl.UWP/comic_dl.UWP.csproj @@ -100,6 +100,7 @@ App.xaml + diff --git a/src/comic_dl/comic_dl.UWP/customRenderer/AdViewRenderer.cs b/src/comic_dl/comic_dl.UWP/customRenderer/AdViewRenderer.cs index 033e074..899f88a 100644 --- a/src/comic_dl/comic_dl.UWP/customRenderer/AdViewRenderer.cs +++ b/src/comic_dl/comic_dl.UWP/customRenderer/AdViewRenderer.cs @@ -16,7 +16,20 @@ public class AdViewRenderer : ViewRenderer string bannerId = "1100041955"; AdControl adView; string applicationID = "9n81f8b5ww93"; - void CreateNativeAdControl() + bool isRegist = false; + + protected override void OnElementChanged(ElementChangedEventArgs e) + { + base.OnElementChanged(e); + + if (Control == null && isRegist != true) + { + CreateNativeAdControl(); + SetNativeControl(adView); + isRegist = true; + } + } + private void CreateNativeAdControl() { if (adView != null) return; @@ -38,17 +51,6 @@ void CreateNativeAdControl() Height = height, Width = width }; - - } - - protected override void OnElementChanged(ElementChangedEventArgs e) - { - base.OnElementChanged(e); - if (Control == null) - { - CreateNativeAdControl(); - //SetNativeControl(adView); - } } } #pragma warning restore CS0618 // Type or member is obsolete diff --git a/src/comic_dl/comic_dl.UWP/customRenderer/MangaAdViewRenderer.cs b/src/comic_dl/comic_dl.UWP/customRenderer/MangaAdViewRenderer.cs new file mode 100644 index 0000000..33b5f5a --- /dev/null +++ b/src/comic_dl/comic_dl.UWP/customRenderer/MangaAdViewRenderer.cs @@ -0,0 +1,57 @@ +using System; +using Xamarin.Forms; +using Xamarin.Forms.Platform.UWP; +using System.Linq; +using System.Threading.Tasks; +using Microsoft.Advertising.Ads; +using Microsoft.Advertising.WinRT.UI; +using Windows.System.Profile; + +[assembly: ExportRenderer(typeof(comic_dl.Controls.MangaDetailAdViewControl), typeof(comic_dl.UWP.customRenderer.MangaAdViewRenderer))] +namespace comic_dl.UWP.customRenderer +{ +#pragma warning disable CS0618 // Type or member is obsolete + public class MangaAdViewRenderer : ViewRenderer + { + string bannerId = "1100041955"; + AdControl adView; + string applicationID = "9n81f8b5ww93"; + bool isRegist = false; + + protected override void OnElementChanged(ElementChangedEventArgs e) + { + base.OnElementChanged(e); + + if (Control == null && isRegist != true) + { + CreateNativeAdControl(); + SetNativeControl(adView); + isRegist = true; + } + } + private void CreateNativeAdControl() + { + if (adView != null) + return; + + var width = 300; + var height = 50; + if (AnalyticsInfo.VersionInfo.DeviceFamily == "Windows.Desktop") + { + width = 728; + height = 90; + } + // Setup your BannerView, review AdSizeCons class for more Ad sizes. + adView = new AdControl + { + ApplicationId = applicationID, + AdUnitId = bannerId, + HorizontalAlignment = Windows.UI.Xaml.HorizontalAlignment.Center, + VerticalAlignment = Windows.UI.Xaml.VerticalAlignment.Bottom, + Height = height, + Width = width + }; + } + } +#pragma warning restore CS0618 // Type or member is obsolete +} diff --git a/src/comic_dl/comic_dl/internalData/ServiceUrl.cs b/src/comic_dl/comic_dl/internalData/ServiceUrl.cs index 4b6dd52..94fefde 100644 --- a/src/comic_dl/comic_dl/internalData/ServiceUrl.cs +++ b/src/comic_dl/comic_dl/internalData/ServiceUrl.cs @@ -13,7 +13,7 @@ class ServiceUrl public static string manga_information = base_manga_url + "/query/web401/info?oid="; public static string manga_search_result = base_manga_url + "/query/web401/mrs_search"; public static string manga_search_result_details = base_manga_url + "/meta"; - public static string base_comic_url = "https://readcomicsonline.me"; + public static string base_comic_url = "https://comicpunch.net/"; public static string base_comic_image_url = base_comic_url + "/reader/"; public static string base_comic_search_url = base_comic_url + "/search/node/"; }