[NUI] Remove using keyword (#552)
authorhuiyueun <35286162+huiyueun@users.noreply.github.com>
Fri, 16 Nov 2018 08:52:36 +0000 (17:52 +0900)
committerdongsug-song <35130733+dongsug-song@users.noreply.github.com>
Fri, 16 Nov 2018 08:52:36 +0000 (17:52 +0900)
Signed-off-by: huiyu.eun <huiyu.eun@samsung.com>
src/Tizen.NUI/src/internal/Application.cs
src/Tizen.NUI/src/internal/DisposeQueue.cs
src/Tizen.NUI/src/internal/NUICoreBackend.cs
src/Tizen.NUI/src/internal/WatchApplication.cs

index 0904b95..55304bb 100755 (executable)
@@ -955,16 +955,7 @@ namespace Tizen.NUI
             // Initialize DisposeQueue Singleton class. This is also required to create DisposeQueue on main thread.
             DisposeQueue.Instance.Initialize();
 
-            NUIApplicationInitEventArgs e = new NUIApplicationInitEventArgs();
-            // Populate all members of "e" (NUIApplicationInitEventArgs) with real data
-            using (e.Application = Application.GetApplicationFromPtr(data))
-            {
-                if (_applicationInitEventHandler != null)
-                {
-                    //here we send all data to user event handlers
-                    _applicationInitEventHandler(this, e);
-                }
-            }
+            _applicationInitEventHandler?.Invoke(this, new NUIApplicationInitEventArgs());
 
         }
 
