Implements the StorageProvider and gets the contents according to sources
authorHyerim Kim <rimi.kim@samsung.com>
Mon, 5 Jun 2017 07:44:04 +0000 (16:44 +0900)
committerHyerim Kim <rimi.kim@samsung.com>
Mon, 5 Jun 2017 07:44:04 +0000 (16:44 +0900)
Change-Id: I6f13dbde0eb256dd7c3befb03cb77b70e1be0548
Signed-off-by: Hyerim Kim <rimi.kim@samsung.com>
14 files changed:
TVMediaHub/TVMediaHub.Tizen/Models/ContentProvider.cs
TVMediaHub/TVMediaHub.Tizen/Models/ImageProvider.cs
TVMediaHub/TVMediaHub.Tizen/Models/MediaHubImpl.cs
TVMediaHub/TVMediaHub.Tizen/Models/MusicProvider.cs
TVMediaHub/TVMediaHub.Tizen/Models/StorageProvider.cs
TVMediaHub/TVMediaHub.Tizen/Models/VideoProvider.cs
TVMediaHub/TVMediaHub.Tizen/ViewModels/ImageTabViewModel.cs
TVMediaHub/TVMediaHub.Tizen/ViewModels/VideoTabViewModel.cs
TVMediaHub/TVMediaHub.Tizen/Views/ImageGroup.xaml.cs
TVMediaHub/TVMediaHub.Tizen/Views/ImageTab.xaml
TVMediaHub/TVMediaHub.Tizen/Views/ImageTab.xaml.cs
TVMediaHub/TVMediaHub.Tizen/Views/VideoGroup.xaml.cs
TVMediaHub/TVMediaHub.Tizen/Views/VideoTab.xaml
TVMediaHub/TVMediaHub.Tizen/Views/VideoTab.xaml.cs

index 57b2aa9..c15c604 100755 (executable)
@@ -54,7 +54,16 @@ namespace TVMediaHub.Tizen.Models
         /// </summary>
         abstract protected void CheckUnavailableContent(MediaInformationEx mediaContent);
 
-        abstract public void SetContentUpdatedEventListener(EventHandler<ContentUpdatedEventArgs> listener);
+        /// <summary>
+        /// A method for handling ContentUpdatedEvent
+        /// </summary>
+        /// <param name="listener">A handling method</param>
+        abstract public void SetContentUpdatedEventListener(EventHandler listener);
+
+        /// <summary>
+        /// An EventHandler be sent to Image, Video and MusicProvider when ContentUpdated event is triggered
+        /// </summary>
+        public EventHandler ContentUpdateFinished;
 
         /// <summary>
         /// A constructor
@@ -65,6 +74,7 @@ namespace TVMediaHub.Tizen.Models
             try
             {
                 ContentDatabase.Connect();
+                ContentDatabase.ContentUpdated += ContentDatabaseContentUpdated;
             }
             catch (Exception e)
             {
@@ -74,6 +84,20 @@ namespace TVMediaHub.Tizen.Models
         }
 
         /// <summary>
+        /// Handles ContentUpdated event that is triggered when db is changed.
+        /// </summary>
+        /// <param name="sender">The source of the event</param>
+        /// <param name="e">A ContentUpdatedEvent arguments</param>
+        private void ContentDatabaseContentUpdated(object sender, ContentUpdatedEventArgs e)
+        {
+            if (e.UpdateType == MediaContentDBUpdateType.Update)
+            {
+                MediaHubImpl.GetInstance.StorageProviderInstance.CheckStorage();
+                ContentUpdateFinished?.Invoke(this, null);
+            }
+        }
+
+        /// <summary>
         /// Converts the value of the DateTime object to its equivalent string representation.
         /// </summary>
         /// <param name="date">A DateTime information</param>
index e7d297d..63f1f5f 100755 (executable)
@@ -60,9 +60,9 @@ namespace TVMediaHub.Tizen.Models
             }
         }
 
-        public override void SetContentUpdatedEventListener(EventHandler<ContentUpdatedEventArgs> listener)
+        public override void SetContentUpdatedEventListener(EventHandler listener)
         {
-            ContentDatabase.ContentUpdated += listener;
+            base.ContentUpdateFinished += listener;
         }
     }
 }
