Implements delete contents in Music tab 71/137871/3
authorHyerim Kim <rimi.kim@samsung.com>
Mon, 10 Jul 2017 07:09:01 +0000 (16:09 +0900)
committerHyerim Kim <rimi.kim@samsung.com>
Tue, 11 Jul 2017 08:23:22 +0000 (17:23 +0900)
Changes the IsDeleteStatus property to the TabStatus property according to review comment

Change-Id: Ic67ebf2baa26a2f5907c8d829da359da9cb3965a
Signed-off-by: Hyerim Kim <rimi.kim@samsung.com>
18 files changed:
TVMediaHub/TVMediaHub.Tizen/Models/MediaShortcutInfo.cs
TVMediaHub/TVMediaHub.Tizen/TVMediaHub.Tizen.csproj
TVMediaHub/TVMediaHub.Tizen/ViewModels/ImageTabViewModel.cs
TVMediaHub/TVMediaHub.Tizen/ViewModels/MusicTabViewModel.cs
TVMediaHub/TVMediaHub.Tizen/ViewModels/TabStatus.cs [new file with mode: 0755]
TVMediaHub/TVMediaHub.Tizen/ViewModels/VideoTabViewModel.cs
TVMediaHub/TVMediaHub.Tizen/Views/ImageItem.xaml
TVMediaHub/TVMediaHub.Tizen/Views/ImageItem.xaml.cs
TVMediaHub/TVMediaHub.Tizen/Views/ImageTab.xaml
TVMediaHub/TVMediaHub.Tizen/Views/ImageTab.xaml.cs
TVMediaHub/TVMediaHub.Tizen/Views/MusicGroup.xaml.cs [changed mode: 0644->0755]
TVMediaHub/TVMediaHub.Tizen/Views/MusicItem.xaml.cs
TVMediaHub/TVMediaHub.Tizen/Views/MusicTab.xaml
TVMediaHub/TVMediaHub.Tizen/Views/MusicTab.xaml.cs
TVMediaHub/TVMediaHub.Tizen/Views/VideoItem.xaml [changed mode: 0644->0755]
TVMediaHub/TVMediaHub.Tizen/Views/VideoItem.xaml.cs
TVMediaHub/TVMediaHub.Tizen/Views/VideoTab.xaml
TVMediaHub/TVMediaHub.Tizen/Views/VideoTab.xaml.cs

index 0ddca92..dc49f5f 100755 (executable)
@@ -17,6 +17,7 @@
 using System.ComponentModel;
 using TVMediaHub.Tizen.DataModels;
 using Tizen.Content.MediaContent;
+using TVMediaHub.Tizen.ViewModels;
 
 namespace TVMediaHub.Tizen.Models
 {
@@ -44,26 +45,25 @@ namespace TVMediaHub.Tizen.Models
         }
 
         /// <summary>
-        /// A flag that whether the content is delete mode or not
+        /// An enumeration value indicates current tab's status
         /// </summary>
-        private bool isDeleteStatus;
-
+        private TabStatus currentTabStatus = TabStatus.Default;
         /// <summary>
-        /// Gets or sets the isDeleteStatus
+        /// Gets or sets the CurrentTabStatus
         /// </summary>
-        public bool IsDeleteStatus
+        public TabStatus CurrentTabStatus
         {
             get
             {
-                return isDeleteStatus;
+                return currentTabStatus;
             }
 
             set
             {
-                if (isDeleteStatus != value)
+                if (currentTabStatus != value)
                 {
-                    isDeleteStatus = value;
-                    OnPropertyChanged("IsDeleteStatus");
+                    currentTabStatus = value;
+                    OnPropertyChanged("CurrentTabStatus");
                 }
             }
         }
@@ -106,7 +106,7 @@ namespace TVMediaHub.Tizen.Models
         public MediaShortcutInfo(MediaInformationEx information)
         {
             Information = information;
-            IsDeleteStatus = false;
+            CurrentTabStatus = TabStatus.Default;
         }
 
         /// <summary>
index 3f8a617..3ea1520 100755 (executable)
@@ -90,6 +90,7 @@
     <Compile Include="ViewModels\MusicTabViewModel.cs" />
     <Compile Include="ViewModels\MusicPlayerViewModelLocator.cs" />
     <Compile Include="ViewModels\MusicTabViewModelLocator.cs" />
+    <Compile Include="ViewModels\TabStatus.cs" />
     <Compile Include="ViewModels\VideoPlayerViewModel.cs" />
     <Compile Include="ViewModels\VideoTabViewModel.cs" />
     <Compile Include="ViewModels\VideoTabViewModelLocator.cs" />
index 29869fe..94e310a 100755 (executable)
@@ -157,26 +157,26 @@ namespace TVMediaHub.Tizen.ViewModels
         public ICommand SelectAllContentCommand { get; set; }
 
         /// <summary>
-        /// A flag that whether the content is delete mode or not
+        /// An enumeration value indicates current image tab's status
         /// </summary>
-        private bool isDeleteStatus;
+        private TabStatus imageTabStatus = TabStatus.Default;
 
         /// <summary>
-        /// Gets or sets the isDeleteStatus
+        /// Gets or sets the ImageTabStatus
         /// </summary>
-        public bool IsDeleteStatus
+        public TabStatus ImageTabStatus
         {
             get
             {
-                return isDeleteStatus;
+                return imageTabStatus;
             }
 
             set
             {
-                if (isDeleteStatus != value)
+                if (imageTabStatus != value)
                 {
-                    isDeleteStatus = value;
-                    OnPropertyChanged("IsDeleteStatus");
+                    imageTabStatus = value;
+                    OnPropertyChanged("ImageTabStatus");
                 }
             }
         }
