Refactoring the UA app (#177)
author유리나/Common Platform Lab(SR)/Staff Engineer/삼성전자 <rina6350.you@samsung.com>
Mon, 30 Mar 2020 00:01:51 +0000 (09:01 +0900)
committer안주원/Common Platform Lab(SR)/Principal Engineer/삼성전자 <juwon.ahn@samsung.com>
Mon, 30 Mar 2020 00:01:51 +0000 (09:01 +0900)
test/UnderArmour/MapMyRun/MapMyRun.Tizen/App.xaml.cs
test/UnderArmour/MapMyRun/MapMyRun.Tizen/views/LoadingPage.xaml.cs
test/UnderArmour/MapMyRun/MapMyRun.Tizen/views/WorkoutMainLoadingPage.xaml.cs
test/UnderArmour/MapMyRun/MapMyRun.Tizen/views/WorkoutMainPage.xaml.cs
test/UnderArmour/MapMyRun/MapMyRun.Tizen/views/WorkoutMainPageGPS.xaml.cs
test/UnderArmour/MapMyRun/MapMyRun/Models/Dispatcher.cs

index ec210e99e9ad9f7d378180e26efd0833a67635fa..59188be3ef26fe8026e3441f23ba4e23c67ee7ea 100755 (executable)
@@ -17,9 +17,8 @@ namespace MapMyRun.Tizen
     [XamlCompilation(XamlCompilationOptions.Compile)]
     public partial class App : Application
     {
-        private const string ServiceAppId = "org.tizen.example.MapMyRunService";
-        //private const string ServiceAppId = "org.tizen.mapmyrunservice";
-        private readonly Loading loading;
+        //private const string ServiceAppId = "org.tizen.example.MapMyRunService";
+        private const string ServiceAppId = "org.tizen.mapmyrunservice";
         public Workout workout;
         public SettingManager settingManager;
         public App()
@@ -27,17 +26,13 @@ namespace MapMyRun.Tizen
             InitializeComponent();
             var dispatcher = MapMyRun.Models.Dispatcher.Instance;
             settingManager = new SettingManager(dispatcher);
-            loading = new Loading(new AppLauncher(), new MessagePortHandler(),
-                dispatcher, new PhoneService(dispatcher, new TizenPlatformService()), settingManager, ServiceAppId);
-            MainPage = new LoadingPage(loading);
             workout = new Workout(dispatcher, new PermissionManager(dispatcher));
-            workout.StartListenWorkoutData();
+            MainPage = new NavigationPage(new LoadingPage());
         }
 
-        protected override void OnStart()
+               protected override void OnStart()
         {
             Console.WriteLine("OnStart!========================");
-            loading.StartLoading();
         }
 
         protected override void OnSleep()
index 5a33546046540b05287536361d14a7c7efb0378b..2bd3953cdcfb64619ad8edd0f669bdc08020fbbb 100755 (executable)
@@ -17,6 +17,7 @@ namespace MapMyRun.Tizen.Views
     public partial class LoadingPage : CirclePage
     {
         private readonly Loading _loading;
+        private const string ServiceAppId = "org.tizen.mapmyrunservice";
         public static readonly BindableProperty ProgressProperty =
             BindableProperty.Create("Progress",
                                     typeof(double),
@@ -24,25 +25,33 @@ namespace MapMyRun.Tizen.Views
                                     propertyChanged: (b, o, n) =>
                                     ProgressBarProgressChanged((CircleProgressBarSurfaceItem)b, (double)n));
 
-        public LoadingPage(Loading loading)
+        public LoadingPage()
         {
             InitializeComponent();
-            _loading = loading;
-            BindingContext = new LoadingPageModel(_loading);
             ProgressBar.SetBinding(ProgressProperty, "Progress");
+
+            var dispatcher = MapMyRun.Models.Dispatcher.Instance;
+            _loading = new Loading(new AppLauncher(), new MessagePortHandler(),
+                dispatcher, new PhoneService(dispatcher, new TizenPlatformService()), ((App)Application.Current).settingManager, ServiceAppId);
+
+            BindingContext = new LoadingPageModel(_loading);
+            Appearing += (s, e) =>
+            {
+                _loading.StartLoading();
+                (Application.Current as App).workout.StartListenWorkoutData();
+            };
         }
 
-        private static void ProgressBarProgressChanged(CircleProgressBarSurfaceItem progressBar, double progress)
+               private static void ProgressBarProgressChanged(CircleProgressBarSurfaceItem progressBar, double progress)
         {
             progressBar.CancelAnimation();
             progressBar.ProgressTo(progress, 200);
             if (progress >= 1)
             {
-                Device.StartTimer(TimeSpan.FromSeconds(0.3), () =>
-                {
-                    Application.Current.MainPage = new NavigationPage(new MainPage());
-                    return false;
-                });
+                               Device.BeginInvokeOnMainThread(() =>
+                               {
+                                       ((App)Application.Current).MainPage.Navigation.PushAsync(new MainPage());
+                               });
             }
         }
     }
index c1fd2ba020ac3467f489da6d1b7ae9515bf9f549..ba4ba68dc6968d6901d5423b7927686830412f34 100755 (executable)
@@ -83,7 +83,7 @@ namespace MapMyRun.Tizen.Views
             await Task.Delay(500);
             image.FadeTo(ZERO_OPACITY, 300);
             await image.ScaleTo(10, 300);
-            Application.Current.MainPage = new WorkoutMainIndexPage();
+                       await ((App)Application.Current).MainPage.Navigation.PushAsync(new WorkoutMainIndexPage());
 
             // TODO : Move proper position
             Workout workout = (Application.Current as App).workout;
index 8557602c35af142964eb03cf09923bef888bedd9..6c709bfc073c7021a28ecbd326f67102e87534e0 100755 (executable)
@@ -214,8 +214,8 @@ namespace MapMyRun.Tizen.Views
             {
                 Workout workout = (Application.Current as App).workout;
                 workout.FinishWorkout();
-                Application.Current.MainPage = new NavigationPage(new MainPage());
-            };
+                               ((App)Application.Current).MainPage.Navigation.PushAsync(new MainPage());
+                       };
         }
 
         void OnPageClick(object s, EventArgs e)
index aea66839ca9bfb66e4c59fd64f8fb971c560b74e..8b60660d6eb0b38ad15132fe268b6f20bd15840e 100755 (executable)
@@ -106,7 +106,7 @@ namespace MapMyRun.Tizen.Views
                 Workout workout = (Application.Current as App).workout;
                 workout.FinishWorkout();
 
-                Application.Current.MainPage = new NavigationPage(new MainPage());
+                ((App)Application.Current).MainPage.Navigation.PushAsync(new MainPage());
             };
 
             Device.StartTimer(TimeSpan.FromMilliseconds(100), () =>
index c7deeb884cee960790643f3f97bd9b3ea013e6f3..f34ed692a513afecd480a5098c6d1d7dfd24f404 100755 (executable)
@@ -8,8 +8,8 @@ namespace MapMyRun.Models
     public class Dispatcher : IDispatcher
     {
         IMessagePortHandler _messagePortHandler = null;
-        private const string ServiceAppId = "org.tizen.example.MapMyRunService";
-        //private const string ServiceAppId = "org.tizen.mapmyrunservice";
+        //private const string ServiceAppId = "org.tizen.example.MapMyRunService";
+        private const string ServiceAppId = "org.tizen.mapmyrunservice";
         private const string LocalPort = "APP_PORT";
         private const string RemotePort = "SERVICE_PORT";
         public const string OperationKey = "operation";