index bb53dfa..4e89dcc 100755 (executable)
@@ -83,6 +83,21 @@ namespace TVMediaHub.Tizen.Models
         }
 
         /// <summary>
+        /// An instance of the StorageProvider
+        /// </summary>
+        private static readonly StorageProvider storageProviderInstance = new StorageProvider();
+        /// <summary>
+        /// Gets an instance of the StorageProvider
+        /// </summary>
+        public StorageProvider StorageProviderInstance
+        {
+            get
+            {
+                return storageProviderInstance;
+            }
+        }
+
+        /// <summary>
         /// A constructor
         /// </summary>
         public MediaHubImpl()
index 9eeabac..d874120 100755 (executable)
@@ -54,9 +54,9 @@ namespace TVMediaHub.Tizen.Models
             }
         }
 
-        public override void SetContentUpdatedEventListener(EventHandler<ContentUpdatedEventArgs> listener)
+        public override void SetContentUpdatedEventListener(EventHandler listener)
         {
-            ContentDatabase.ContentUpdated += listener;
+            base.ContentUpdateFinished += listener;
         }
     }
 }
index 0ed2e48..39a80d1 100755 (executable)
@@ -25,22 +25,37 @@ namespace TVMediaHub.Tizen.Models
     public class StorageProvider
     {
         /// <summary>
+        /// A list of external storage
+        /// </summary>
+        private IEnumerable<Storage> storageList = new List<Storage>();
+
+        /// <summary>
+        /// A list of storage id
+        /// </summary>
+        public List<string> StorageId { get; protected set; }
+
+        /// <summary>
         /// A constructor
         /// </summary>
         public StorageProvider()
         {
-            /// Connect to the media database to search, insert, remove or modify media information.
-            ContentDatabase.Connect();
+            StorageId = new List<string>();
+            CheckStorage();
         }
 
         /// <summary>
-        /// Returns the ContentCollections with optional filter from the media database.
+        /// Returns the list of the storage id of the media storage.
         /// </summary>
         /// <returns>Task with the list of the ContentCollection</returns>
-        public IEnumerable<Storage> Read()
+        public void CheckStorage()
         {
-            return ContentManager.Database.SelectAll<Storage>(null);
-        }
+            StorageId.Clear();
+            storageList = ContentManager.Database.SelectAll<Storage>(null);
 
+            foreach (var item in storageList)
+            {
+                StorageId.Add(item.Id);
+            }
+        }
     }
 }
index 47f38d5..7417734 100755 (executable)
@@ -100,9 +100,9 @@ namespace TVMediaHub.Tizen.Models
             ContentManager.Database.Update(videoContent.MediaContentInformation);
         }
 
-        public override void SetContentUpdatedEventListener(EventHandler<ContentUpdatedEventArgs> listener)
+        public override void SetContentUpdatedEventListener(EventHandler listener)
         {
-            ContentDatabase.ContentUpdated += listener;
+            base.ContentUpdateFinished += listener;
         }
     }
 }
\ No newline at end of file
index 0544c11..b36e2e5 100755 (executable)
@@ -20,7 +20,6 @@ using System.Runtime.CompilerServices;
 using System.Windows.Input;
 using Xamarin.Forms;
 using System.Linq;
-using Tizen.Content.MediaContent;
 using TVMediaHub.Tizen.Models;
 using TVMediaHub.Tizen.DataModels;
 using System.Threading.Tasks;
@@ -43,10 +42,18 @@ namespace TVMediaHub.Tizen.ViewModels
         public ObservableCollection<GroupItem> ImageList { get; set; }
 
         /// <summary>
+        /// A dictionary list of the source and storage id
+        /// </summary>
+        private Dictionary<string, string> sourcePairList;
+
+        /// <summary>
         /// An index of displaying image
         /// </summary>
         private int displayingImageIndex;
 
+        /// <summary>
+        /// A sort option
+        /// </summary>
         private SortOption option = SortOption.Date;
 
         /// <summary>
@@ -130,6 +137,11 @@ namespace TVMediaHub.Tizen.ViewModels
         public ICommand ChangeSortOptionCommand { get; set; }
 
         /// <summary>