@@ -320,13 +320,21 @@ namespace TVMediaHub.Tizen.ViewModels
             {
                 SelectedList.Clear();
                 OnPropertyChanged("SelectedCount");
-                IsDeleteStatus = !IsDeleteStatus;
+
+                if (ImageTabStatus == TabStatus.Default)
+                {
+                    ImageTabStatus = TabStatus.Delete;
+                }
+                else
+                {
+                    ImageTabStatus = TabStatus.Default;
+                }
 
                 foreach (var group in ImageList)
                 {
                     foreach (var info in group.Contents)
                     {
-                        info.IsDeleteStatus = IsDeleteStatus;
+                        info.CurrentTabStatus = ImageTabStatus;
                     }
                 }
             });
@@ -363,7 +371,7 @@ namespace TVMediaHub.Tizen.ViewModels
 
             SetCurrentImageInfo = new Command<MediaInformationEx>((info) =>
             {
-                if (IsDeleteStatus)
+                if (ImageTabStatus == TabStatus.Delete)
                 {
                     if (SelectedList.Contains(info))
                     {
index 215ce89..bb4607a 100755 (executable)
  * limitations under the License.
  */
 
+using System;
 using System.Collections.Generic;
 using System.Collections.ObjectModel;
 using System.ComponentModel;
+using System.IO;
 using System.Threading;
 using System.Windows.Input;
 using TVMediaHub.Tizen.DataModels;
@@ -67,16 +69,77 @@ namespace TVMediaHub.Tizen.ViewModels
         public ICommand GetInformationsCommand { get; set; }
 
         /// <summary>
+        /// A command for deleting a video content
+        /// </summary>
+        public ICommand DeleteContentCommand { get; set; }
+
+        /// <summary>
+        /// A command for selecting all video contents
+        /// </summary>
+        public ICommand SelectAllContentCommand { get; set; }
+
+        /// <summary>
+        /// A command to set current music information
+        /// </summary>
+        public ICommand SelectMusicItem { get; set; }
+
+        /// <summary>
         /// A command for changing Source
         /// </summary>
         public ICommand ChangeSourceCommand { get; set; }
 
         /// <summary>
+        /// A command for changing tab's status
+        /// </summary>
+        public ICommand ChangeTabStatusCommand { get; set; }
+
+        /// <summary>
         /// The information of the current music
         /// </summary>
         public MediaInformationEx CurrentMusic { get; set; }
 
         /// <summary>
+        /// A value indicates current Music tab's status
+        /// </summary>
+        private TabStatus musicTabStatus = TabStatus.Default;
+
+        /// <summary>
+        /// Gets or sets the MusicTabStatus
+        /// </summary>
+        public TabStatus MusicTabStatus
+        {
+            get
+            {
+                return musicTabStatus;
+            }
+
+            set
+            {
+                if (musicTabStatus != value)
+                {
+                    musicTabStatus = value;
+                    OnPropertyChanged("MusicTabStatus");
+                }
+            }
+        }
+
+        /// <summary>
+        /// A list of video contents to be displayed
+        /// </summary>
+        public List<MediaInformationEx> SelectedList { get; set; }
+
+        /// <summary>
+        /// A count of SelectedList
+        /// </summary>
+        public int SelectedCount
+        {
+            get
+            {
+                return SelectedList.Count;
+            }
+        }
+
+        /// <summary>
         /// The sort option to display items of the music tab
         /// </summary>
         private SortOption option = SortOption.Title;
@@ -111,6 +174,7 @@ namespace TVMediaHub.Tizen.ViewModels
         {
             MusicList = new ObservableCollection<GroupItem>();
             sourcePairList = new Dictionary<string, string>();
+            SelectedList = new List<MediaInformationEx>();
             InitializeFooterItemsSource();
             InitializeCommands();
 
@@ -193,10 +257,94 @@ namespace TVMediaHub.Tizen.ViewModels
         }
 
         /// <summary>
-        /// A method for initializing commands that are used in Image tab
+        /// A method for initializing commands that are used in Music tab
         /// </summary>
         private void InitializeCommands()
         {
+            ChangeTabStatusCommand = new Command(() =>
+            {
+                SelectedList.Clear();
+                OnPropertyChanged("SelectedCount");
+
+                if (MusicTabStatus.Equals(TabStatus.Default))
+                {
+                    MusicTabStatus = TabStatus.Delete;
+                }
+                else
+                {
+                    MusicTabStatus = TabStatus.Default;
+                }
+            });
+
+            SelectAllContentCommand = new Command<bool>((IsSelectedAll) =>
+            {
+                if (IsSelectedAll)
+                {
+                    foreach (var group in MusicList)
+                    {
+                        foreach (var info in group.Contents)
+                        {
+                            if (!SelectedList.Contains(info.Information))
+                            {
+                                SelectedList.Add(info.Information);
+                            }
+                        }
+                    }
+                }
+                else
+                {
+                    SelectedList.Clear();
+                }
+
+                OnPropertyChanged("SelectedCount");
+            });
+
+            DeleteContentCommand = new Command<MediaInformationEx>((SelectedItem) =>
+            {
+                if (SelectedItem != null)
+                {
+                    SelectedList.Clear();
+                    SelectedList.Add(SelectedItem);
+                }
+
+                foreach (var info in SelectedList)
+                {
+                    try
+                    {
+                        File.Delete(info.MediaContentInformation.FilePath);
+                    }
+                    catch (Exception exception)
+                    {
+                        // TODO: Handling exceptions
+                        DbgPort.E("Exception - " + exception.Message);
+                        return;
+                    }
+
+                    MediaHubImpl.GetInstance.MusicProviderInstance.Delete(info);
+                }
+            });
+
+            SelectMusicItem = new Command<MediaInformationEx>((info) =>
+            {
+                if (MusicTabStatus == TabStatus.Delete)
+                {
+                    if (SelectedList.Contains(info))
+                    {
+                        SelectedList.Remove(info);
+                    }
+                    else
+                    {
+                        SelectedList.Add(info);
+                    }
+
+                    OnPropertyChanged("SelectedCount");
+                }
+                else
+                {
+                    SetCurrentMusic(info);
+                }
+            });
+
             ChangeSortOptionCommand = new Command<string>((opt) =>
             {
                 var optionString = opt.ToLower();
@@ -243,6 +391,7 @@ namespace TVMediaHub.Tizen.ViewModels
                 }, "");
             });
 
+            OnPropertyChanged("ChangeTabStatusCommand");
             OnPropertyChanged("ChangeSortOptionCommand");
         }
 
diff --git a/TVMediaHub/TVMediaHub.Tizen/ViewModels/TabStatus.cs b/TVMediaHub/TVMediaHub.Tizen/ViewModels/TabStatus.cs
new file mode 100755 (executable)
index 0000000..5925cbf
--- /dev/null
@@ -0,0 +1,24 @@
+/*
+ * Copyright (c) 2017 Samsung Electronics Co., Ltd
+ *
+ * Licensed under the Flora License, Version 1.1 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://floralicense.org/license/
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+namespace TVMediaHub.Tizen.ViewModels\r
+{\r
+    public enum TabStatus\r
+    {\r
+        Default,\r
+        Delete\r
+    }\r
+}\r
index 480aad2..58bbca0 100755 (executable)
@@ -127,11 +127,6 @@ namespace TVMediaHub.Tizen.ViewModels
         }
 
         /// <summary>
-        /// A flag that whether the content is delete mode or not
-        /// </summary>
-        private bool isDeleteStatus;
-
-        /// <summary>
         /// A sort option
         /// </summary>
         private SortOption option = SortOption.Title;
@@ -157,21 +152,26 @@ namespace TVMediaHub.Tizen.ViewModels
         }
 
         /// <summary>
-        /// Gets or sets the DeleteStatus
+        /// An enumeration value indicates current video tab's status
+        /// </summary>
+        private TabStatus videoTabStatus = TabStatus.Default;
+
+        /// <summary>
+        /// Gets or sets the VideoTabStatus
         /// </summary>
-        public bool IsDeleteStatus
+        public TabStatus VideoTabStatus
         {
             get
             {
-                return isDeleteStatus;
+                return videoTabStatus;
             }
 
             set
             {
-                if (isDeleteStatus != value)
+                if (videoTabStatus != value)
                 {
-                    isDeleteStatus = value;
-                    OnPropertyChanged("IsDeleteStatus");
+                    videoTabStatus = value;
+                    OnPropertyChanged("VideoTabStatus");
                 }
             }
         }
@@ -245,13 +245,20 @@ namespace TVMediaHub.Tizen.ViewModels
             {
                 SelectedList.Clear();
                 OnPropertyChanged("SelectedCount");
-                IsDeleteStatus = !IsDeleteStatus;
+                if (VideoTabStatus == TabStatus.Default)
+                {
+                    VideoTabStatus = TabStatus.Delete;
+                }
+                else
+                {
+                    VideoTabStatus = TabStatus.Default;
+                }
 
                 foreach (var group in VideoList)
                 {
                     foreach (var info in group.Contents)
                     {
-                        info.IsDeleteStatus = IsDeleteStatus;
+                        info.CurrentTabStatus = VideoTabStatus;
                     }
                 }
             });
@@ -320,7 +327,7 @@ namespace TVMediaHub.Tizen.ViewModels
             });
             SetCurrentVideoInfo = new Command<MediaInformationEx>((info) =>
             {
-                if (IsDeleteStatus)
+                if (VideoTabStatus == TabStatus.Delete)
                 {
                     if (SelectedList.Contains(info))
                     {
index 1c056c3..9eacdb9 100755 (executable)
@@ -5,7 +5,7 @@
                 xmlns:Utils="clr-namespace:TVMediaHub.Tizen.Utils"
                 xmlns:Views="clr-namespace:TVMediaHub.Tizen.Views"
                 ImageInfo="{Binding Information}"
-                IsDeleteMode="{Binding IsDeleteStatus}">
+                ImageTabStatus="{Binding CurrentTabStatus}">
     <Button x:Name="FocusArea"
             Opacity="0"
             Clicked="OnItemClicked"
index 6a9fa7a..39cb993 100755 (executable)
@@ -22,6 +22,7 @@ using TVMediaHub.Tizen.Utils;
 using TVMediaHub.Tizen.DataModels;
 using Xamarin.Forms;
 using Xamarin.Forms.Xaml;
+using TVMediaHub.Tizen.ViewModels;
 
 namespace TVMediaHub.Tizen.Views
 {
@@ -103,23 +104,23 @@ namespace TVMediaHub.Tizen.Views
         public ContextPopupItemSelectedEventHandler ContextPopupItemSelectedHandler;
 
         /// <summary>
-        /// Identifies the IsDeleteMode bindable property
+        /// Identifies the ImageTabStatus bindable property
         /// </summary>
-        public static readonly BindableProperty IsDeleteModeProperty = BindableProperty.Create("IsDeleteMode", typeof(bool), typeof(ImageItem), false);
+        public static readonly BindableProperty ImageTabStatusProperty = BindableProperty.Create("ImageTabStatus", typeof(TabStatus), typeof(ImageItem), TabStatus.Default);
 
         /// <summary>
-        /// Gets or sets the value whether item is delete mode or not
+        /// Gets or sets ImageTabStatus
         /// </summary>
-        public bool IsDeleteMode
+        public TabStatus ImageTabStatus
         {
             set
             {
-                SetValue(IsDeleteModeProperty, value);
+                SetValue(ImageTabStatusProperty, value);
             }
 
             get
             {
-                return (bool)GetValue(IsDeleteModeProperty);
+                return (TabStatus)GetValue(ImageTabStatusProperty);
             }
         }
 
@@ -248,7 +249,7 @@ namespace TVMediaHub.Tizen.Views
             ImageArea.LayoutTo(ImageAreaFocusedBounds, 167);
 #pragma warning restore CS4014
             OnItemClickedHandler?.Invoke(SelectedImage);
-            if (IsDeleteMode)
+            if (ImageTabStatus == TabStatus.Delete)
             {
                 if (CurStatus == ItemStatus.Normal)
                 {
@@ -308,9 +309,9 @@ namespace TVMediaHub.Tizen.Views
         /// <param name="e">A propertyChanged event argument</param>
         private void ImageTabPropertyChanged(object sender, PropertyChangedEventArgs e)
         {
-            if (e.PropertyName.CompareTo("IsDeleteMode") == 0)
+            if (e.PropertyName.CompareTo("ImageTabStatus") == 0)
             {
-                if (!IsDeleteMode)
+                if (ImageTabStatus == TabStatus.Default)
                 {
                     CurStatus = ItemStatus.Normal;
                     UpdateView();
@@ -378,7 +379,7 @@ namespace TVMediaHub.Tizen.Views
                             UnavailableIcon.LayoutTo(ImageFocusedBounds, 500, easing);
                         }
 
-                        if (IsDeleteMode)
+                        if (ImageTabStatus == TabStatus.Delete)
                         {
                             ImgCheckDimmed.LayoutTo(ImageAreaFocusedBounds, 500, easing);
                             ImgCheck.LayoutTo(ImageAreaFocusedBounds, 500, easing);
@@ -411,7 +412,7 @@ namespace TVMediaHub.Tizen.Views
 
             ImgFocused.LayoutTo(ShadowNormalBounds, 167, easing);
             ImgDimmed.LayoutTo(ImageAreaNormalBounds, 167, easing);
-            if (IsDeleteMode)
+            if (ImageTabStatus == TabStatus.Delete)
             {
                 ImgCheckDimmed.LayoutTo(ImageAreaNormalBounds, 167, easing);
                 ImgCheck.LayoutTo(ImageAreaNormalBounds, 167, easing);
index b87e6d7..47cf795 100755 (executable)
@@ -6,7 +6,7 @@
              xmlns:Views="clr-namespace:TVMediaHub.Tizen.Views"
              xmlns:ViewModels="clr-namespace:TVMediaHub.Tizen.ViewModels"
              ItemsSource="{Binding ImageList}"
-             IsDeleteStatus="{Binding IsDeleteStatus}"
+             ImageTabStatus="{Binding ImageTabStatus}"
              GetInformationsCommand="{Binding GetInformationsCommand}"
              ChangeSortOptionCommand="{Binding ChangeSortOptionCommand}"
              ChangeSourceCommand="{Binding ChangeSourceCommand}"
index 81b7d10..da44b5b 100755 (executable)
@@ -173,17 +173,17 @@ namespace TVMediaHub.Tizen.Views
         }
 
         /// <summary>
-        /// Identifies the IsDeleteStatus bindable property
+        /// Identifies the ImageTabStatus bindable property
         /// </summary>
-        public static readonly BindableProperty IsDeleteStatusProperty = BindableProperty.Create("IsDeleteStatus", typeof(bool), typeof(ImageTab), false);
+        public static readonly BindableProperty ImageTabStatusProperty = BindableProperty.Create("ImageTabStatus", typeof(TabStatus), typeof(ImageTab), TabStatus.Default);
 
         /// <summary>
-        /// Gets or sets IsDeleteStatus
+        /// Gets or sets ImageTabStatus
         /// </summary>
-        public bool IsDeleteStatus
+        public TabStatus ImageTabStatus
         {
-            get { return (bool)GetValue(IsDeleteStatusProperty); }
-            set { SetValue(IsDeleteStatusProperty, value); }
+            get { return (TabStatus)GetValue(ImageTabStatusProperty); }
+            set { SetValue(ImageTabStatusProperty, value); }
         }
 
         /// <summary>
@@ -320,7 +320,7 @@ namespace TVMediaHub.Tizen.Views
             ItemsSource.Clear();
             GalleryContentView.Children.Clear();
             BottomButtonList.Clear();
-            if (IsDeleteStatus)
+            if (ImageTabStatus == TabStatus.Delete)
             {
                 DeleteModeChangeCommand?.Execute("");
                 FooterNormal.IsVisible = true;
@@ -431,7 +431,7 @@ namespace TVMediaHub.Tizen.Views
                 var btn = list[buttonIndex].Value;
                 if (buttonIndex == 0)
                 {
-                    if (IsDeleteStatus)
+                    if (ImageTabStatus == TabStatus.Delete)
                     {
                         btn.On<Xamarin.Forms.PlatformConfiguration.Tizen>().SetNextFocusDownView(FooterDelete.GetSelectAllButton());
                         // TODO : FooterDelete.GetSelectAllButton().DropdownSource.ButtonOption.On<Xamarin.Forms.PlatformConfiguration.Tizen>().SetNextFocusUpView(btn);
@@ -444,7 +444,7 @@ namespace TVMediaHub.Tizen.Views
                 }
                 else if (buttonIndex == list.Count - 1)
                 {
-                    if (IsDeleteStatus)
+                    if (ImageTabStatus == TabStatus.Delete)
                     {
                         btn.On<Xamarin.Forms.PlatformConfiguration.Tizen>().SetNextFocusDownView(FooterDelete.GetCancelButton());
                         FooterDelete.GetCancelButton().On<Xamarin.Forms.PlatformConfiguration.Tizen>().SetNextFocusUpView(btn);
@@ -458,7 +458,7 @@ namespace TVMediaHub.Tizen.Views
                 }
                 else
                 {
-                    if (IsDeleteStatus)
+                    if (ImageTabStatus == TabStatus.Delete)
                     {
                         btn.On<Xamarin.Forms.PlatformConfiguration.Tizen>().SetNextFocusDownView(FooterDelete.GetOkButton());
                         // TODO :FooterDelete.GetCancelAllButton().ButtonOption.On<Xamarin.Forms.PlatformConfiguration.Tizen>().SetNextFocusUpView(btn);
old mode 100644 (file)
new mode 100755 (executable)
index 2056a21..34ea731
@@ -20,6 +20,7 @@ using System.ComponentModel;
 using System.Linq;
 using System.Text;
 using System.Threading.Tasks;
+using System.Windows.Input;
 using TVMediaHub.Tizen.Models;
 using TVMediaHub.Tizen.Utils;
 using Xamarin.Forms;
@@ -48,16 +49,35 @@ namespace TVMediaHub.Tizen.Views
         }
 
         /// <summary>
+        /// A list of music items
+        /// </summary>
+        public List<MusicItem> MusicItemList { get; set; }
+
+        /// <summary>
+        /// A command will be executed when item is clicked
+        /// </summary>
+        private ICommand ItemClickCommand;
+
+        /// <summary>
         /// A constructor
         /// </summary>
         public MusicGroup()
         {
             InitializeComponent();
             InitializeSize();
+            Init();
             PropertyChanged += MusicGroupPropertyChanged;
         }
 
         /// <summary>
+        /// A method for initializing several lists and properties that are used in this class
+        /// </summary>
+        private void Init()
+        {
+            MusicItemList = new List<MusicItem>();
+        }
+
+        /// <summary>
         /// A method for initializing sizes
         /// </summary>
         private void InitializeSize()
@@ -76,6 +96,15 @@ namespace TVMediaHub.Tizen.Views
         }
 
         /// <summary>
+        /// A method for setting the command to ItemClickCommand
+        /// </summary>
+        /// <param name="command">A command to be set</param>
+        public void SetClickCommand(ICommand command)
+        {
+            ItemClickCommand = command;
+        }
+
+        /// <summary>
         /// This method is called when the properties is changed
         /// </summary>
         /// <param name="sender">The source of the event</param>
@@ -85,14 +114,21 @@ namespace TVMediaHub.Tizen.Views
             if (e.PropertyName.Equals("ItemsSource"))
             {
                 var index = 0;
+                MusicItemList.Clear();
                 foreach (var item in ItemsSource)
                 {
                     var itemView = new MusicItem();
                     itemView.BindingContext = item;
+                    MusicItemList.Add(itemView);
                     itemView.OnFocusedEventHandler += (se, ev) =>
                     {
                         GroupContentArea.RaiseChild(itemView);
                     };
+                    itemView.OnItemClickedHandler += (info) =>
+                    {
+                        ItemClickCommand?.Execute(info);
+                    };
+
                     GroupContentArea.Children.Add(itemView, index / 4, index % 4);
                     index++;
                 }
index 92b2cad..cf11f6b 100755 (executable)
@@ -65,6 +65,16 @@ namespace TVMediaHub.Tizen.Views
         public EventHandler OnUnfocusedEventHandler;
 
         /// <summary>
+        /// A delegate will be executed when the item is clicked
+        /// </summary>
+        /// <param name="info">A clicked item's MediaInformation</param>
+        public delegate void ItemEventHandler(MediaInformationEx info);
+        /// <summary>
+        /// A ClickEventHandler for click event of the item
+        /// </summary>
+        public ItemEventHandler OnItemClickedHandler;
+
+        /// <summary>
         /// Bounds for TextArea when item is unfocused
         /// </summary>
         private Rectangle TextAreaNormalBounds;
@@ -154,9 +164,7 @@ namespace TVMediaHub.Tizen.Views
         /// <param name="e">A Focus event's argument</param>
         private void OnItemClicked(object sender, EventArgs e)
         {
-            DbgPort.D("MusicItem is clicked : " + (MusicInfo.MediaContentInformation as AudioInformation).Title);
-
-            MusicTabViewModelLocator.ViewModel.SetCurrentMusic(MusicInfo);
+            OnItemClickedHandler?.Invoke(MusicInfo);
         }
 
         /// <summary>
index c1fdee6..28b6afc 100755 (executable)
@@ -8,7 +8,13 @@
                   ChangeSortOptionCommand="{Binding ChangeSortOptionCommand}"
                   GetInformationsCommand="{Binding GetInformationsCommand}"
                   ChangeSourceCommand="{Binding ChangeSourceCommand}"
-                  ItemsSource="{Binding MusicList}">
+                  ItemsSource="{Binding MusicList}"
+                  ChangeTabStatusCommand="{Binding ChangeTabStatusCommand}"
+                  OnClickCommand="{Binding SelectMusicItem}"
+                  DeleteContentCommand="{Binding DeleteContentCommand}"
+                  SelectAllContentCommand="{Binding SelectAllContentCommand}"
+                  SelectedCount="{Binding SelectedCount}"
+                  MusicTabStatus="{Binding MusicTabStatus}">
     <!-- TODO : Fix to Guide  -->
 
     <RelativeLayout RelativeLayout.HeightConstraint="{ConstraintExpression Type=RelativeToParent, Property=Height, Factor=1}"
@@ -19,7 +25,8 @@
                                       IsVisible="False"
                                       RelativeLayout.HeightConstraint="{ConstraintExpression Type=RelativeToParent, Property=Height, Factor=1}"
                                       RelativeLayout.WidthConstraint="{ConstraintExpression Type=RelativeToParent, Property=Width, Factor=1}"
-                                      SelectedCount="{Binding SelectedCount}" />
+                                      SelectedCount="{Binding SelectedCount}"
+                                      ContentType="Music"/>
             <Views:FooterNormalStatus x:Name="FooterNormal"
                                       IsVisible="True"
                                       IsFooterEnabled="True"
index 7b3d946..2d5afb0 100755 (executable)
@@ -14,6 +14,8 @@
  * limitations under the License.
  */
 
+using System;
+using System.Collections.Generic;
 using System.Collections.ObjectModel;
 using System.Collections.Specialized;
 using System.Windows.Input;
@@ -39,6 +41,11 @@ namespace TVMediaHub.Tizen.Views
         private bool IsContentReady = false;
 
         /// <summary>
+        /// The flag that whether all contents are selected or not
+        /// </summary>
+        private bool IsSelectedAll { get; set; }
+
+        /// <summary>
         /// Identifies the ItemsSource bindable property
         /// </summary>
         public static readonly BindableProperty ItemsSourceProperty = BindableProperty.Create("ItemsSource", typeof(ObservableCollection<GroupItem>), typeof(MusicTab), default(ObservableCollection<GroupItem>));
@@ -67,6 +74,97 @@ namespace TVMediaHub.Tizen.Views
         }
 
         /// <summary>
+        /// Identifies the ChangeTabStatusCommand bindable property
+        /// </summary>
+        public static readonly BindableProperty ChangeTabStatusCommandProperty = BindableProperty.Create("ChangeTabStatusCommand", typeof(ICommand), typeof(MusicTab), default(ICommand));
+
+        /// <summary>
+        /// Gets or sets ChangeTabStatus Command
+        /// </summary>
+        public ICommand ChangeTabStatusCommand
+        {
+            get { return (ICommand)GetValue(ChangeTabStatusCommandProperty); }
+            set { SetValue(ChangeTabStatusCommandProperty, value); }
+        }
+
+        /// <summary>
+        /// Identifies the MusicTabStatus bindable property
+        /// </summary>
+        public static readonly BindableProperty MusicTabStatusProperty = BindableProperty.Create("MusicTabStatus", typeof(TabStatus), typeof(MusicTab), TabStatus.Default);
+
+        /// <summary>
+        /// Gets or sets MusicTabStatus
+        /// </summary>
+        public TabStatus MusicTabStatus
+        {
+            get { return (TabStatus)GetValue(MusicTabStatusProperty); }
+            set { SetValue(MusicTabStatusProperty, value); }
+        }
+
+        /// <summary>
+        /// Identifies the DeleteContentCommand bindable property
+        /// </summary>
+        public static readonly BindableProperty DeleteContentCommandProperty = BindableProperty.Create("DeleteContentCommand", typeof(ICommand), typeof(MusicTab), default(ICommand));
+
+        /// <summary>
+        /// Gets or sets DeleteContent Command
+        /// </summary>
+        public ICommand DeleteContentCommand
+        {
+            get { return (ICommand)GetValue(DeleteContentCommandProperty); }
+            set { SetValue(DeleteContentCommandProperty, value); }
+        }
+
+        /// <summary>
+        /// Identifies the DeleteContentCommand bindable property
+        /// </summary>
+        public static readonly BindableProperty SelectAllContentCommandProperty = BindableProperty.Create("SelectAllContentCommand", typeof(ICommand), typeof(MusicTab), default(ICommand));
+
+        /// <summary>
+        /// Gets or sets SelectAllContent Command
+        /// </summary>
+        public ICommand SelectAllContentCommand
+        {
+            get { return (ICommand)GetValue(SelectAllContentCommandProperty); }
+            set { SetValue(SelectAllContentCommandProperty, value); }
+        }
+
+        /// <summary>
+        /// Identifies the OnClickCommand bindable property
+        /// </summary>
+        public static readonly BindableProperty OnClickCommandProperty = BindableProperty.Create("OnClickCommand", typeof(ICommand), typeof(MusicTab), default(ICommand));
+
+        /// <summary>
+        /// Gets or sets OnClick Command
+        /// </summary>
+        public ICommand OnClickCommand
+        {
+            get
+            {
+                return (ICommand)GetValue(OnClickCommandProperty);
+            }
+
+            set
+            {
+                SetValue(OnClickCommandProperty, value);
+            }
+        }
+
+        /// <summary>
+        /// Identifies the SelectedCount bindable property
+        /// </summary>
+        public static readonly BindableProperty SelectedCountProperty = BindableProperty.Create("SelectedCount", typeof(int), typeof(MusicTab), 0);
+
+        /// <summary>
+        /// Gets or sets count of selected item
+        /// </summary>
+        public int SelectedCount
+        {
+            get { return (int)GetValue(SelectedCountProperty); }
+            set { SetValue(SelectedCountProperty, value); }
+        }
+
+        /// <summary>
         /// Identifies the GetInformationsCommand bindable property
         /// </summary>
         public static readonly BindableProperty GetInformationsCommandProperty = BindableProperty.Create("GetInformationsCommand", typeof(ICommand), typeof(MusicTab), default(ICommand));
@@ -138,11 +236,12 @@ namespace TVMediaHub.Tizen.Views
         private void InitializeFooter()
         {
             FooterNormal.OnDropdownSourceItemSelected += OnSourceChanged;
-
             FooterNormal.OnDropdownSortItemSelected += OnSortOptionChanged;
-
             FooterNormal.OnSelectedOptionIndexChanged += OnOptionSelected;
 
+            FooterDelete.SelecteAllButtonEvent += OnSelectAllClicked;
+            FooterDelete.OKButtonEvent += OnOKClicked;
+            FooterDelete.CancelButtonEvent += OnCancelClicked;
         }
 
         /// <summary>
@@ -198,6 +297,7 @@ namespace TVMediaHub.Tizen.Views
 
                 var groupItem = e.NewItems[0];
                 groupView.BindingContext = groupItem;
+                groupView.SetClickCommand(OnClickCommand);
                 MusicContentView.Children.Add(groupView);
             }
             else if (e.Action.ToString().Equals(NotifyCollectionChangedAction.Reset.ToString()))
