Remove the ApplicationLifecycle (#204)
author유리나/Common Platform Lab(SR)/Staff Engineer/삼성전자 <rina6350.you@samsung.com>
Mon, 20 Apr 2020 03:05:49 +0000 (12:05 +0900)
committer안주원/Common Platform Lab(SR)/Principal Engineer/삼성전자 <juwon.ahn@samsung.com>
Mon, 20 Apr 2020 03:05:49 +0000 (12:05 +0900)
src/XSF/Xamarin.Forms.Platform.Tizen/AdaptedFormsApplication.cs [deleted file]
src/XSF/Xamarin.Forms.Platform.Tizen/ApplicationLifecycle.cs [deleted file]
src/XSF/Xamarin.Forms.Platform.Tizen/Forms.cs

diff --git a/src/XSF/Xamarin.Forms.Platform.Tizen/AdaptedFormsApplication.cs b/src/XSF/Xamarin.Forms.Platform.Tizen/AdaptedFormsApplication.cs
deleted file mode 100644 (file)
index 038cd92..0000000
+++ /dev/null
@@ -1,74 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Reflection;
-using System.Text;
-using ElmSharp;
-using Tizen.Applications;
-
-namespace Xamarin.Forms.Platform.Tizen
-{
-       class AdaptedFormsApplication : FormsApplication
-       {
-               public ApplicationLifecycle Lifecycle { get; set; }
-
-               protected override void OnPause()
-               {
-                       base.OnPause();
-                       Lifecycle?.SendPause();
-               }
-               protected override void OnPreCreate()
-               {
-                       if (MainWindow == null)
-                       {
-                               base.OnPreCreate();
-                       }
-                       Lifecycle?.SendPreCreate();
-               }
-               protected override void OnResume()
-               {
-                       base.OnResume();
-                       Lifecycle?.SendResume();
-               }
-               protected override void OnAppControlReceived(AppControlReceivedEventArgs e)
-               {
-                       base.OnAppControlReceived(e);
-                       Lifecycle?.Send(e);
-               }
-               protected override void OnCreate()
-               {
-                       base.OnCreate();
-                       Lifecycle?.SendCreate();
-               }
-               protected override void OnDeviceOrientationChanged(DeviceOrientationEventArgs e)
-               {
-                       base.OnDeviceOrientationChanged(e);
-                       Lifecycle?.Send(e);
-               }
-               protected override void OnLocaleChanged(LocaleChangedEventArgs e)
-               {
-                       base.OnLocaleChanged(e);
-                       Lifecycle?.Send(e);
-               }
-               protected override void OnLowBattery(LowBatteryEventArgs e)
-               {
-                       base.OnLowBattery(e);
-                       Lifecycle?.Send(e);
-               }
-               protected override void OnLowMemory(LowMemoryEventArgs e)
-               {
-                       base.OnLowMemory(e);
-                       Lifecycle?.Send(e);
-               }
-               protected override void OnRegionFormatChanged(RegionFormatChangedEventArgs e)
-               {
-                       base.OnRegionFormatChanged(e);
-                       Lifecycle?.Send(e);
-               }
-               protected override void OnTerminate()
-               {
-                       base.OnTerminate();
-                       Lifecycle?.SendTerminate();
-               }
-       }
-}
\ No newline at end of file
diff --git a/src/XSF/Xamarin.Forms.Platform.Tizen/ApplicationLifecycle.cs b/src/XSF/Xamarin.Forms.Platform.Tizen/ApplicationLifecycle.cs
deleted file mode 100644 (file)
index 91669a9..0000000
+++ /dev/null
@@ -1,55 +0,0 @@
-using Tizen.Applications;
-
-namespace Xamarin.Forms.Platform.Tizen
-{
-       public abstract class ApplicationLifecycle
-       {
-               public FormsApplication FormsApplication { get; internal set; }
-
-               internal void SendPause() => OnPause();
-               internal void SendPreCreate() => OnPreCreate();
-               internal void SendResume() => OnResume();
-               internal void SendCreate() => OnCreate();
-               internal void SendTerminate() => OnTerminate();
-               internal void Send(AppControlReceivedEventArgs e) => OnAppControlReceived(e);
-               internal void Send(DeviceOrientationEventArgs e) => OnDeviceOrientationChanged(e);
-               internal void Send(LocaleChangedEventArgs e) => OnLocaleChanged(e);
-               internal void Send(LowBatteryEventArgs e) => OnLowBattery(e);
-               internal void Send(LowMemoryEventArgs e) => OnLowMemory(e);
-               internal void Send(RegionFormatChangedEventArgs e) => OnRegionFormatChanged(e);
-
-               protected virtual void OnPause()
-               {
-               }
-               protected virtual void OnPreCreate()
-               {
-               }
-               protected virtual void OnResume()
-               {
-               }
-               protected virtual void OnAppControlReceived(AppControlReceivedEventArgs e)
-               {
-               }
-               protected virtual void OnCreate()
-               {
-               }
-               protected virtual void OnDeviceOrientationChanged(DeviceOrientationEventArgs e)
-               {
-               }
-               protected virtual void OnLocaleChanged(LocaleChangedEventArgs e)
-               {
-               }
-               protected virtual void OnLowBattery(LowBatteryEventArgs e)
-               {
-               }
-               protected virtual void OnLowMemory(LowMemoryEventArgs e)
-               {
-               }
-               protected virtual void OnRegionFormatChanged(RegionFormatChangedEventArgs e)
-               {
-               }
-               protected virtual void OnTerminate()
-               {
-               }
-       }
-}
\ No newline at end of file
index 1ec5da0f95e8b3014282bff7c6dae6363fd14d13..73951ae7a79195267a27f94c53eb3f1789308a7d 100644 (file)
@@ -34,7 +34,6 @@ namespace Xamarin.Forms
 
        public class InitializationOptions
        {
-               public ApplicationLifecycle LifeCycle { get; set; }
                public CoreApplication Context { get; set; }
                public bool UseDeviceIndependentPixel { get; set; }
                public HandlerAttribute[] Handlers { get; set; }
@@ -75,25 +74,6 @@ namespace Xamarin.Forms
                        Assemblies = assemblies;
                }
 
-               public InitializationOptions(ApplicationLifecycle lifecycle)
-               {
-                       LifeCycle = lifecycle;
-               }
-
-               public InitializationOptions(ApplicationLifecycle lifecycle, bool useDeviceIndependentPixel, HandlerAttribute[] handlers)
-               {
-                       LifeCycle = lifecycle;
-                       UseDeviceIndependentPixel = useDeviceIndependentPixel;
-                       Handlers = handlers;
-               }
-
-               public InitializationOptions(ApplicationLifecycle lifecycle, bool useDeviceIndependentPixel, params Assembly[] assemblies)
-               {
-                       LifeCycle = lifecycle;
-                       UseDeviceIndependentPixel = useDeviceIndependentPixel;
-                       Assemblies = assemblies;
-               }
-
                public void UseStaticRegistrar(StaticRegistrarStrategy strategy, Dictionary<Type, Func<IRegisterable>> customHandlers=null, bool disableCss=false)
                {
                        StaticRegistarStrategy = strategy;
@@ -382,13 +362,6 @@ namespace Xamarin.Forms
                        }
                }
 