@@ -1006,17 +997,7 @@ namespace Tizen.NUI
         // Callback for Application TerminateSignal
         private void OnNUIApplicationTerminate(IntPtr data)
         {
-            NUIApplicationTerminatingEventArgs e = new NUIApplicationTerminatingEventArgs();
-
-            // Populate all members of "e" (NUIApplicationTerminateEventArgs) with real data
-            using (e.Application = Application.GetApplicationFromPtr(data))
-            {
-                if (_applicationTerminateEventHandler != null)
-                {
-                    //here we send all data to user event handlers
-                    _applicationTerminateEventHandler(this, e);
-                }
-            }
+            _applicationTerminateEventHandler?.Invoke(this, new NUIApplicationTerminatingEventArgs());
         }
 
         /**
@@ -1057,17 +1038,7 @@ namespace Tizen.NUI
         // Callback for Application PauseSignal
         private void OnNUIApplicationPause(IntPtr data)
         {
-            NUIApplicationPausedEventArgs e = new NUIApplicationPausedEventArgs();
-
-            // Populate all members of "e" (NUIApplicationPauseEventArgs) with real data
-            using (e.Application = Application.GetApplicationFromPtr(data))
-            {
-                if (_applicationPauseEventHandler != null)
-                {
-                    //here we send all data to user event handlers
-                    _applicationPauseEventHandler(this, e);
-                }
-            }
+            _applicationPauseEventHandler?.Invoke(this, new NUIApplicationPausedEventArgs());
         }
 
         /**
@@ -1108,17 +1079,7 @@ namespace Tizen.NUI
         // Callback for Application ResumeSignal
         private void OnNUIApplicationResume(IntPtr data)
         {
-            NUIApplicationResumedEventArgs e = new NUIApplicationResumedEventArgs();
-
-            // Populate all members of "e" (NUIApplicationResumeEventArgs) with real data
-            using (e.Application = Application.GetApplicationFromPtr(data))
-            {
-                if (_applicationResumeEventHandler != null)
-                {
-                    //here we send all data to user event handlers
-                    _applicationResumeEventHandler(this, e);
-                }
-            }
+            _applicationResumeEventHandler?.Invoke(this, new NUIApplicationResumedEventArgs());
         }
 
         /**
@@ -1159,17 +1120,7 @@ namespace Tizen.NUI
         // Callback for Application ResetSignal
         private void OnNUIApplicationReset(IntPtr data)
         {
-            NUIApplicationResetEventArgs e = new NUIApplicationResetEventArgs();
-
-            // Populate all members of "e" (NUIApplicationResetEventArgs) with real data
-            using (e.Application = Application.GetApplicationFromPtr(data))
-            {
-                if (_applicationResetEventHandler != null)
-                {
-                    //here we send all data to user event handlers
-                    _applicationResetEventHandler(this, e);
-                }
-            }
+            _applicationResetEventHandler?.Invoke(this, new NUIApplicationResetEventArgs());
         }
 
         /**
@@ -1210,17 +1161,7 @@ namespace Tizen.NUI
         // Callback for Application ResizeSignal
         private void OnNUIApplicationResize(IntPtr data)
         {
-            NUIApplicationResizedEventArgs e = new NUIApplicationResizedEventArgs();
-
-            // Populate all members of "e" (NUIApplicationResizeEventArgs) with real data
-            using (e.Application = Application.GetApplicationFromPtr(data))
-            {
-                if (_applicationResizeEventHandler != null)
-                {
-                    //here we send all data to user event handlers
-                    _applicationResizeEventHandler(this, e);
-                }
-            }
+            _applicationResizeEventHandler?.Invoke(this, new NUIApplicationResizedEventArgs());
         }
 
         /**
@@ -1261,17 +1202,7 @@ namespace Tizen.NUI
         // Callback for Application LanguageChangedSignal
         private void OnNUIApplicationLanguageChanged(IntPtr data)
         {
-            NUIApplicationLanguageChangedEventArgs e = new NUIApplicationLanguageChangedEventArgs();
-
-            // Populate all members of "e" (NUIApplicationLanguageChangedEventArgs) with real data
-            using (e.Application = Application.GetApplicationFromPtr(data))
-            {
-                if (_applicationLanguageChangedEventHandler != null)
-                {
-                    //here we send all data to user event handlers
-                    _applicationLanguageChangedEventHandler(this, e);
-                }
-            }
+            _applicationLanguageChangedEventHandler?.Invoke(this, new NUIApplicationLanguageChangedEventArgs());
         }
 
         /**
@@ -1312,17 +1243,7 @@ namespace Tizen.NUI
         // Callback for Application RegionChangedSignal
         private void OnNUIApplicationRegionChanged(IntPtr data)
         {
-            NUIApplicationRegionChangedEventArgs e = new NUIApplicationRegionChangedEventArgs();
-
-            // Populate all members of "e" (NUIApplicationRegionChangedEventArgs) with real data
-            using (e.Application = Application.GetApplicationFromPtr(data))
-            {
-                if (_applicationRegionChangedEventHandler != null)
-                {
-                    //here we send all data to user event handlers
-                    _applicationRegionChangedEventHandler(this, e);
-                }
-            }
+            _applicationRegionChangedEventHandler?.Invoke(this, new NUIApplicationRegionChangedEventArgs());
         }
 
         /**
@@ -1367,12 +1288,7 @@ namespace Tizen.NUI
 
             // Populate all members of "e" (NUIApplicationBatteryLowEventArgs) with real data
             e.BatteryStatus = status;
-
-            if (_applicationBatteryLowEventHandler != null)
-            {
-                //here we send all data to user event handlers
-                _applicationBatteryLowEventHandler(this, e);
-            }
+            _applicationBatteryLowEventHandler?.Invoke(this, e);
         }
 
         /**
@@ -1417,12 +1333,7 @@ namespace Tizen.NUI
 
             // Populate all members of "e" (NUIApplicationMemoryLowEventArgs) with real data
             e.MemoryStatus = status;
-
-            if (_applicationMemoryLowEventHandler != null)
-            {
-                //here we send all data to user event handlers
-                _applicationMemoryLowEventHandler(this, e);
-            }
+            _applicationMemoryLowEventHandler?.Invoke(this, e);
         }
 
         /**
@@ -1465,16 +1376,7 @@ namespace Tizen.NUI
         {
             NUIApplicationAppControlEventArgs e = new NUIApplicationAppControlEventArgs();
             e.VoidP = voidp;
-
-            // Populate all members of "e" (NUIApplicationAppControlEventArgs) with real data
-            using (e.Application = Application.GetApplicationFromPtr(application))
-            {
-                if (_applicationAppControlEventHandler != null)
-                {
-                    //here we send all data to user event handlers
-                    _applicationAppControlEventHandler(this, e);
-                }
-            }
+            _applicationAppControlEventHandler?.Invoke(this, e);
         }
 
         private static Application _instance; // singleton
@@ -1494,7 +1396,7 @@ namespace Tizen.NUI
                 return null;
             }
 
-            Application ret = new Application(cPtr, false);
+            Application ret = Registry.GetManagedBaseHandleFromNativePtr(cPtr) as Application;
             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
             return ret;
         }
index dc75e9c..e16ff0a 100755 (executable)
@@ -39,9 +39,9 @@ namespace Tizen.NUI
         {
             if(_isCalled == false)
             {
-            _disposeQueueProcessDisposablesDelegate = new EventThreadCallback.CallbackDelegate(ProcessDisposables);
-            _eventThreadCallback = new EventThreadCallback(_disposeQueueProcessDisposablesDelegate);
-                _isCalled = true;
+               _disposeQueueProcessDisposablesDelegate = new EventThreadCallback.CallbackDelegate(ProcessDisposables);
+                _eventThreadCallback = new EventThreadCallback(_disposeQueueProcessDisposablesDelegate);
+               _isCalled = true;
             }
         }
 
@@ -58,7 +58,7 @@ namespace Tizen.NUI
             }
         }
 
-        private void ProcessDisposables()
+        public void ProcessDisposables()
         {
             lock (_listLock)
             {
index cd0a16d..25ff2fc 100755 (executable)
@@ -147,6 +147,8 @@ namespace Tizen.NUI
             _application.AppControl += OnAppControl;
 
             _application.MainLoop();
+
+            DisposeQueue.Instance.ProcessDisposables();
             _application.Dispose();
         }
 
index 32f1a73..fbd378a 100644 (file)
@@ -209,13 +209,10 @@ namespace Tizen.NUI
         private void OnTimeTick(IntPtr application, IntPtr watchTime)
         {
             TimeTickEventArgs e = new TimeTickEventArgs();
-            using (e.Application = Application.GetApplicationFromPtr(application))
-            {
-            using (e.WatchTime = WatchTime.GetWatchTimeFromPtr(watchTime))
-            {
-                _timeTickEventHandler?.Invoke(this, e);
-            }
-            }
+            e.Application = this;
+            e.WatchTime = WatchTime.GetWatchTimeFromPtr(watchTime);
+
+            _timeTickEventHandler?.Invoke(this, e);
 
         }
 
@@ -289,13 +286,9 @@ namespace Tizen.NUI
         {
             AmbientTickEventArgs e = new AmbientTickEventArgs();
 
-            using (e.Application = Application.GetApplicationFromPtr(application))
-            {
-            using (e.WatchTime = WatchTime.GetWatchTimeFromPtr(watchTime))
-            {
-                _ambientTickEventHandler?.Invoke(this, e);
-            }
-            }
+            e.Application = this;
+            e.WatchTime = WatchTime.GetWatchTimeFromPtr(watchTime);
+            _ambientTickEventHandler?.Invoke(this, e);
         }
 
         internal WatchTimeSignal AmbientTickSignal()
@@ -367,11 +360,9 @@ namespace Tizen.NUI
         private void OnAmbientChanged(IntPtr application, bool changed)
         {
             AmbientChangedEventArgs e = new AmbientChangedEventArgs();
-            using (e.Application = Application.GetApplicationFromPtr(application))
-            {
-                e.Changed = changed;
-                _ambientChangedEventHandler?.Invoke(this, e);
-            }
+            e.Application = this;
+            e.Changed = changed;
+            _ambientChangedEventHandler?.Invoke(this, e);
         }
 
         internal WatchBoolSignal AmbientChangedSignal()