@@ -243,6 +343,76 @@ namespace TVMediaHub.Tizen.Views
         /// <param name="e">A SelectedItemChanged event's argument</param>
         private void OnOptionSelected(object sender, ContextPopupSelectedEventArgs e)
         {
+            var label = e.Item.Label.Trim().ToLower();
+            if (label.Equals("delete"))
+            {
+                ChangeTabStatusCommand?.Execute("");
+                FooterNormal.IsVisible = false;
+                FooterDelete.IsVisible = true;
+            }
+            else if (label.Equals("detail info"))
+            {
+                // TODO : Display the alert popup
+            }
+        }
+
+        /// <summary>
+        /// This method is called when cancel button is clicked
+        /// </summary>
+        /// <param name="sender">The source of the event</param>
+        /// <param name="e">An event's argument</param>
+        private void OnCancelClicked(object sender, EventArgs e)
+        {
+            ChangeTabStatusCommand?.Execute("");
+            FooterNormal.IsVisible = true;
+            FooterDelete.IsVisible = false;
+        }
+
+        /// <summary>
+        /// This method is called when SelectAll button is clicked
+        /// </summary>
+        /// <param name="sender">The source of the event</param>
+        /// <param name="e">An event's argument</param>
+        private void OnSelectAllClicked(object sender, EventArgs e)
+        {
+            IsSelectedAll = FooterDelete.IsSelectedAll;
+            SelectAllContentCommand?.Execute(IsSelectedAll);
+        }
+
+        /// <summary>
+        /// This method is called when OK button is clicked
+        /// </summary>
+        /// <param name="sender">The source of the event</param>
+        /// <param name="e">An event's argument</param>
+        private async void OnOKClicked(object sender, EventArgs e)
+        {
+            string title = "Delete";
+
+            if (SelectedCount < 1)
+            {
+                return;
+            }
+            else if (SelectedCount > 1)
+            {
+                title = "Delete Selected";
+
+                if (IsSelectedAll)
+                {
+                    title = "Delete All";
+                }
+            }
+
+            bool answer = await DisplayAlert(title, "Do you want to delete?", "YES", "NO");
+
+            if (answer)
+            {
+                DeleteContentCommand?.Execute(null);
+                GetInformationsCommand?.Execute("");
+            }
+
+            ChangeTabStatusCommand?.Execute("");
+            FooterNormal.IsVisible = true;
+            FooterDelete.IsVisible = false;
         }
     }
 }