-               static void Init()
-               {
-                       var appAdapter = new AdaptedFormsApplication();
-                       Init(appAdapter, false);
-                       IsPreloaded = true;
-               }
-
                public static void Init(CoreApplication application)
                {
                        Init(application, false);
@@ -402,18 +375,6 @@ namespace Xamarin.Forms
 
                public static void Init(InitializationOptions options)
                {
-                       if (!IsInitialized)
-                       {
-                               var appAdapter = new AdaptedFormsApplication();
-                               Context = appAdapter;
-                       }
-
-                       if (options.LifeCycle != null)
-                       {
-                               var appAdapter = Context as AdaptedFormsApplication;
-                               appAdapter.Lifecycle = options.LifeCycle;
-                               options.LifeCycle.FormsApplication = appAdapter;
-                       }
                        SetupInit(Context, options);
                }
 
@@ -693,7 +654,9 @@ namespace Xamarin.Forms
                [EditorBrowsable(EditorBrowsableState.Never)]
                public static EvasObject Preload()
                {
-                       Forms.Init();
+                       var dummyApp = new DummyFormsApplication();
+                       Init(dummyApp, false);
+                       IsPreloaded = true;
 
                        EWindow eWindow = null;
                        ELayout eLayout = null;
@@ -813,4 +776,6 @@ namespace Xamarin.Forms
                        return base.VisitMember(node);
                }
        }
+
+       class DummyFormsApplication : FormsApplication { }
 }
\ No newline at end of file