+        /// A command for changing Source
+        /// </summary>
+        public ICommand ChangeSourceCommand { get; set; }
+
+        /// <summary>
         /// A command for deleting a image content
         /// </summary>
         public ICommand DeleteContentCommand { get; set; }
@@ -139,7 +151,6 @@ namespace TVMediaHub.Tizen.ViewModels
         /// </summary>
         public ICommand SelectAllContentCommand { get; set; }
 
-        private int SortBy;
         /// <summary>
         /// A flag that whether the content is delete mode or not
         /// </summary>
@@ -166,6 +177,31 @@ namespace TVMediaHub.Tizen.ViewModels
         }
 
         /// <summary>
+        /// A flag that whether the BottomButtonList of Tab is needed to delete or not
+        /// </summary>
+        private bool isNeededClearList;
+
+        /// <summary>
+        /// Gets or sets the isNeededClearList
+        /// </summary>
+        public bool IsNeededClearList
+        {
+            get
+            {
+                return isNeededClearList;
+            }
+
+            set
+            {
+                if (isNeededClearList != value)
+                {
+                    isNeededClearList = value;
+                    OnPropertyChanged("IsNeededClearList");
+                }
+            }
+        }
+
+        /// <summary>
         /// A command for executing when CurrentImageInfo is changed
         /// </summary>
         public ICommand SetCurrentImageInfo
@@ -257,22 +293,16 @@ namespace TVMediaHub.Tizen.ViewModels
         /// </summary>
         public ImageTabViewModel()
         {
+            ImageList = new ObservableCollection<GroupItem>();
+            SelectedList = new List<MediaInformationEx>();
+            sourcePairList = new Dictionary<string, string>();
             InitializeFooterItemsSource();
             InitializeCommands();
             CreateImageInfoList();
-
-            ImageList = new ObservableCollection<GroupItem>();
-            SelectedList = new List<MediaInformationEx>();
             OnPropertyChanged("ImageList");
             MediaHubImpl.GetInstance.ImageProviderInstance.SetContentUpdatedEventListener((sender, arg) =>
             {
-                DbgPort.D("Content updated");
-                /*
-                if (arg.UpdateType.Equals(MediaContentDBUpdateType.Update))
-                {
-                    GetInformationsCommand?.Execute("");
-                }
-                */
+                AddSourceListItem();
             });
         }
 
@@ -347,6 +377,21 @@ namespace TVMediaHub.Tizen.ViewModels
                 }
             });
 
+            ChangeSourceCommand = new Command<string>((name) =>
+            {
+                if (name == null)
+                {
+                    DbgPort.D("name is null");
+                    return;
+                }
+
+                string id = sourcePairList[name];
+                SynchronizationContext.Current.Post((o) =>
+                {
+                    ReadImageList(option, id);
+                }, "");
+            });
+
             SelectAllContentCommand = new Command<bool>((IsSelectedAll) =>
             {
                 if (IsSelectedAll)
@@ -442,24 +487,32 @@ namespace TVMediaHub.Tizen.ViewModels
             OnPropertyChanged("ChangeSortOptionCommand");
         }
 
-        private void GetImageData(int source, int sortby)
+        /// <summary>
+        /// A method for making the source list
+        /// </summary>
+        private void AddSourceListItem()
         {
+            int index = 1;
+            sourcePairList.Clear();
+            List<string> tempList = new List<string>();
 
-        }
+            sourcePairList.Add("ALL SOURCE", null);
+            sourcePairList.Add("DEVICE", "media");
 
-        private void OnSourceChanged(int source)
-        {
+            tempList.Add("ALL SOURCE");
+            tempList.Add("DEVICE");
 
-        }
-
-        void OnSortbyChanged(int sortby)
-        {
-            if (SortBy != sortby)
+            foreach (var item in MediaHubImpl.GetInstance.StorageProviderInstance.StorageId)
             {
-                SortBy = sortby;
+                sourcePairList.Add("USB " + index, item);
+                tempList.Add("USB " + index);
+                index++;
             }
-        }
 
+            SourceList = tempList;
+
+            OnPropertyChanged("SourceList");
+        }
 
         /// <summary>
         /// Finds specific Image in list and sets the DisplayingImageIndex