old mode 100644 (file)
new mode 100755 (executable)
index 95562da..2f3e09c
@@ -5,7 +5,7 @@
                 x:Class="TVMediaHub.Tizen.Views.VideoItem"
                 xmlns:Views="clr-namespace:TVMediaHub.Tizen.Views"
                 VideoInfo="{Binding Information}"
-                IsDeleteMode="{Binding IsDeleteStatus}">
+                VideoTabStatus="{Binding CurrentTabStatus}">
     <Button x:Name ="FocusArea"
             Opacity="0"
             Clicked="OnItemClicked"
index 4c16c24..738d20d 100755 (executable)
@@ -21,6 +21,7 @@ using Tizen.Xamarin.Forms.Extension;
 using TVMediaHub.Tizen.Utils;
 using TVMediaHub.Tizen.DataModels;
 using Xamarin.Forms;
+using TVMediaHub.Tizen.ViewModels;
 
 namespace TVMediaHub.Tizen.Views
 {
@@ -117,23 +118,23 @@ namespace TVMediaHub.Tizen.Views
         public ContextPopupItemSelectedEventHandler ContextPopupItemSelectedHandler;
 
         /// <summary>
-        /// Identifies the IsDeleteMode bindable property
+        /// Identifies the VideoTabStatus bindable property
         /// </summary>
-        public static readonly BindableProperty IsDeleteModeProperty = BindableProperty.Create("IsDeleteMode", typeof(bool), typeof(VideoItem), false);
+        public static readonly BindableProperty VideoTabStatusProperty = BindableProperty.Create("VideoTabStatus", typeof(TabStatus), typeof(VideoItem), TabStatus.Default);
 
         /// <summary>
-        /// Gets or sets the value whether item is delete mode or not
+        /// Gets or sets VideoTabStatus
         /// </summary>
-        public bool IsDeleteMode
+        public TabStatus VideoTabStatus
         {
             set
             {
-                SetValue(IsDeleteModeProperty, value);
+                SetValue(VideoTabStatusProperty, value);
             }
 
             get
             {
-                return (bool)GetValue(IsDeleteModeProperty);
+                return (TabStatus)GetValue(VideoTabStatusProperty);
             }
         }
 
@@ -315,7 +316,7 @@ namespace TVMediaHub.Tizen.Views
                 PlayImage.FadeTo(0.0, 167);
             }
 
