-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
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
Showing
4 changed files
with
73 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
57 changes: 57 additions & 0 deletions
57
src/comic_dl/comic_dl.UWP/customRenderer/MangaAdViewRenderer.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters