Remove reflection code for precreate Window (#123)
author부정균/Common Platform Lab(SR)/Staff Engineer/삼성전자 <jk.pu@samsung.com>
Tue, 7 Jan 2020 05:36:39 +0000 (14:36 +0900)
committer안주원/Common Platform Lab(SR)/Staff Engineer/삼성전자 <juwon.ahn@samsung.com>
Tue, 7 Jan 2020 05:36:39 +0000 (14:36 +0900)
- remove reflecton code for ElmSharp.PreloadedWindow, only use Xamarin PreloadedWindow.
- add locale system setting property get() and LocaleLanguageChanged  event handler for
reducing launching time.

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

index d42a967..f51cc03 100644 (file)
@@ -9,6 +9,7 @@ using Xamarin.Forms.Platform.Tizen;
 using ElmSharp;
 using Tizen.Applications;
 using TSystemInfo = Tizen.System.Information;
+using TSystemSetting = Tizen.System.SystemSettings;
 using ELayout = ElmSharp.Layout;
 using DeviceOrientation = Xamarin.Forms.Internals.DeviceOrientation;
 using Xamarin.Forms.PlatformConfiguration.TizenSpecific;
@@ -673,6 +674,9 @@ namespace Xamarin.Forms
                        var window = new PreloadedWindow();
                        Forms.Init();
 
+                       var locale = TSystemSetting.LocaleLanguage;
+                       TSystemSetting.LocaleLanguageChanged += (s, e) => { };
+
                        var types = new[]
                        {
                                typeof(Application),
index e9ef611..664c9b7 100644 (file)
@@ -50,23 +50,13 @@ namespace Xamarin.Forms.Platform.Tizen
                {
                        base.OnPreCreate();
                        Application.ClearCurrent();
-                       var type = typeof(Window);
-                       // Use reflection to avoid breaking compatibility. ElmSharp.Window.CreateWindow() is has been added since API6.
-                       var methodInfo = type.GetMethod("CreateWindow", BindingFlags.NonPublic | BindingFlags.Static);
                        Window window = null;
-                       if (methodInfo != null)
+                       window = PreloadedWindow.GetInstance() ?? new Window("FormsWindow");
+                       if (window is PreloadedWindow precreated)
                        {
-                               window = (Window)methodInfo.Invoke(null, new object[] { "FormsWindow" });
-                               BaseLayout = (ELayout)window.GetType().GetProperty("BaseLayout")?.GetValue(window);
-                       }
-                       else
-                       {
-                               window = PreloadedWindow.GetInstance() ?? new Window("FormsWindow");
-                               if (window is PreloadedWindow precreated)
-                               {
-                                       BaseLayout = precreated.BaseLayout;
-                               }
+                               BaseLayout = precreated.BaseLayout;
                        }
+
                        MainWindow = window;
                }