Fixed to use ElmSharp preloaded window in Forms preload method (#155)
author윤정현/Common Platform Lab(SR)/Staff Engineer/삼성전자 <jh0506.yun@samsung.com>
Thu, 19 Mar 2020 04:03:47 +0000 (13:03 +0900)
committer유리나/Common Platform Lab(SR)/Staff Engineer/삼성전자 <rina6350.you@samsung.com>
Thu, 19 Mar 2020 04:03:47 +0000 (13:03 +0900)
* Fixed to use ElmSharp preloaded window in Forms preload method

* Fixed local variables name

Xamarin.Forms/Xamarin.Forms.Platform.Tizen/Forms.cs
Xamarin.Forms/Xamarin.Forms.Platform.Tizen/FormsApplication.cs
Xamarin.Forms/Xamarin.Forms.Platform.Tizen/PreloadedWindow.cs

index 10cae9a..fb6a3c4 100644 (file)
@@ -10,6 +10,7 @@ using ElmSharp;
 using Tizen.Applications;
 using TSystemInfo = Tizen.System.Information;
 using TSystemSetting = Tizen.System.SystemSettings;
+using EWindow = ElmSharp.Window;
 using ELayout = ElmSharp.Layout;
 using DeviceOrientation = Xamarin.Forms.Internals.DeviceOrientation;
 using Xamarin.Forms.PlatformConfiguration.TizenSpecific;
@@ -673,25 +674,25 @@ namespace Xamarin.Forms
                {
                        Forms.Init();
 
-                       var window = new PreloadedWindow();
-
-                       //Elmsharp preload, this should be removed if Elmsharp preload PR is merged in dotnet-launcher.
-                       new ElmSharp.Entry(window).Unrealize();
-                       new Scroller(window).Unrealize();
-                       new Box(window).Unrealize();
-                       new ElmSharp.Label(window).Unrealize();
-                       new GenList(window).Unrealize();
-                       new ElmSharp.Button(window).Unrealize();
-                       new Check(window).Unrealize();
-                       new Naviframe(window).Unrealize();
-                       new ElmSharp.Slider(window).Unrealize();
-                       new Spinner(window).Unrealize();
-                       new ElmSharp.ProgressBar(window).Unrealize();
-                       new GestureLayer(window).Unrealize();
-                       new Polygon(window).Unrealize();
-                       new ElmSharp.Image(window).Unrealize();
-                       window.BackButtonPressed += DummyHandler;
-                       window.BackButtonPressed -= DummyHandler;
+                       EWindow eWindow = null;
+                       ELayout eLayout = null;
+                       var typeWin = typeof(EWindow);
+                       var methodInfo = typeWin.GetMethod("CreateWindow", BindingFlags.NonPublic | BindingFlags.Static);
+                       if (methodInfo != null)
+                       {
+                               eWindow = (EWindow)methodInfo.Invoke(null, new object[] { "FormsWindow" });
+                               eLayout = (ELayout)eWindow.GetType().GetProperty("BaseLayout")?.GetValue(eWindow);
+                       }
+
+                       PreloadedWindow preloadedWindow = null;
+                       if (eWindow != null && eLayout != null)
+                       {
+                               preloadedWindow = new PreloadedWindow(eWindow, eLayout);
+                       }
+                       else
+                       {
+                               preloadedWindow = new PreloadedWindow();
+                       }
 
                        var locale = TSystemSetting.LocaleLanguage;
                        TSystemSetting.LocaleLanguageChanged += DummyHandler;
@@ -756,9 +757,9 @@ namespace Xamarin.Forms
                        {
                                System.Runtime.CompilerServices.RuntimeHelpers.RunClassConstructor(type.TypeHandle);
                        }
-                       global::Xamarin.Forms.Platform.Tizen.Native.NativeFactory.PrecreateNatives(window);
+                       global::Xamarin.Forms.Platform.Tizen.Native.NativeFactory.PrecreateNatives(preloadedWindow.Window);
 
-                       return window;
+                       return preloadedWindow.Window;
                }
        }
 
index bf9dad4..60527d0 100644 (file)
@@ -51,14 +51,9 @@ namespace Xamarin.Forms.Platform.Tizen
                {
                        base.OnPreCreate();
                        Application.ClearCurrent();
-                       Window window = null;
-                       window = PreloadedWindow.GetInstance() ?? new Window("FormsWindow");
-                       if (window is PreloadedWindow precreated)
-                       {
-                               BaseLayout = precreated.BaseLayout;
-                       }
-
-                       MainWindow = window;
+                       PreloadedWindow window = PreloadedWindow.GetInstance() ?? new PreloadedWindow();
+                       BaseLayout = window.BaseLayout;
+                       MainWindow = window.Window;
                }
 
                protected override void OnTerminate()
index a7663be..31c076c 100644 (file)
@@ -3,16 +3,29 @@ using ELayout = ElmSharp.Layout;
 
 namespace Xamarin.Forms.Platform.Tizen
 {
-       public class PreloadedWindow : Window
+       public class PreloadedWindow
        {
                static PreloadedWindow s_precreated;
 
-               public PreloadedWindow() : base("FormsWindow-pre")
+               public PreloadedWindow()
                {
                        s_precreated = this;
                        Initialize();
                }
 
+               public PreloadedWindow(Window win, ELayout layout)
+               {
+                       s_precreated = this;
+                       Window = win;
+                       BaseLayout = layout;
+               }
+
+               public Window Window
+               {
+                       get;
+                       protected set;
+               }
+
                public ELayout BaseLayout
                {
                        get;
@@ -21,7 +34,10 @@ namespace Xamarin.Forms.Platform.Tizen
 
                protected void Initialize()
                {
-                       var conformant = new Conformant(this);
+                       Window = new Window("FormsWindow");
+                       Window.Show();
+
+                       var conformant = new Conformant(Window);
                        conformant.Show();
 
                        var layout = new ELayout(conformant);