From 0aa24fec42cb37283cd04cef1afcb882212e5772 Mon Sep 17 00:00:00 2001 From: Hwankyu Jhun Date: Mon, 27 Feb 2017 14:02:29 +0900 Subject: [PATCH] Create AppEventCallbacks in the backend constructors Change-Id: I1d5ad122eb8ee6637fab3b4434388e059762dd32 Signed-off-by: Hwankyu Jhun --- .../ServiceCoreBackend.cs | 17 +++++++++++++---- .../Tizen.Applications.CoreBackend/UICoreBackend.cs | 17 +++++++++++++---- 2 files changed, 26 insertions(+), 8 deletions(-) diff --git a/src/Tizen.Applications.Service/Tizen.Applications.CoreBackend/ServiceCoreBackend.cs b/src/Tizen.Applications.Service/Tizen.Applications.CoreBackend/ServiceCoreBackend.cs index c8438f3..4a86b80 100755 --- a/src/Tizen.Applications.Service/Tizen.Applications.CoreBackend/ServiceCoreBackend.cs +++ b/src/Tizen.Applications.Service/Tizen.Applications.CoreBackend/ServiceCoreBackend.cs @@ -28,12 +28,21 @@ namespace Tizen.Applications.CoreBackend private IntPtr _localeChangedEventHandle = IntPtr.Zero; private IntPtr _regionChangedEventHandle = IntPtr.Zero; private bool _disposedValue = false; + private Interop.Service.AppEventCallback _onLowMemoryNative; + private Interop.Service.AppEventCallback _onLowBatteryNative; + private Interop.Service.AppEventCallback _onLocaleChangedNative; + private Interop.Service.AppEventCallback _onRegionChangedNative; public ServiceCoreBackend() { _callbacks.OnCreate = new Interop.Service.ServiceAppCreateCallback(OnCreateNative); _callbacks.OnTerminate = new Interop.Service.ServiceAppTerminateCallback(OnTerminateNative); _callbacks.OnAppControl = new Interop.Service.ServiceAppControlCallback(OnAppControlNative); + + _onLowMemoryNative = new Interop.Service.AppEventCallback(OnLowMemoryNative); + _onLowBatteryNative = new Interop.Service.AppEventCallback(OnLowBatteryNative); + _onLocaleChangedNative = new Interop.Service.AppEventCallback(OnLocaleChangedNative); + _onRegionChangedNative = new Interop.Service.AppEventCallback(OnRegionChangedNative); } public override void Exit() @@ -46,24 +55,24 @@ namespace Tizen.Applications.CoreBackend base.Run(args); ErrorCode err = ErrorCode.None; - err = Interop.Service.AddEventHandler(out _lowMemoryEventHandle, AppEventType.LowMemory, OnLowMemoryNative, IntPtr.Zero); + err = Interop.Service.AddEventHandler(out _lowMemoryEventHandle, AppEventType.LowMemory, _onLowMemoryNative, IntPtr.Zero); if (err != ErrorCode.None) { Log.Error(LogTag, "Failed to add event handler for LowMemory event. Err = " + err); } - err = Interop.Service.AddEventHandler(out _lowBatteryEventHandle, AppEventType.LowBattery, OnLowBatteryNative, IntPtr.Zero); + err = Interop.Service.AddEventHandler(out _lowBatteryEventHandle, AppEventType.LowBattery, _onLowBatteryNative, IntPtr.Zero); if (err != ErrorCode.None) { Log.Error(LogTag, "Failed to add event handler for LowBattery event. Err = " + err); } - err = Interop.Service.AddEventHandler(out _localeChangedEventHandle, AppEventType.LanguageChanged, OnLocaleChangedNative, IntPtr.Zero); + err = Interop.Service.AddEventHandler(out _localeChangedEventHandle, AppEventType.LanguageChanged, _onLocaleChangedNative, IntPtr.Zero); if (err != ErrorCode.None) { Log.Error(LogTag, "Failed to add event handler for LocaleChanged event. Err = " + err); } - err = Interop.Service.AddEventHandler(out _regionChangedEventHandle, AppEventType.RegionFormatChanged, OnRegionChangedNative, IntPtr.Zero); + err = Interop.Service.AddEventHandler(out _regionChangedEventHandle, AppEventType.RegionFormatChanged, _onRegionChangedNative, IntPtr.Zero); if (err != ErrorCode.None) { Log.Error(LogTag, "Failed to add event handler for RegionFormatChanged event. Err = " + err); diff --git a/src/Tizen.Applications.UI/Tizen.Applications.CoreBackend/UICoreBackend.cs b/src/Tizen.Applications.UI/Tizen.Applications.CoreBackend/UICoreBackend.cs index 9d8c2d1..212334d 100755 --- a/src/Tizen.Applications.UI/Tizen.Applications.CoreBackend/UICoreBackend.cs +++ b/src/Tizen.Applications.UI/Tizen.Applications.CoreBackend/UICoreBackend.cs @@ -28,6 +28,10 @@ namespace Tizen.Applications.CoreBackend private IntPtr _localeChangedEventHandle = IntPtr.Zero; private IntPtr _regionChangedEventHandle = IntPtr.Zero; private bool _disposedValue = false; + private Interop.Application.AppEventCallback _onLowMemoryNative; + private Interop.Application.AppEventCallback _onLowBatteryNative; + private Interop.Application.AppEventCallback _onLocaleChangedNative; + private Interop.Application.AppEventCallback _onRegionChangedNative; public UICoreBackend() { @@ -36,6 +40,11 @@ namespace Tizen.Applications.CoreBackend _callbacks.OnAppControl = new Interop.Application.AppControlCallback(OnAppControlNative); _callbacks.OnResume = new Interop.Application.AppResumeCallback(OnResumeNative); _callbacks.OnPause = new Interop.Application.AppPauseCallback(OnPauseNative); + + _onLowMemoryNative = new Interop.Application.AppEventCallback(OnLowMemoryNative); + _onLowBatteryNative = new Interop.Application.AppEventCallback(OnLowBatteryNative); + _onLocaleChangedNative = new Interop.Application.AppEventCallback(OnLocaleChangedNative); + _onRegionChangedNative = new Interop.Application.AppEventCallback(OnRegionChangedNative); } public override void Exit() @@ -48,24 +57,24 @@ namespace Tizen.Applications.CoreBackend base.Run(args); ErrorCode err = ErrorCode.None; - err = Interop.Application.AddEventHandler(out _lowMemoryEventHandle, AppEventType.LowMemory, OnLowMemoryNative, IntPtr.Zero); + err = Interop.Application.AddEventHandler(out _lowMemoryEventHandle, AppEventType.LowMemory, _onLowMemoryNative, IntPtr.Zero); if (err != ErrorCode.None) { Log.Error(LogTag, "Failed to add event handler for LowMemory event. Err = " + err); } - err = Interop.Application.AddEventHandler(out _lowBatteryEventHandle, AppEventType.LowBattery, OnLowBatteryNative, IntPtr.Zero); + err = Interop.Application.AddEventHandler(out _lowBatteryEventHandle, AppEventType.LowBattery, _onLowBatteryNative, IntPtr.Zero); if (err != ErrorCode.None) { Log.Error(LogTag, "Failed to add event handler for LowBattery event. Err = " + err); } - err = Interop.Application.AddEventHandler(out _localeChangedEventHandle, AppEventType.LanguageChanged, OnLocaleChangedNative, IntPtr.Zero); + err = Interop.Application.AddEventHandler(out _localeChangedEventHandle, AppEventType.LanguageChanged, _onLocaleChangedNative, IntPtr.Zero); if (err != ErrorCode.None) { Log.Error(LogTag, "Failed to add event handler for LocaleChanged event. Err = " + err); } - err = Interop.Application.AddEventHandler(out _regionChangedEventHandle, AppEventType.RegionFormatChanged, OnRegionChangedNative, IntPtr.Zero); + err = Interop.Application.AddEventHandler(out _regionChangedEventHandle, AppEventType.RegionFormatChanged, _onRegionChangedNative, IntPtr.Zero); if (err != ErrorCode.None) { Log.Error(LogTag, "Failed to add event handler for RegionFormatChanged event. Err = " + err); -- 2.7.4