void OnCreate( Bundle savedInstanceState, ActivationFlags flags) { _activityCreated = true; if (!AllowFragmentRestore) { // Remove the automatically persisted fragment structure; we don't need them // because we're rebuilding everything from scratch. This saves a bit of memory // and prevents loading errors from child fragment managers savedInstanceState?.Remove("android:support:fragments"); } base.OnCreate(savedInstanceState); AToolbar bar; if (ToolbarResource != 0) { bar = LayoutInflater.Inflate(ToolbarResource, null).JavaCast <AToolbar>(); if (bar == null) { throw new InvalidOperationException("ToolbarResource must be set to a Android.Support.V7.Widget.Toolbar"); } } else { bar = new AToolbar(this); } SetSupportActionBar(bar); _layout = new ARelativeLayout(BaseContext); SetContentView(_layout); Xamarin.Forms.Application.ClearCurrent(); _previousState = _currentState; _currentState = AndroidApplicationLifecycleState.OnCreate; OnStateChanged(); if (Forms.IsLollipopOrNewer) { // Allow for the status bar color to be changed if ((flags & ActivationFlags.DisableSetStatusBarColor) == 0) { Window.AddFlags(WindowManagerFlags.DrawsSystemBarBackgrounds); } } if (Forms.IsLollipopOrNewer) { // Listen for the device going into power save mode so we can handle animations being disabled _powerSaveModeBroadcastReceiver = new PowerSaveModeBroadcastReceiver(); } }
private void DisplayAd(VisxAdManager visxAdManager) { /// Adding Vis.X Banner/Video Ad to the created Android /// native View and invoced on the main Xamarin thread Android.Widget.RelativeLayout container = new Android.Widget.RelativeLayout(_context); MainThread.BeginInvokeOnMainThread(() => { container = adContainer.FindViewById <Android.Widget.RelativeLayout>(Resource.Id.inlineContainer); container.AddView(visxAdManager.AdContainer); }); }
protected override void OnCreate(Bundle savedInstanceState) { base.OnCreate(savedInstanceState); _layout = new ARelativeLayout(BaseContext); SetContentView(_layout); Xamarin.Forms.Application.ClearCurrent(); Window.AddFlags(WindowManagerFlags.DrawsSystemBarBackgrounds); }
/// <summary> /// Creaeting Android Native View Root /// </summary> /// <param name="e"></param> protected override void OnElementChanged(ElementChangedEventArgs <Xamarin.Forms.View> e) { Console.WriteLine("Xamarin.Android.Layer.Banner ---> OnElementChanged(): " + e); base.OnElementChanged(e); root = new Android.Widget.RelativeLayout(Context); var inflater = (LayoutInflater)Context.GetSystemService(Context.LayoutInflaterService); adContainer = inflater.Inflate(Resource.Layout.banner, root); SetNativeControl(adContainer); }
/// <summary> /// Creaeting Android Native View Root /// </summary> /// <param name="e"></param> protected override void OnElementChanged(ElementChangedEventArgs <Xamarin.Forms.View> e) { Console.WriteLine("Xamarin.Android.Layer.Universal ---> OnElementChanged(): " + e); base.OnElementChanged(e); _visxAdManagerUniversal.SetViewValues(100); _root = new Android.Widget.RelativeLayout(Context); var inflater = (LayoutInflater)Context.GetSystemService(Context.LayoutInflaterService); _adContainer = inflater.Inflate(Resource.Layout.universal, _root); SetNativeControl(_adContainer); }
public static bool Trigger(string trigger, object arg1, object arg2, object arg3, object arg4) { bool didTrigger = false; switch (trigger) { case "there are no easter eggs": { didTrigger = true; #if __ANDROID__ Android.Widget.RelativeLayout relativeLayout = ((Android.Views.View)arg1).FindViewById <Android.Widget.RelativeLayout>(Droid.Resource.Id.relative_background); RectangleF bounds = new System.Drawing.RectangleF(0, 0, Droid.NavbarFragment.GetCurrentContainerDisplayWidth( ), ((Android.App.Fragment)arg2).Resources.DisplayMetrics.HeightPixels); UICredits credits = new UICredits(); credits.Create(relativeLayout, false, bounds, delegate { credits.View.RemoveAsSubview(relativeLayout); }); credits.LayoutChanged(bounds); #endif #if __IOS__ RectangleF rectf = new RectangleF((float)((UIKit.UIView)arg1).Frame.Left, (float)((UIKit.UIView)arg1).Frame.Top, (float)((UIKit.UIView)arg1).Frame.Width, (float)((UIKit.UIView)arg1).Frame.Height); UICredits credits = new UICredits(); credits.Create((UIKit.UIScrollView)arg2, true, rectf, delegate { credits.View.RemoveAsSubview((UIKit.UIScrollView)arg2); }); credits.LayoutChanged(new System.Drawing.RectangleF(0, 0, (float)((UIKit.UIView)arg1).Bounds.Width, (float)((UIKit.UIScrollView)arg2).ContentSize.Height)); ((UIKit.UIScrollView)arg2).ContentOffset = CoreGraphics.CGPoint.Empty; ((UIKit.UIScrollView)arg2).ContentSize = new CoreGraphics.CGSize(((UIKit.UIView)arg1).Frame.Width, credits.View.Frame.Height); #endif break; } case "i want a pony": { didTrigger = true; DoPicture(trigger, arg1, arg2, "pony.png"); break; } } return(didTrigger); }
private void DisplayAd(VisxAdManager visxAdManager) { /// Adding Vis.X Universal Ad to the created Android /// native View and invoced on the main Xamarin thread Android.Widget.RelativeLayout container = new Android.Widget.RelativeLayout(_context); MainThread.BeginInvokeOnMainThread(() => { container = _adContainer.FindViewById <Android.Widget.RelativeLayout>(Resource.Id.inlineContainer); if (visxAdManager.AdContainer.Parent != null) { visxAdManager.AdContainer.RemoveFromParent(); } container.AddView(visxAdManager.AdContainer); }); }
public static void DoPicture(string trigger, object arg1, object arg2, string imageName) { #if __ANDROID__ Android.Widget.RelativeLayout relativeLayout = ((Android.Views.View)arg1).FindViewById <Android.Widget.RelativeLayout>(Droid.Resource.Id.relative_background); RectangleF bounds = new System.Drawing.RectangleF(0, 0, Droid.NavbarFragment.GetCurrentContainerDisplayWidth( ), ((Android.App.Fragment)arg2).Resources.DisplayMetrics.HeightPixels); UIPony special = new UIPony(); special.Create(relativeLayout, false, imageName, bounds, delegate { special.View.RemoveAsSubview(relativeLayout); }); special.LayoutChanged(bounds); #endif #if __IOS__ RectangleF rectf = new RectangleF((float)((UIKit.UIView)arg1).Frame.Left, (float)((UIKit.UIView)arg1).Frame.Top, (float)((UIKit.UIView)arg1).Frame.Width, (float)((UIKit.UIView)arg1).Frame.Height); UIPony special = new UIPony(); special.Create((UIKit.UIScrollView)arg2, true, imageName, rectf, delegate { special.View.RemoveAsSubview((UIKit.UIScrollView)arg2); }); special.LayoutChanged(new System.Drawing.RectangleF(0, 0, (float)((UIKit.UIView)arg1).Bounds.Width, (float)((UIKit.UIScrollView)arg2).ContentSize.Height)); ((UIKit.UIScrollView)arg2).ContentOffset = CoreGraphics.CGPoint.Empty; ((UIKit.UIScrollView)arg2).ContentSize = new CoreGraphics.CGSize(((UIKit.UIView)arg1).Frame.Width, special.View.Frame.Height); #endif }
void OnCreate( Bundle savedInstanceState, ActivationFlags flags) { Profile.FrameBegin(); _activityCreated = true; if (!AllowFragmentRestore) { // Remove the automatically persisted fragment structure; we don't need them // because we're rebuilding everything from scratch. This saves a bit of memory // and prevents loading errors from child fragment managers savedInstanceState?.Remove("android:support:fragments"); } Profile.FramePartition("Xamarin.Android.OnCreate"); base.OnCreate(savedInstanceState); Profile.FramePartition("SetSupportActionBar"); AToolbar bar = null; #if __ANDROID_29__ if (ToolbarResource == 0) { ToolbarResource = Resource.Layout.Toolbar; } if (TabLayoutResource == 0) { TabLayoutResource = Resource.Layout.Tabbar; } #endif if (ToolbarResource != 0) { try { bar = LayoutInflater.Inflate(ToolbarResource, null).JavaCast <AToolbar>(); } #if __ANDROID_29__ catch (global::Android.Views.InflateException ie) { if ((ie.Cause is Java.Lang.ClassNotFoundException || ie.Cause.Cause is Java.Lang.ClassNotFoundException) && ie.Message.Contains("Error inflating class android.support.v7.widget.Toolbar") && this.TargetSdkVersion() >= 29) { Internals.Log.Warning(nameof(FormsAppCompatActivity), "Toolbar layout needs to be updated from android.support.v7.widget.Toolbar to androidx.appcompat.widget.Toolbar. " + "Tabbar layout need to be updated from android.support.design.widget.TabLayout to com.google.android.material.tabs.TabLayout. " + "Or if you haven't made any changes to the default Toolbar and Tabbar layouts they can just be deleted."); ToolbarResource = Resource.Layout.FallbackToolbarDoNotUse; TabLayoutResource = Resource.Layout.FallbackTabbarDoNotUse; bar = LayoutInflater.Inflate(ToolbarResource, null).JavaCast <AToolbar>(); } else { throw; } #else catch { throw; #endif } if (bar == null) #if __ANDROID_29__ { throw new InvalidOperationException("ToolbarResource must be set to a Android.Support.V7.Widget.Toolbar"); } #else { throw new InvalidOperationException("ToolbarResource must be set to a androidx.appcompat.widget.Toolbar"); } #endif } else { bar = new AToolbar(this); } SetSupportActionBar(bar); Profile.FramePartition("SetContentView"); _layout = new ARelativeLayout(BaseContext); SetContentView(_layout); Profile.FramePartition("OnStateChanged"); Xamarin.Forms.Application.ClearCurrent(); _previousState = _currentState; _currentState = AndroidApplicationLifecycleState.OnCreate; OnStateChanged(); Profile.FramePartition("Forms.IsLollipopOrNewer"); if (Forms.IsLollipopOrNewer) { // Allow for the status bar color to be changed if ((flags & ActivationFlags.DisableSetStatusBarColor) == 0) { Profile.FramePartition("Set DrawsSysBarBkgrnds"); Window.AddFlags(WindowManagerFlags.DrawsSystemBarBackgrounds); } } if (Forms.IsLollipopOrNewer) { // Listen for the device going into power save mode so we can handle animations being disabled Profile.FramePartition("Allocate PowerSaveModeReceiver"); _powerSaveModeBroadcastReceiver = new PowerSaveModeBroadcastReceiver(); } ContextExtensions.SetDesignerContext(_layout); Profile.FrameEnd(); }
void OnCreate( Bundle savedInstanceState, ActivationFlags flags) { Profile.FrameBegin(); _activityCreated = true; if (!AllowFragmentRestore) { // Remove the automatically persisted fragment structure; we don't need them // because we're rebuilding everything from scratch. This saves a bit of memory // and prevents loading errors from child fragment managers savedInstanceState?.Remove("android:support:fragments"); } Profile.FramePartition("Xamarin.Android.OnCreate"); base.OnCreate(savedInstanceState); Profile.FramePartition("SetSupportActionBar"); AToolbar bar = null; if (_toolbarResource == 0) { ToolbarResource = Resource.Layout.toolbar; } if (_tabLayoutResource == 0) { _tabLayoutResource = Resource.Layout.tabbar; } if (ToolbarResource != 0) { try { bar = LayoutInflater.Inflate(ToolbarResource, null).JavaCast <AToolbar>(); } catch (global::Android.Views.InflateException ie) { throw new InvalidOperationException("ToolbarResource must be set to a androidx.appcompat.widget.Toolbar", ie); } if (bar == null) { throw new InvalidOperationException("ToolbarResource must be set to a androidx.appcompat.widget.Toolbar"); } } else { bar = new AToolbar(this); } SetSupportActionBar(bar); Profile.FramePartition("SetContentView"); _layout = new ARelativeLayout(BaseContext); SetContentView(_layout); Profile.FramePartition("OnStateChanged"); Microsoft.Maui.Controls.Application.Current = null; _previousState = _currentState; _currentState = AndroidApplicationLifecycleState.OnCreate; OnStateChanged(); // Allow for the status bar color to be changed if ((flags & ActivationFlags.DisableSetStatusBarColor) == 0) { Profile.FramePartition("Set DrawsSysBarBkgrnds"); Window.AddFlags(WindowManagerFlags.DrawsSystemBarBackgrounds); } Profile.FrameEnd(); }