Refactor bindings 66/158266/3
authorLukasz Stanislawski <l.stanislaws@samsung.com>
Mon, 30 Oct 2017 13:13:59 +0000 (14:13 +0100)
committerLukasz Stanislawski <l.stanislaws@samsung.com>
Mon, 30 Oct 2017 13:32:08 +0000 (14:32 +0100)
Make AppItemView not use ApplicationInfo directly.

Change-Id: I081cabfbd8b777db7fee3b7d88bcde4b5d8b32d1

TaskManager/TaskManager.Tizen/Model/TaskmanagedAppController.cs
TaskManager/TaskManager.Tizen/ViewModels/MainViewModel.cs
TaskManager/TaskManager.Tizen/Views/AppItemView.xaml.cs
TaskManager/TaskManager.Tizen/Views/ClearAllItemView.xaml.cs
TaskManager/TaskManager.Tizen/Views/MainView.xaml

index 633bcde79791ea82d11901065fc11fd7a6d69679..de344e96d558b69c277998d2c954015d946354a2 100644 (file)
@@ -44,11 +44,11 @@ namespace TaskManager.Tizen.Model
 
         public void Dismiss()
         {
-            TaskManagerLogger.Debug("Dismiss");
             _controller.Delete();
 
             if (_context != null)
                 _context.Terminate();
+            TaskManagerLogger.Debug($"{_appId} dismissed");
         }
 
         public void Resume()
index d5b7a229ea251353d7de4b30d15c128afbd2fa1b..11d4deb1a7175fb68a076bcfc218a0e6d9a9945e 100644 (file)
@@ -72,6 +72,7 @@ namespace TaskManager.Tizen.ViewModels
             ApplicationInfo appInfo = app as ApplicationInfo;
             if (appInfo != null)
             {
+                TaskManagerLogger.Debug($"Resuming '{appInfo.Name}' app");
                 try
                 {
                     appInfo.Controller.Resume();
@@ -89,6 +90,7 @@ namespace TaskManager.Tizen.ViewModels
             ApplicationInfo appInfo = app as ApplicationInfo;
             if (appInfo != null)
             {
+                TaskManagerLogger.Debug($"Killing '{appInfo.Name}' app");
                 try
                 {
                     appInfo.Controller.Dismiss();
@@ -103,6 +105,7 @@ namespace TaskManager.Tizen.ViewModels
 
         private void KillAllApplications()
         {
+            TaskManagerLogger.Debug("");
             foreach (var app in this.Applications)
             {
                 try
index 2775e7b997cea211652a190910afbde0083e87ec..d3fd9bd74af8258bb54cfa3f5016d97c6d59ecea 100644 (file)
@@ -31,14 +31,27 @@ namespace TaskManager.Tizen.Views
         public static readonly BindableProperty ScrollerProperty = BindableProperty.Create(nameof(Scroller), typeof(ScrollView), typeof(ContentView), null, BindingMode.TwoWay, null);
         public ScrollView Scroller
         {
-            set
-            {
-                SetValue(ScrollerProperty, value);
-            }
-            get
-            {
-                return (ScrollView)GetValue(ScrollerProperty);
-            }
+            set { SetValue(ScrollerProperty, value); }
+            get { return (ScrollView)GetValue(ScrollerProperty); }
+        }
+
+        public static readonly BindableProperty OnIconTappedProperty = BindableProperty.Create(nameof(OnIconTapped),
+    typeof(ICommand), typeof(ContentView), null, BindingMode.OneWay, null);
+
+        public ICommand OnIconTapped
+        {
+            set { SetValue(OnIconTappedProperty, value); }
+            get { return (ICommand)GetValue(OnIconTappedProperty); }
+        }
+
+
+        public static readonly BindableProperty OnIconDismissedProperty = BindableProperty.Create(nameof(OnIconDismissed),
+    typeof(ICommand), typeof(ContentView), null, BindingMode.OneWay, null);
+
+        public ICommand OnIconDismissed
+        {
+            set { SetValue(OnIconDismissedProperty, value); }
+            get { return (ICommand)GetValue(OnIconDismissedProperty); }
         }
 
         public AppItemView()
@@ -48,8 +61,7 @@ namespace TaskManager.Tizen.Views
 
         private void OnTapped(object sender, EventArgs e)
         {
-            var appInfo = BindingContext as ApplicationInfo;
-            appInfo?.Controller.Resume();
+            OnIconTapped?.Execute(BindingContext);
         }
 
         private async void OnPanUpdated(object sender, PanUpdatedEventArgs e)
@@ -106,8 +118,7 @@ namespace TaskManager.Tizen.Views
 
         private void DismissApp()
         {
-            var appInfo = BindingContext as ApplicationInfo;
-            appInfo?.Controller.Dismiss();
+            OnIconDismissed?.Execute(BindingContext);
         }
 
         private void Collapse()
index 5bc3ad131bfd3adedff506f4ec000275ea55ad78..e5c35865c2187cabe8744e9482fed33dacae5c12 100644 (file)
@@ -6,6 +6,7 @@ using System.Threading.Tasks;
 using System.Windows.Input;
 using Tizen;
 using Xamarin.Forms;
+using TaskManager.Tizen.Utils;
 
 namespace TaskManager.Tizen.Views
 {
@@ -27,11 +28,7 @@ namespace TaskManager.Tizen.Views
 
         private void OnTapped(object sender, EventArgs e)
         {
-            Log.Debug("TSK_MGR", "Clear all item tapped");
-            if (OnIconTapped == null)
-            {
-                return;
-            }
+            TaskManagerLogger.Debug("Clear all item tapped");
             OnIconTapped?.Execute(sender);
         }
     }
index db93d884ecdfaed18a53b91af1489e648798adbf..6c9bcd155f6110cfe37acf25985a4b0b89e79972 100644 (file)
@@ -5,6 +5,7 @@
              xmlns:views="clr-namespace:TaskManager.Tizen.Views;assembly=TaskManager.Tizen"
              xmlns:controls="clr-namespace:TaskManager.Tizen.Controls;assembly=TaskManager.Tizen"
              x:Class="TaskManager.Tizen.Views.MainView"
+             x:Name="root"
              ContentVisible="{Binding Applications, Converter={StaticResource ListToBoolConverter}}"
              >
 
@@ -30,7 +31,7 @@
             <views:BindableStackLayout.ItemTemplate>
               <DataTemplate>
                 <ViewCell>
-                  <views:AppItemView Scroller="{x:Reference scroller}"/>
+                  <views:AppItemView Scroller="{x:Reference scroller}" OnIconTapped="{Binding BindingContext.ResumeApp, Source={x:Reference Name=root}}" OnIconDismissed="{Binding BindingContext.KillApp, Source={x:Reference Name=root}}"/>
                 </ViewCell>
               </DataTemplate>
             </views:BindableStackLayout.ItemTemplate>