-            if (IsDeleteMode)
+            if (VideoTabStatus == TabStatus.Delete)
             {
                 CheckDimImage.LayoutTo(NormalBounds, 167, easing);
                 CheckImage.LayoutTo(NormalBounds, 167, easing);
@@ -363,7 +364,7 @@ namespace TVMediaHub.Tizen.Views
                             PlayImage.FadeTo(0.99, 167);
                         }
 
-                        if (IsDeleteMode)
+                        if (VideoTabStatus == TabStatus.Delete)
                         {
                             CheckDimImage.LayoutTo(FocusedBounds, 167, easing);
                             CheckImage.LayoutTo(FocusedBounds, 167, easing);
@@ -400,7 +401,8 @@ namespace TVMediaHub.Tizen.Views
             CheckImage.LayoutTo(FocusedBounds, 167);
             ImageArea.LayoutTo(FocusedBounds, 167);
             OnItemClickedHandler?.Invoke(VideoInfo);
-            if (IsDeleteMode)
+
+            if (VideoTabStatus == TabStatus.Delete)
             {
                 if (CurStatus == ItemStatus.Normal)
                 {
@@ -470,9 +472,9 @@ namespace TVMediaHub.Tizen.Views
         /// <param name="e">A propertyChanged event argument</param>
         private void VideoItemPropertyChanged(object sender, PropertyChangedEventArgs e)
         {
-            if (e.PropertyName.CompareTo("IsDeleteMode") == 0)
+            if (e.PropertyName.CompareTo("VideoTabStatus") == 0)
             {
-                if (!IsDeleteMode)
+                if (VideoTabStatus == TabStatus.Default)
                 {
                     CurStatus = ItemStatus.Normal;
                     UpdateView();
index b408c9b..b9554a0 100755 (executable)
@@ -7,7 +7,7 @@
              xmlns:ViewModels="clr-namespace:TVMediaHub.Tizen.ViewModels"
              Title="Movie"
              ItemsSource="{Binding VideoList}"
-             IsDeleteStatus="{Binding IsDeleteStatus}"
+             VideoTabStatus="{Binding VideoTabStatus}"
              ChangeTabStatusCommand="{Binding ChangeTabStatusCommand}"
              ChangeSortOptionCommand="{Binding ChangeSortOptionCommand}"
              ChangeSourceCommand="{Binding ChangeSourceCommand}"
index 9f27157..68df208 100755 (executable)
@@ -75,17 +75,17 @@ namespace TVMediaHub.Tizen.Views
         }
 
         /// <summary>
-        /// Identifies the IsDeleteStatus bindable property
+        /// Identifies the VideoTabStatus bindable property
         /// </summary>
-        public static readonly BindableProperty IsDeleteStatusProperty = BindableProperty.Create("IsDeleteStatus", typeof(bool), typeof(VideoTab), false);
+        public static readonly BindableProperty VideoTabStatusProperty = BindableProperty.Create("VideoTabStatus", typeof(TabStatus), typeof(VideoTab), TabStatus.Default);
 
         /// <summary>
-        /// Gets or sets IsDeleteStatus
+        /// Gets or sets VideoTabStatus
         /// </summary>
-        public bool IsDeleteStatus
+        public TabStatus VideoTabStatus
         {
-            get { return (bool)GetValue(IsDeleteStatusProperty); }
-            set { SetValue(IsDeleteStatusProperty, value); }
+            get { return (TabStatus)GetValue(VideoTabStatusProperty); }
+            set { SetValue(VideoTabStatusProperty, value); }
         }
 
         /// <summary>
@@ -310,7 +310,7 @@ namespace TVMediaHub.Tizen.Views
             ItemsSource.Clear();
             VideoTabList.Children.Clear();
             BottomButtonList.Clear();
-            if (IsDeleteStatus)
+            if (VideoTabStatus == TabStatus.Delete)
             {
                 ChangeTabStatusCommand?.Execute("");
                 FooterNormal.IsVisible = true;
@@ -427,7 +427,7 @@ namespace TVMediaHub.Tizen.Views
                 var btn = list[buttonIndex].Value;
                 if (buttonIndex == 0)
                 {
-                    if (IsDeleteStatus)
+                    if (VideoTabStatus == TabStatus.Delete)
                     {
                         btn.On<Xamarin.Forms.PlatformConfiguration.Tizen>().SetNextFocusDownView(FooterDelete.GetSelectAllButton());
                         // TODO : FooterDelete.GetSelectAllButton().DropdownSource.ButtonOption.On<Xamarin.Forms.PlatformConfiguration.Tizen>().SetNextFocusUpView(btn);
@@ -440,7 +440,7 @@ namespace TVMediaHub.Tizen.Views
                 }
                 else if (buttonIndex == list.Count - 1)
                 {
-                    if (IsDeleteStatus)
+                    if (VideoTabStatus == TabStatus.Delete)
                     {
                         btn.On<Xamarin.Forms.PlatformConfiguration.Tizen>().SetNextFocusDownView(FooterDelete.GetCancelButton());
                         FooterDelete.GetCancelButton().On<Xamarin.Forms.PlatformConfiguration.Tizen>().SetNextFocusUpView(btn);
@@ -454,7 +454,7 @@ namespace TVMediaHub.Tizen.Views
                 }
                 else
                 {
-                    if (IsDeleteStatus)
+                    if (VideoTabStatus == TabStatus.Delete)
                     {
                         btn.On<Xamarin.Forms.PlatformConfiguration.Tizen>().SetNextFocusDownView(FooterDelete.GetOkButton());
                         // TODO :FooterDelete.GetCancelAllButton().ButtonOption.On<Xamarin.Forms.PlatformConfiguration.Tizen>().SetNextFocusUpView(btn);