@@ -508,20 +561,25 @@ namespace TVMediaHub.Tizen.ViewModels
         /// A method for reading image contents through ImageProvider and updating ImageList
         /// </summary>
         /// <param name="option">A current sort option</param>
-        private async void ReadImageList(SortOption option)
+        private async void ReadImageList(SortOption option, string storageId = null)
         {
             ImageList.Clear();
-            IEnumerable<GroupItem> tempList = await MediaHubImpl.GetInstance.ImageProviderInstance.ReadAsync(option);
+            IEnumerable<GroupItem> tempList = await MediaHubImpl.GetInstance.ImageProviderInstance.ReadAsync(option, storageId);
             foreach (var group in tempList)
             {
                 await MediaHubImpl.GetInstance.ImageProviderInstance.CheckThumbnail(group.Contents);
             }
+
+            IsNeededClearList = true;
+
             foreach (var group in tempList)
             {
                 // TODO : remove delay
                 await Task.Delay(1);
                 ImageList.Add(group);
             }
+
+            IsNeededClearList = false;
         }
 
         /// <summary>
@@ -545,14 +603,9 @@ namespace TVMediaHub.Tizen.ViewModels
         /// </summary>
         private void InitializeFooterItemsSource()
         {
-            var list = new List<string>
-            {
-                "ALL SOURCE",
-            };
-            SourceList = list;
-            OnPropertyChanged("SourceList");
+            AddSourceListItem();
 
-            list = new List<string>
+            var list = new List<string>
             {
                 "EVENT",
                 "FILE FORMAT",
index a9027f7..749edca 100755 (executable)
@@ -21,7 +21,6 @@ using System.ComponentModel;
 using System.IO;
 using System.Threading;
 using System.Windows.Input;
-using Tizen.Content.MediaContent;
 using TVMediaHub.Tizen.Models;
 using TVMediaHub.Tizen.Utils;
 using TVMediaHub.Tizen.DataModels;
@@ -39,6 +38,8 @@ namespace TVMediaHub.Tizen.ViewModels
         /// </summary>
         public event PropertyChangedEventHandler PropertyChanged;
 
+        private Dictionary<string, string> sourcePairList;
+
         /// <summary>
         /// A method for invoking PropertyChanged event
         /// </summary>
@@ -86,6 +87,11 @@ namespace TVMediaHub.Tizen.ViewModels
         public ICommand ChangeSortOptionCommand { get; set; }
 
         /// <summary>
+        /// A command for changing Source
+        /// </summary>
+        public ICommand ChangeSourceCommand { get; set; }
+
+        /// <summary>
         /// A command for getting the list of video contents
         /// </summary>
         public ICommand GetInformationsCommand { get; set; }
@@ -119,8 +125,14 @@ namespace TVMediaHub.Tizen.ViewModels
             get;
         }
 
+        /// <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;
 
         /// <summary>
@@ -158,6 +170,31 @@ namespace TVMediaHub.Tizen.ViewModels
         }
 
         /// <summary>
+        /// A flag that whether the BottomButtonList of Tab is needed to delete or not
+        /// </summary>
+        private bool isNeededClearList;
+
+        /// <summary>
+        /// Gets or sets the isNeededClearList
+        /// </summary>
+        public bool IsNeededClearList
+        {
+            get
+            {
+                return isNeededClearList;
+            }
+
+            set
+            {
+                if (isNeededClearList != value)
+                {
+                    isNeededClearList = value;
+                    OnPropertyChanged("IsNeededClearList");
+                }
+            }
+        }
+
+        /// <summary>
         /// A list of video contents to be displayed
         /// </summary>
         public List<MediaInformationEx> SelectedList { get; set; }
