Skip to content

Commit

Permalink
Done
Browse files Browse the repository at this point in the history
Done :
1.) Added custom renderer for ads in UWP.
2.) Included Ad IDs in UWP.
3.) Fixed Comic url for new source.
  • Loading branch information
Xonshiz committed Apr 2, 2019
1 parent d9a17ec commit 121d15e
Show file tree
Hide file tree
Showing 4 changed files with 73 additions and 13 deletions.
1 change: 1 addition & 0 deletions src/comic_dl/comic_dl.UWP/comic_dl.UWP.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,7 @@
<DependentUpon>App.xaml</DependentUpon>
</Compile>
<Compile Include="customRenderer\AdViewRenderer.cs" />
<Compile Include="customRenderer\MangaAdViewRenderer.cs" />
<Compile Include="dependencyServices\DirectoryHelper.cs" />
<Compile Include="dependencyServices\SQLiteDb.cs" />
<Compile Include="MainPage.xaml.cs">
Expand Down
26 changes: 14 additions & 12 deletions src/comic_dl/comic_dl.UWP/customRenderer/AdViewRenderer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,20 @@ public class AdViewRenderer : ViewRenderer<Controls.AdControlView, AdControl>
string bannerId = "1100041955";
AdControl adView;
string applicationID = "9n81f8b5ww93";
void CreateNativeAdControl()
bool isRegist = false;

protected override void OnElementChanged(ElementChangedEventArgs<Controls.AdControlView> e)
{
base.OnElementChanged(e);

if (Control == null && isRegist != true)
{
CreateNativeAdControl();
SetNativeControl(adView);
isRegist = true;
}
}
private void CreateNativeAdControl()
{
if (adView != null)
return;
Expand All @@ -38,17 +51,6 @@ void CreateNativeAdControl()
Height = height,
Width = width
};

}

protected override void OnElementChanged(ElementChangedEventArgs<Controls.AdControlView> e)
{
base.OnElementChanged(e);
if (Control == null)
{
CreateNativeAdControl();
//SetNativeControl(adView);
}
}
}
#pragma warning restore CS0618 // Type or member is obsolete
Expand Down
57 changes: 57 additions & 0 deletions src/comic_dl/comic_dl.UWP/customRenderer/MangaAdViewRenderer.cs
Original file line number Diff line number Diff line change
@@ -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<Controls.MangaDetailAdViewControl, AdControl>
{
string bannerId = "1100041955";
AdControl adView;
string applicationID = "9n81f8b5ww93";
bool isRegist = false;

protected override void OnElementChanged(ElementChangedEventArgs<Controls.MangaDetailAdViewControl> 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
}
2 changes: 1 addition & 1 deletion src/comic_dl/comic_dl/internalData/ServiceUrl.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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/";
}
Expand Down

0 comments on commit 121d15e

Please sign in to comment.