public static void InitNative(Activity activity, NativeAdLayout nativeAdLayout, NativeAd ad) { try { var isPro = ListUtils.MyUserInfoList.FirstOrDefault()?.IsPro ?? 0; if (isPro == 0 && AppSettings.ShowFbNativeAds) { if (ad == null) { var nativeAd = new NativeAd(activity, AppSettings.AdsFbNativeKey); nativeAd.SetAdListener(new NativeAdListener(activity, nativeAd, nativeAdLayout)); // Initiate a request to load an ad. nativeAd.LoadAd(); } else { var holder = new AdHolder(nativeAdLayout); LoadAd(activity, holder, ad, nativeAdLayout); } } } catch (Exception e) { Console.WriteLine(e); } }
public static void InitNative(Activity activity, NativeAdLayout nativeAdLayout, NativeAd ad) { try { if (AppSettings.ShowFbNativeAds) { if (ad == null) { var nativeAd = new NativeAd(activity, AppSettings.AdsFbNativeKey); nativeAd.SetAdListener(new NativeAdListener(activity, nativeAd, nativeAdLayout)); // Initiate a request to load an ad. nativeAd.LoadAd(); } else { var holder = new AdHolder(nativeAdLayout); LoadAd(activity, holder, ad, nativeAdLayout); } } } catch (Exception e) { Console.WriteLine(e); } }
private void InitComponent() { try { TxtAppName = FindViewById <TextView>(Resource.Id.appName); TxtPackageName = FindViewById <TextView>(Resource.Id.appUsername); IconVersion = FindViewById <TextView>(Resource.Id.iconVersion); TxtCountVersion = FindViewById <TextView>(Resource.Id.countVersion); IconChangelog = FindViewById <TextView>(Resource.Id.iconChangelog); IconRateApp = FindViewById <TextView>(Resource.Id.iconRateApp); IconTerms = FindViewById <TextView>(Resource.Id.iconTerms); IconPrivacy = FindViewById <TextView>(Resource.Id.iconPrivacy); IconAbout = FindViewById <TextView>(Resource.Id.iconAbout); LayoutChangelog = FindViewById <LinearLayout>(Resource.Id.layoutChangelog); LayoutRate = FindViewById <LinearLayout>(Resource.Id.layoutRate); LayoutTerms = FindViewById <LinearLayout>(Resource.Id.layoutTerms); LayoutPrivacy = FindViewById <LinearLayout>(Resource.Id.layoutPrivacy); LayoutAbout = FindViewById <LinearLayout>(Resource.Id.layoutAbout); FontUtils.SetTextViewIcon(FontsIconFrameWork.FontAwesomeLight, IconVersion, FontAwesomeIcon.InfoCircle); FontUtils.SetTextViewIcon(FontsIconFrameWork.FontAwesomeLight, IconChangelog, FontAwesomeIcon.SyncAlt); FontUtils.SetTextViewIcon(FontsIconFrameWork.IonIcons, IconRateApp, IonIconsFonts.AndroidStarHalf); FontUtils.SetTextViewIcon(FontsIconFrameWork.FontAwesomeRegular, IconTerms, FontAwesomeIcon.FileContract); FontUtils.SetTextViewIcon(FontsIconFrameWork.FontAwesomeLight, IconPrivacy, FontAwesomeIcon.UserSecret); FontUtils.SetTextViewIcon(FontsIconFrameWork.FontAwesomeBrands, IconAbout, FontAwesomeIcon.Medapps); NativeAdLayout nativeAdLayout = FindViewById <NativeAdLayout>(Resource.Id.native_ad_container); nativeAdLayout.Visibility = ViewStates.Gone; AdsFacebook.InitNative(this, nativeAdLayout, null); TxtAppName.Text = AppSettings.ApplicationName; PackageInfo info = PackageManager.GetPackageInfo(PackageName, 0); int versionNumber = info.VersionCode; string versionName = info.VersionName; TxtPackageName.Text = PackageName; TxtCountVersion.Text = versionName; } catch (Exception e) { Console.WriteLine(e); } }
private static void LoadAd(Activity activity, AdHolder holder, NativeAd nativeAd, NativeAdLayout adView) { try { adView.Visibility = ViewStates.Visible; if (holder.NativeAdChoicesContainer != null) { var adOptionsView = new AdOptionsView(activity, nativeAd, adView); holder.NativeAdChoicesContainer.RemoveAllViews(); holder.NativeAdChoicesContainer.AddView(adOptionsView, 0); } // Setting the Text holder.NativeAdSocialContext.Text = nativeAd.AdSocialContext; holder.NativeAdCallToAction.Text = nativeAd.AdCallToAction; holder.NativeAdCallToAction.Visibility = nativeAd.HasCallToAction ? ViewStates.Visible : ViewStates.Invisible; holder.NativeAdTitle.Text = nativeAd.AdvertiserName; holder.NativeAdBody.Text = nativeAd.AdBodyText; holder.SponsoredLabel.Text = activity.GetText(Resource.String.sponsored); // You can use the following to specify the clickable areas. List <View> clickableViews = new List <View> { holder.NativeAdIcon, holder.NativeAdMedia, holder.NativeAdCallToAction }; nativeAd.RegisterViewForInteraction(adView, holder.NativeAdMedia, holder.NativeAdIcon, clickableViews); // Optional: tag views NativeAdBase.NativeComponentTag.TagView(holder.NativeAdIcon, NativeAdBase.NativeComponentTag.AdIcon); NativeAdBase.NativeComponentTag.TagView(holder.NativeAdTitle, NativeAdBase.NativeComponentTag.AdTitle); NativeAdBase.NativeComponentTag.TagView(holder.NativeAdBody, NativeAdBase.NativeComponentTag.AdBody); NativeAdBase.NativeComponentTag.TagView(holder.NativeAdSocialContext, NativeAdBase.NativeComponentTag.AdSocialContext); NativeAdBase.NativeComponentTag.TagView(holder.NativeAdCallToAction, NativeAdBase.NativeComponentTag.AdCallToAction); } catch (Exception e) { Console.WriteLine(e); } }
public NativeAdListener(Activity activity, NativeAd nativeAd, NativeAdLayout nativeAdLayout) { Activity = activity; NativeAd = nativeAd; NativeAdLayout = nativeAdLayout; }