@@ -179,22 +216,16 @@ namespace TVMediaHub.Tizen.ViewModels
         public VideoTabViewModel()
         {
             DbgPort.D("Binding Context cotr " + DateTime.Now);
-            InitializeFooterItemsSource();
-            InitializeCommands();
             VideoList = new ObservableCollection<GroupItem>();
             SelectedList = new List<MediaInformationEx>();
             PlayList = new List<MediaInformationEx>();
-
+            sourcePairList = new Dictionary<string, string>();
+            InitializeFooterItemsSource();
+            InitializeCommands();
             OnPropertyChanged("VideoList");
             MediaHubImpl.GetInstance.VideoProviderInstance.SetContentUpdatedEventListener((sender, arg) =>
             {
-                DbgPort.D("Content updated");
-                /*
-                if (arg.UpdateType.Equals(MediaContentDBUpdateType.Update))
-                {
-                    GetInformationsCommand?.Execute("");
-                }
-                */
+                AddSourceListItem();
             });
         }
 
@@ -266,7 +297,20 @@ namespace TVMediaHub.Tizen.ViewModels
                     ReadVideoList(option);
                 }, "");
             });
+            ChangeSourceCommand = new Command<string>((name) =>
+            {
+                if (name == null)
+                {
+                    DbgPort.D("name is null");
+                    return;
+                }
 
+                string id = sourcePairList[name];
+                SynchronizationContext.Current.Post((o) =>
+                {
+                    ReadVideoList(option, id);
+                }, "");
+            });
             SetCurrentVideoInfo = new Command<MediaInformationEx>((info) =>
             {
                 if (IsDeleteStatus)
@@ -332,14 +376,9 @@ namespace TVMediaHub.Tizen.ViewModels
         /// </summary>
         private void InitializeFooterItemsSource()
         {
-            var list = new List<string>
-            {
-                "ALL SOURCE",
-            };
-            SourceList = list;
-            OnPropertyChanged("SourceList");
+            AddSourceListItem();
 
-            list = new List<string>
+            var list = new List<string>
             {
                 "NAME",
                 "GENRE",
@@ -357,6 +396,33 @@ namespace TVMediaHub.Tizen.ViewModels
             OnPropertyChanged("OptionList");
         }
 
+        /// <summary>
+        /// A method for making the source list
+        /// </summary>
+        private void AddSourceListItem()
+        {
+            int index = 1;
+            sourcePairList.Clear();
+            List<string> tempList = new List<string>();
+
+            sourcePairList.Add("ALL SOURCE", null);
+            sourcePairList.Add("DEVICE", "media");
+
+            tempList.Add("ALL SOURCE");
+            tempList.Add("DEVICE");
+
+            foreach (var item in MediaHubImpl.GetInstance.StorageProviderInstance.StorageId)
+            {
+                sourcePairList.Add("USB " + index, item);
+                tempList.Add("USB " + index);
+                index++;
+            }
+
+            SourceList = tempList;
+
+            OnPropertyChanged("SourceList");
+        }
+
         private void ReadRecentlyWatchedContent()
         {
             // TODO : Read from VideoProvider
@@ -368,21 +434,26 @@ namespace TVMediaHub.Tizen.ViewModels
         /// A method for reading video contents through VideoProvider and updating VideoList
         /// </summary>
         /// <param name="option">A current sort option</param>
-        private async void ReadVideoList(SortOption option)
+        private async void ReadVideoList(SortOption option, string storageId = null)
         {
             VideoList.Clear();
-            IEnumerable<GroupItem> tempList = await MediaHubImpl.GetInstance.VideoProviderInstance.ReadAsync(option);
+
+            IEnumerable<GroupItem> tempList = await MediaHubImpl.GetInstance.VideoProviderInstance.ReadAsync(option, storageId);
             foreach (var group in tempList)
             {
                 await MediaHubImpl.GetInstance.VideoProviderInstance.CheckThumbnail(group.Contents);
             }
 
+            IsNeededClearList = true;
+
             foreach (var group in tempList)
             {
                 //await Task.Delay(1);
                 VideoList.Add(group);
             }
 
+            IsNeededClearList = false;
+
             foreach (var group in VideoList)
             {
                 foreach (var item in group.Contents)
index 3ecce46..4a5fe66 100755 (executable)
@@ -200,7 +200,7 @@ namespace TVMediaHub.Tizen.Views
                     };
                     view.OnUnfocusedEventHandler += (se, ev) =>
                     {
-                        if (focusedItem.Equals(view as ImageItem))
+                        if (focusedItem != null && focusedItem.Equals(view as ImageItem))
                         {
                             focusedItem = null;
                         }
index 142ebd2..b87e6d7 100755 (executable)
@@ -9,11 +9,13 @@
              IsDeleteStatus="{Binding IsDeleteStatus}"
              GetInformationsCommand="{Binding GetInformationsCommand}"
              ChangeSortOptionCommand="{Binding ChangeSortOptionCommand}"
+             ChangeSourceCommand="{Binding ChangeSourceCommand}"
              DeleteModeChangeCommand="{Binding DeleteModeChangeCommand}"
              OnClickCommand="{Binding SetCurrentImageInfo}"
              DeleteContentCommand="{Binding DeleteContentCommand}"
              SelectAllContentCommand="{Binding SelectAllContentCommand}"
              SelectedCount="{Binding SelectedCount}"
+             IsNeededClearList="{Binding IsNeededClearList}"
              Title="Gallery">
     <RelativeLayout
         RelativeLayout.HeightConstraint="{ConstraintExpression Type=RelativeToParent, Property=Height, Factor=1}"
index 07a61ac..00c50de 100755 (executable)
@@ -19,7 +19,6 @@ using System.Collections.Generic;
 using System.Collections.ObjectModel;
 using System.Threading;
 using System.Windows.Input;
-using Tizen.Content.MediaContent;
 using Tizen.Xamarin.Forms.Extension;
 using TVMediaHub.Tizen.Controls;
 using TVMediaHub.Tizen.DataModels;
@@ -76,6 +75,20 @@ namespace TVMediaHub.Tizen.Views
         }
 
         /// <summary>
+        /// Identifies the ChangeSourceCommand bindable property
+        /// </summary>
+        public static readonly BindableProperty ChangeSourceCommandProperty = BindableProperty.Create("ChangeSourceCommand", typeof(ICommand), typeof(ImageTab), default(ICommand));
+
+        /// <summary>
+        /// Gets or sets ChangeSourceCommand Command
+        /// </summary>
+        public ICommand ChangeSourceCommand
+        {
+            get { return (ICommand)GetValue(ChangeSourceCommandProperty); }
+            set { SetValue(ChangeSourceCommandProperty, value); }
+        }
+
+        /// <summary>
         /// Identifies the DeleteModeChangeCommand bindable property
         /// </summary>
         public static readonly BindableProperty DeleteModeChangeCommandProperty = BindableProperty.Create("DeleteModeChangeCommand", typeof(ICommand), typeof(ImageTab), default(ICommand));
@@ -174,6 +187,20 @@ namespace TVMediaHub.Tizen.Views
         }
 
         /// <summary>
+        /// Identifies the IsNeededClearList bindable property
+        /// </summary>
+        public static readonly BindableProperty IsNeededClearListProperty = BindableProperty.Create("IsNeededClearList", typeof(bool), typeof(ImageTab), false);
+
+        /// <summary>
+        /// Gets or sets IsNeededClearList
+        /// </summary>
+        public bool IsNeededClearList
+        {
+            get { return (bool)GetValue(IsNeededClearListProperty); }
+            set { SetValue(IsNeededClearListProperty, value); }
+        }
+
+        /// <summary>
         /// A list of bottom buttons
         /// </summary>
         private List<KeyValuePair<double, Button>> BottomButtonList;
@@ -207,7 +234,7 @@ namespace TVMediaHub.Tizen.Views
             InitializeFonts();
             InitializeFooter();
             ItemsSource.CollectionChanged += ItemsSourceCollectionChanged;
-
+            PropertyChanged += ImageTabPropertyChanged;
 
             SynchronizationContext.Current.Post((o) =>
             {
@@ -216,6 +243,22 @@ namespace TVMediaHub.Tizen.Views
         }
 
         /// <summary>
+        /// This method is called when the properties is changed
+        /// </summary>
+        /// <param name="sender">The source of the event</param>
+        /// <param name="e">A propertyChanged event argument</param>
+        private void ImageTabPropertyChanged(object sender, System.ComponentModel.PropertyChangedEventArgs e)
+        {
+            if (e.PropertyName.Equals("IsNeededClearList"))
+            {
+                if (IsNeededClearList)
+                {
+                    BottomButtonList.Clear();
+                }
+            }
+        }
+
+        /// <summary>
         /// A method for initializing list
         /// </summary>
         private void InitializeData()
@@ -252,11 +295,8 @@ namespace TVMediaHub.Tizen.Views
         /// </summary>
         private void InitializeFooter()
         {
-
             FooterNormal.OnDropdownSourceItemSelected += OnSourceChanged;
-
             FooterNormal.OnDropdownSortItemSelected += OnSortOptionChanged;
-
             FooterNormal.OnSelectedOptionIndexChanged += OnOptionSelected;
 
             FooterDelete.SelecteAllButtonEvent += OnSelectAllClicked;
@@ -546,6 +586,11 @@ namespace TVMediaHub.Tizen.Views
         /// <param name="e">A SelectedItemChanged event's argument</param>
         private void OnSourceChanged(object sender, SelectedItemChangedEventArgs e)
         {
+            String storageName = e.SelectedItem as String;
+
+            BottomButtonList.Clear();
+            ChangeSourceCommand?.Execute(storageName);
+            SetFooterFocusChain(ImageTabScrollView.ScrollX);
         }
 
         /// <summary>
@@ -555,7 +600,9 @@ namespace TVMediaHub.Tizen.Views
         /// <param name="e">A SelectedItemChanged event's argument</param>
         private void OnSortOptionChanged(object sender, SelectedItemChangedEventArgs e)
         {
+            BottomButtonList.Clear();
             ChangeSortOptionCommand?.Execute(e.SelectedItem);
+            SetFooterFocusChain(ImageTabScrollView.ScrollX);
         }
 
         /// <summary>
index b2b52aa..444ff48 100755 (executable)
@@ -254,7 +254,7 @@ namespace TVMediaHub.Tizen.Views
                     };
                     view.OnUnfocusedEventHandler += (se, ev) =>
                     {
-                        if(focusedItem.Equals(view as VideoItem))
+                        if (focusedItem != null && focusedItem.Equals(view as VideoItem))
                         {
                             focusedItem = null;
                         }
index 45412d9..b408c9b 100755 (executable)
              IsDeleteStatus="{Binding IsDeleteStatus}"
              ChangeTabStatusCommand="{Binding ChangeTabStatusCommand}"
              ChangeSortOptionCommand="{Binding ChangeSortOptionCommand}"
+             ChangeSourceCommand="{Binding ChangeSourceCommand}"
              GetInformationsCommand="{Binding GetInformationsCommand}"
              OnClickCommand="{Binding SetCurrentVideoInfo}"
              DeleteContentCommand="{Binding DeleteContentCommand}"
              SelectAllContentCommand="{Binding SelectAllContentCommand}"
-             SelectedCount="{Binding SelectedCount}">
+             SelectedCount="{Binding SelectedCount}"
+             IsNeededClearList="{Binding IsNeededClearList}">
     <RelativeLayout
         RelativeLayout.HeightConstraint="{ConstraintExpression Type=RelativeToParent, Property=Height, Factor=1}"
         RelativeLayout.WidthConstraint="{ConstraintExpression Type=RelativeToParent, Property=Width, Factor=1}">
index 6cf97ce..868e5e6 100755 (executable)
@@ -91,6 +91,20 @@ namespace TVMediaHub.Tizen.Views
         }
 
         /// <summary>
+        /// Identifies the IsNeededClearList bindable property
+        /// </summary>
+        public static readonly BindableProperty IsNeededClearListProperty = BindableProperty.Create("IsNeededClearList", typeof(bool), typeof(ImageTab), false);
+
+        /// <summary>
+        /// Gets or sets IsNeededClearList
+        /// </summary>
+        public bool IsNeededClearList
+        {
+            get { return (bool)GetValue(IsNeededClearListProperty); }
+            set { SetValue(IsNeededClearListProperty, value); }
+        }
+
+        /// <summary>
         /// Identifies the ChangeTabStatusCommand bindable property
         /// </summary>
         public static readonly BindableProperty ChangeTabStatusCommandProperty = BindableProperty.Create("ChangeTabStatusCommand", typeof(ICommand), typeof(VideoTab), default(ICommand));
@@ -110,7 +124,7 @@ namespace TVMediaHub.Tizen.Views
         public static readonly BindableProperty ChangeSortOptionCommandProperty = BindableProperty.Create("ChangeSortOptionCommand", typeof(ICommand), typeof(VideoTab), default(ICommand));
 
         /// <summary>
-        /// Gets or sets ChangeTabStatus Command
+        /// Gets or sets ChangeSortOption Command
         /// </summary>
         public ICommand ChangeSortOptionCommand
         {
@@ -119,6 +133,20 @@ namespace TVMediaHub.Tizen.Views
         }
 
         /// <summary>
+        /// Identifies the ChangeSourceCommand bindable property
+        /// </summary>
+        public static readonly BindableProperty ChangeSourceCommandProperty = BindableProperty.Create("ChangeSourceCommand", typeof(ICommand), typeof(VideoTab), default(ICommand));
+
+        /// <summary>
+        /// Gets or sets ChangeSourceCommand Command
+        /// </summary>
+        public ICommand ChangeSourceCommand
+        {
+            get { return (ICommand)GetValue(ChangeSourceCommandProperty); }
+            set { SetValue(ChangeSourceCommandProperty, value); }
+        }
+
+        /// <summary>
         /// Identifies the DeleteContentCommand bindable property
         /// </summary>
         public static readonly BindableProperty DeleteContentCommandProperty = BindableProperty.Create("DeleteContentCommand", typeof(ICommand), typeof(VideoTab), default(ICommand));
@@ -198,6 +226,23 @@ namespace TVMediaHub.Tizen.Views
             InitializeFonts();
             InitializeFooter();
             ItemsSource.CollectionChanged += ItemsSourceCollectionChanged;
+            PropertyChanged += VideoTabPropertyChanged;
+        }
+
+        /// <summary>
+        /// This method is called when the properties is changed
+        /// </summary>
+        /// <param name="sender">The source of the event</param>
+        /// <param name="e">A propertyChanged event argument</param>
+        private void VideoTabPropertyChanged(object sender, System.ComponentModel.PropertyChangedEventArgs e)
+        {
+            if (e.PropertyName.Equals("IsNeededClearList"))
+            {
+                if (IsNeededClearList)
+                {
+                    BottomButtonList.Clear();
+                }
+            }
         }
 
         /// <summary>
@@ -238,9 +283,7 @@ namespace TVMediaHub.Tizen.Views
         private void InitializeFooter()
         {
             FooterNormal.OnDropdownSourceItemSelected += OnSourceChanged;
-
             FooterNormal.OnDropdownSortItemSelected += OnSortOptionChanged;
-
             FooterNormal.OnSelectedOptionIndexChanged += OnOptionSelected;
 
             FooterDelete.SelecteAllButtonEvent += OnSelectAllClicked;
@@ -355,7 +398,6 @@ namespace TVMediaHub.Tizen.Views
             }
             else if (e.Action.ToString().Equals("Reset"))
             {
-                BottomButtonList.Clear();
                 VideoTabList.Children.Clear();
                 VideoGroupList.Clear();
                 if (!VideoNoContents.IsVisible)
@@ -537,7 +579,10 @@ namespace TVMediaHub.Tizen.Views
         /// <param name="e">A SelectedItemChanged event's argument</param>
         private void OnSourceChanged(object sender, SelectedItemChangedEventArgs e)
         {
-            // TODO : Source Change
+            String storageName = e.SelectedItem as String;
+
+            ChangeSourceCommand?.Execute(storageName);
+            SetFooterFocusChain(VideoTabScrollView.ScrollX);
         }
 
         /// <summary>
@@ -548,6 +593,7 @@ namespace TVMediaHub.Tizen.Views
         private void OnSortOptionChanged(object sender, SelectedItemChangedEventArgs e)
         {
             ChangeSortOptionCommand?.Execute(e.SelectedItem);
+            SetFooterFocusChain(VideoTabScrollView.ScrollX);
         }
 
         /// <summary>