Change ReadList Asynchronous
authorHeonjae Jang <heonjae.jang@samsung.com>
Fri, 14 Apr 2017 11:01:54 +0000 (20:01 +0900)
committerHeonjae Jang <heonjae.jang@samsung.com>
Fri, 14 Apr 2017 12:00:22 +0000 (21:00 +0900)
Change-Id: I65893ce5e78e7e3d720566ef3d377e6a8fb481b0
Signed-off-by: Heonjae Jang <heonjae.jang@samsung.com>
14 files changed:
TVMediaHub/TVMediaHub.Tizen/Models/ContentProvider.cs
TVMediaHub/TVMediaHub.Tizen/ViewModels/ImageTabViewModel.cs
TVMediaHub/TVMediaHub.Tizen/ViewModels/VideoTabViewModel.cs
TVMediaHub/TVMediaHub.Tizen/Views/FooterDeleteStatus.xaml
TVMediaHub/TVMediaHub.Tizen/Views/FooterDeleteStatus.xaml.cs
TVMediaHub/TVMediaHub.Tizen/Views/FooterNormalStatus.xaml.cs
TVMediaHub/TVMediaHub.Tizen/Views/ImageGroup.xaml
TVMediaHub/TVMediaHub.Tizen/Views/ImageTab.xaml.cs
TVMediaHub/TVMediaHub.Tizen/Views/MediaHubMainPage.xaml
TVMediaHub/TVMediaHub.Tizen/Views/RecentlyWatchedVideoContent.xaml.cs
TVMediaHub/TVMediaHub.Tizen/Views/VideoGroup.xaml.cs
TVMediaHub/TVMediaHub.Tizen/Views/VideoItem.xaml
TVMediaHub/TVMediaHub.Tizen/Views/VideoTab.xaml
TVMediaHub/TVMediaHub.Tizen/Views/VideoTab.xaml.cs

index d15097d..576747b 100644 (file)
@@ -140,19 +140,50 @@ namespace TVMediaHub.Tizen.Models
                 }
 
                 if (currentGroupItem != null)
+                {
                     currentGroupItem.Contents.Add(shortcutInfo);
+                }
                 else
+                {
                     throw new System.Exception("Something's wrong on making a GroupItem. Check your logic.");
-
+                }
             }
 
             return result;
         }
-
-        public async Task CreateThumbnail(MediaShortcutInfo shortcutInfo)
+#pragma warning disable CS1998 // Async method lacks 'await' operators and will run synchronously
+        private async Task<IEnumerable<GroupItem>> MakeGroupAsync(IEnumerable<MediaInformation> mediaInformations, SortOption sortOption)
+#pragma warning restore CS1998 // Async method lacks 'await' operators and will run synchronously
         {
-            DbgPort.D("CreateThumbnail : " + shortcutInfo.Information.Title);
-            var path = await shortcutInfo.Information.CreateThumbnailAsync();
+            DbgPort.D("MG Async");
+            List<GroupItem> result = new List<GroupItem>();
+            GroupItem lastGroupItem = null;
+            GroupItem currentGroupItem = null;
+
+            if (mediaInformations == null)
+            {
+                throw new System.ArgumentException("mediaInformations must not be null.");
+            }
+
+            foreach (MediaInformation mediaInformation in mediaInformations)
+            {
+                var currentInformation = mediaInformation;
+                var path = await currentInformation.CreateThumbnailAsync();
+                var shortcutInfo = new MediaShortcutInfo(currentInformation);
+                currentGroupItem = GetGroupItem(sortOption, currentGroupItem, mediaInformation);
+                if (lastGroupItem != currentGroupItem)
+                {
+                    result.Add(currentGroupItem);
+                    lastGroupItem = currentGroupItem;
+                }
+
+                if (currentGroupItem != null)
+                    currentGroupItem.Contents.Add(shortcutInfo);
+                else
+                    throw new System.Exception("Something's wrong on making a GroupItem. Check your logic.");
+
+            }
+            return result;
         }
 
         public IEnumerable<MediaInformation> ReadWithoutGroup(SortOption sortOption, string storageId = null, int offset = -1, int count = -1)
@@ -202,12 +233,77 @@ namespace TVMediaHub.Tizen.Models
 
             return mediaInformations;
         }
+        public async Task CheckThumnail(IEnumerable<MediaInformation> list)
+        {
+            foreach (var info in list)
+            {
+                var path = await info.CreateThumbnailAsync();
+                DbgPort.D(DateTime.Now.Millisecond.ToString());
+            }
+        }
+
+        public async Task<IEnumerable<MediaInformation>> ReadWithoutGroupAsync(SortOption sortOption, string storageId = null, int offset = -1, int count = -1)
+        {
+            // Makes Content Filter by arguments
+            var contentFilter = new ContentFilter();
+
+            switch (sortOption)
+            {
+                case SortOption.Title:
+                    contentFilter.OrderKey = "MEDIA_DISPLAY_NAME";
+                    break;
+                case SortOption.Date:
+                    contentFilter.OrderKey = "MEDIA_RECORDED_DATE";
+                    break;
+                case SortOption.Genre:
+                    contentFilter.OrderKey = "MEDIA_GENRE";
+                    break;
+                case SortOption.Type:
+                    contentFilter.OrderKey = "MEDIA_TYPE";
+                    break;
+                default:
+                    throw new System.ArgumentException("Invalid sorting option.");
+            }
+
+            if (offset >= 0)
+                contentFilter.Offset = offset;
+
+            if (count >= 0)
+                contentFilter.Count = count;
+
+            if (storageId != null)
+                contentFilter.StorageId = storageId;
+
+            contentFilter.Condition = GetConditionStringForSelection();
+
+            // Executes the 'select' query
+            IEnumerable<MediaInformation> mediaInformations = null;
+            try
+            {
+                await Task.Factory.StartNew(() =>
+                {
+                    mediaInformations = ContentManager.Database.SelectAll<MediaInformation>(contentFilter);
+                });
+            }
+            catch (Exception exception)
+            {
+                Log.Debug(TAG, exception.Message);
+            }
+            return mediaInformations;
+        }
 
         public IEnumerable<GroupItem> Read(SortOption sortOption, string storageId = null, int offset = -1, int count = -1)
         {
             return MakeGroups(ReadWithoutGroup(sortOption, storageId, offset, count), sortOption);
         }
 
+        public async Task<IEnumerable<GroupItem>> ReadAsync(SortOption sortOption, string storageId = null, int offset = -1, int count = -1)
+        {
+            IEnumerable<MediaInformation> list = await ReadWithoutGroupAsync(sortOption, storageId, offset, count);
+            CheckThumnail(list);
+            return await MakeGroupAsync(list, sortOption);
+        }
+
         public MediaInformation Read(String mediaID)
         {
             return ContentManager.Database.Select(mediaID);
index 6a09272..45cd23a 100755 (executable)
@@ -23,6 +23,10 @@ using System.Linq;
 using Tizen.Content.MediaContent;
 using TVMediaHub.Tizen.Models;
 using TVMediaHub.Tizen.DataModels;
+using System.Threading.Tasks;
+using TVMediaHub.Tizen.Utils;
+using System;
+using System.Collections.ObjectModel;
 
 namespace TVMediaHub.Tizen.ViewModels
 {
@@ -30,7 +34,8 @@ namespace TVMediaHub.Tizen.ViewModels
     {
         private IEnumerable<MediaInformation> MediaInfoList;
         private List<ImageViewerInfomation> ImageInfoList;
-        public IEnumerable<GroupItem> ImageList { get; set; }
+
+        public ObservableCollection<GroupItem> ImageList { get; set; }
         public Command SetSelectedImageCommand { get; set; }
         public ImageViewerInfomation CurrentImage { get; set; }
 
@@ -99,6 +104,8 @@ namespace TVMediaHub.Tizen.ViewModels
 
         public Command DeleteModeChangeCommand { get; set; }
 
+        public ICommand GetInformationsCommand { get; set; }
+
         public event PropertyChangedEventHandler PropertyChanged;
 
         protected void OnPropertyChanged([CallerMemberName] string propertyName = null)
@@ -111,6 +118,7 @@ namespace TVMediaHub.Tizen.ViewModels
 
         public ImageTabViewModel()
         {
+            ImageList = new ObservableCollection<GroupItem>();
             InitializeFooterItemsSource();
             InitializeCommands();
             MakeImageInfoList();
@@ -118,18 +126,17 @@ namespace TVMediaHub.Tizen.ViewModels
 
             // for test
             CurrentImage = ImageInfoList[0];
-
             OnPropertyChanged("CurrentImage");
         }
 
         private void InitializeCommands()
         {
-            this.DeleteModeChangeCommand = new Command(() =>
+            DeleteModeChangeCommand = new Command(() =>
             {
                 OnDeleteModeChanged();
             });
 
-            this.NavigationCommand = new Command<string>((direction) =>
+            NavigationCommand = new Command<string>((direction) =>
             {
                 int index = ImageInfoList.ToList<ImageViewerInfomation>().IndexOf(CurrentImage);
                 if (direction.Equals("Left"))
@@ -149,30 +156,30 @@ namespace TVMediaHub.Tizen.ViewModels
                 OnPropertyChanged("CurrentImage");
             });
 
-            this.SetSlideShowSpeedCommand = new Command<SlideShowSpeed>((speed) =>
+            SetSlideShowSpeedCommand = new Command<SlideShowSpeed>((speed) =>
             {
                 Speed = speed;
                 OnPropertyChanged("Speed");
             });
 
-            this.SetSlideShowEffectCommand = new Command<SlideShowEffect>((effect) =>
+            SetSlideShowEffectCommand = new Command<SlideShowEffect>((effect) =>
             {
                 Effect = effect;
                 OnPropertyChanged("Effect");
             });
 
-            this.SetCurrentImageInfo = new Command<MediaInformation>((info) =>
+            SetCurrentImageInfo = new Command<MediaInformation>((info) =>
             {
                 SetCurrentImage(info);
             });
 
-            this.SetRotationCountCommand = new Command(() =>
+            SetRotationCountCommand = new Command(() =>
             {
                 CurrentImage.RotateCount++;
                 OnPropertyChanged("CurrentImage");
             });
 
-            this.ChangeSortOptionCommand = new Command<string>((opt) =>
+            ChangeSortOptionCommand = new Command<string>((opt) =>
             {
                 switch (opt)
                 {
@@ -190,6 +197,11 @@ namespace TVMediaHub.Tizen.ViewModels
                         break;
                 }
             });
+
+            GetInformationsCommand = new Command(() =>
+            {
+                ReadImageList(SortOption.Title);
+            });
         }
 
         private void GetImageData(int source, int sortby)
@@ -253,10 +265,14 @@ namespace TVMediaHub.Tizen.ViewModels
             return ivInfo;
         }
 
-        private void ReadImageList(SortOption option)
+        private async void ReadImageList(SortOption option)
         {
-            ImageList = MediaHubImpl.GetInstance.ImageProviderInstance.Read(option);
-            OnPropertyChanged("ImageList");
+            ImageList.Clear();
+            IEnumerable<GroupItem> tempList = await MediaHubImpl.GetInstance.ImageProviderInstance.ReadAsync(option);
+            foreach (var group in tempList)
+            {
+                ImageList.Add(group);
+            }
         }
 
         private void MakeImageInfoList()
index 3a1197f..4295ab4 100644 (file)
@@ -16,6 +16,7 @@
 
 using System;
 using System.Collections.Generic;
+using System.Collections.ObjectModel;
 using System.ComponentModel;
 using System.Threading.Tasks;
 using System.Windows.Input;
@@ -43,7 +44,7 @@ namespace TVMediaHub.Tizen.ViewModels
         // TODO : Change to MediaInformation
         public string RecentlyWatchedContent { get; private set; }
 
-        public IEnumerable<GroupItem> VideoList { get; set; }
+        public ObservableCollection<GroupItem> VideoList { get; set; }
 
         public IEnumerable<string> SourceList { get; set; }
 
@@ -51,9 +52,9 @@ namespace TVMediaHub.Tizen.ViewModels
 
         public IEnumerable<string> OptionList { get; set; }
 
-        public ICommand CreateThumbnailCommand { get; set; }
         public ICommand ChangeTabStatusCommand { get; set; }
         public ICommand ChangeSortOptionCommand { get; set; }
+        public ICommand GetInformationsCommand { get; set; }
 
         private bool isDeleteStatus;
 
@@ -75,10 +76,16 @@ namespace TVMediaHub.Tizen.ViewModels
 
         public VideoTabViewModel()
         {
+            DbgPort.D("Binding Context cotr " + DateTime.Now);
             InitializeFooterItemsSource();
-            ReadRecentlyWatchedContent();
-            ReadVideoList(SortOption.Title);
-            CreateThumbnailCommand = new Command(() => CreateThumbnail());
+            InitializeCommands();
+            VideoList = new ObservableCollection<GroupItem>();
+            OnPropertyChanged("VideoList");
+            DbgPort.D("" + DateTime.Now);
+        }
+
+        private void InitializeCommands()
+        {
             ChangeTabStatusCommand = new Command(() =>
             {
                 IsDeleteStatus = !IsDeleteStatus;
@@ -106,47 +113,12 @@ namespace TVMediaHub.Tizen.ViewModels
                         break;
                 }
             });
-            OnPropertyChanged("CreateThumbnailCommand");
-            OnPropertyChanged("ChangeTabStatusCommand");
-            OnPropertyChanged("ChangeSortOptionCommand");
-        }
-
-        public async Task<bool> CreateThumbnail()
-        {
-            DbgPort.D("CreateThumnail Task Start");
-            List<MediaShortcutInfo> noThumbnailList = new List<MediaShortcutInfo>();
-            var tasks = new List<Task>();
-
-            foreach (var group in VideoList)
+            GetInformationsCommand = new Command(() =>
             {
-                foreach (var info in group.Contents)
-                {
-                    if (info.Information.ThumbnailPath == null)
-                    {
-                        noThumbnailList.Add(info);
-                        DbgPort.D("Add task " + info);
-                        tasks.Add(MediaHubImpl.GetInstance.VideoProviderInstance.CreateThumbnail(info));
-                    }
-                }
-            }
-
-            DbgPort.D("Wait Start " + DateTime.Now.Millisecond);
-
-            await Task.WhenAll(tasks).ContinueWith((a) =>
-            {
-                Device.BeginInvokeOnMainThread(() =>
-                {
-                    foreach (var info in noThumbnailList)
-                    {
-                        DbgPort.D("Update Thumbnail : " + info.Information.Title);
-                        info.Update();
-                    }
-                });
+                ReadVideoList(SortOption.Title);
             });
-
-            DbgPort.D("Wait End " + DateTime.Now.Millisecond);
-            DbgPort.D("CreateThumnail Task End");
-            return true;
+            OnPropertyChanged("ChangeTabStatusCommand");
+            OnPropertyChanged("ChangeSortOptionCommand");
         }
 
         private void InitializeFooterItemsSource()
@@ -185,10 +157,14 @@ namespace TVMediaHub.Tizen.ViewModels
             OnPropertyChanged("RecentlyWatchedContent");
         }
 
-        private void ReadVideoList(SortOption option)
+        private async void ReadVideoList(SortOption option)
         {
-            VideoList = MediaHubImpl.GetInstance.VideoProviderInstance.Read(option);
-            OnPropertyChanged("VideoList");
+            VideoList.Clear();
+            IEnumerable<GroupItem> tempList = await MediaHubImpl.GetInstance.VideoProviderInstance.ReadAsync(option);
+            foreach (var group in tempList)
+            {
+                VideoList.Add(group);
+            }
         }
     }
 }
index 7f6e64d..6837702 100644 (file)
@@ -2,24 +2,4 @@
 <RelativeLayout xmlns="http://xamarin.com/schemas/2014/forms"
              xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
              x:Class="TVMediaHub.Tizen.Views.FooterDeleteStatus">
-    <Label x:Name="SeletedItemLabel"
-           RelativeLayout.HeightConstraint="{ConstraintExpression Type=RelativeToParent, Property=Height, Factor=0.0364}"
-           RelativeLayout.WidthConstraint="{ConstraintExpression Type=RelativeToParent, Property=Width, Factor=0.3125}"
-           RelativeLayout.YConstraint="{ConstraintExpression Type=RelativeToParent, Property=Height, Factor=0.8841}"
-           RelativeLayout.XConstraint="{ConstraintExpression Type=RelativeToParent, Property=Width, Factor=0.05}"/>
-    <Button x:Name="SelectAllButton"
-            RelativeLayout.HeightConstraint="{ConstraintExpression Type=RelativeToParent, Property=Height, Factor=0.0909}"
-            RelativeLayout.WidthConstraint="{ConstraintExpression Type=RelativeToParent, Property=Width, Factor=0.1563}"
-            RelativeLayout.YConstraint="{ConstraintExpression Type=RelativeToParent, Property=Height, Factor=0.8841}"
-            RelativeLayout.XConstraint="{ConstraintExpression Type=RelativeToParent, Property=Width, Factor=0.5}"/>
-    <Button x:Name="OKButton"
-            RelativeLayout.HeightConstraint="{ConstraintExpression Type=RelativeToParent, Property=Height, Factor=0.0909}"
-            RelativeLayout.WidthConstraint="{ConstraintExpression Type=RelativeToParent, Property=Width, Factor=0.1563}"
-            RelativeLayout.YConstraint="{ConstraintExpression Type=RelativeToParent, Property=Height, Factor=0.8841}"
-            RelativeLayout.XConstraint="{ConstraintExpression Type=RelativeToParent, Property=Width, Factor=0.6385}"/>
-    <Button x:Name="CancelButton"
-           RelativeLayout.HeightConstraint="{ConstraintExpression Type=RelativeToParent, Property=Height, Factor=0.0909}"
-           RelativeLayout.WidthConstraint="{ConstraintExpression Type=RelativeToParent, Property=Width, Factor=0.1563}"
-           RelativeLayout.YConstraint="{ConstraintExpression Type=RelativeToParent, Property=Height, Factor=0.8841}"
-           RelativeLayout.XConstraint="{ConstraintExpression Type=RelativeToParent, Property=Width, Factor=0.7948}"/>
 </RelativeLayout>
\ No newline at end of file
index 87c491e..f42abd6 100644 (file)
@@ -12,5 +12,15 @@ namespace TVMediaHub.Tizen.Views
         {
             InitializeComponent();
         }
+
+        private void OnSelectAllButtonClicked(object sender, EventArgs e)
+        {
+        }
+        private void OnOKButtonClicked(object sender, EventArgs e)
+        {
+        }
+        private void OnCancelClicked(object sender, EventArgs e)
+        {
+        }
     }
 }
index 5a0651e..735d5bc 100644 (file)
@@ -141,22 +141,25 @@ namespace TVMediaHub.Tizen.Views
                 OnDropdownOptionItemSelected?.Invoke(s, e);
             };
 
+            // TODO : Change yConstraint.
+            // Tab Size - 128
+
             Children.Add(DropdownSource,
                 heightConstraint: Constraint.Constant(SizeUtils.GetHeightSize(80)),
                 widthConstraint: Constraint.Constant(SizeUtils.GetWidthSize(300)),
-                yConstraint: Constraint.Constant(SizeUtils.GetWidthSize(752)),
+                yConstraint: Constraint.Constant(SizeUtils.GetWidthSize(619)),
                 xConstraint: Constraint.Constant(SizeUtils.GetWidthSize(96)));
 
             Children.Add(DropdownSort,
                 heightConstraint: Constraint.Constant(SizeUtils.GetHeightSize(80)),
                 widthConstraint: Constraint.Constant(SizeUtils.GetWidthSize(300)),
-                yConstraint: Constraint.Constant(SizeUtils.GetWidthSize(752)),
+                yConstraint: Constraint.Constant(SizeUtils.GetWidthSize(619)),
                 xConstraint: Constraint.Constant(SizeUtils.GetWidthSize(1226)));
 
             Children.Add(DropdownOption,
                 heightConstraint: Constraint.Constant(SizeUtils.GetHeightSize(80)),
                 widthConstraint: Constraint.Constant(SizeUtils.GetWidthSize(300)),
-                yConstraint: Constraint.Constant(SizeUtils.GetWidthSize(752)),
+                yConstraint: Constraint.Constant(SizeUtils.GetWidthSize(619)),
                 xConstraint: Constraint.Constant(SizeUtils.GetWidthSize(1526)));
         }
     }
index 9a293e9..75f1546 100644 (file)
@@ -16,7 +16,6 @@
     <Grid x:Name="GroupContentArea" ColumnSpacing="2" RowSpacing="2"
           RelativeLayout.HeightConstraint="{ConstraintExpression Type=RelativeToParent, Property=Height, Factor=0.7324}"
           RelativeLayout.YConstraint="{ConstraintExpression Type=RelativeToParent, Property=Height, Factor=0.1649}">
-
     </Grid>
 
 </RelativeLayout>
\ No newline at end of file
index 1de17b5..7d5ecbe 100755 (executable)
@@ -16,7 +16,9 @@
 
 using System;
 using System.Collections.Generic;
+using System.Collections.ObjectModel;
 using System.ComponentModel;
+using System.Threading.Tasks;
 using System.Windows.Input;
 using TVMediaHub.Tizen.Models;
 using TVMediaHub.Tizen.Utils;
@@ -27,13 +29,26 @@ namespace TVMediaHub.Tizen.Views
 {
     public partial class ImageTab : ContentPage
     {
+        /// <summary>
+        /// Identifies the CreateThumbnailCommand bindable property
+        /// </summary>
+        public static readonly BindableProperty CreateThumbnailCommandProperty = BindableProperty.Create("CreateThumbnailCommand", typeof(ICommand), typeof(VideoTab), default(ICommand));
+
+        /// <summary>
+        /// Gets or sets CreateThumbnail Command
+        /// </summary>
+        public ICommand CreateThumbnailCommand
+        {
+            get { return (ICommand)GetValue(CreateThumbnailCommandProperty); }
+            set { SetValue(CreateThumbnailCommandProperty, value); }
+        }
         bool IsDeleteMode;
 
-        public static readonly BindableProperty ItemsSourceProperty = BindableProperty.Create("ItemsSource", typeof(IEnumerable<GroupItem>), typeof(ImageTab), default(IEnumerable<GroupItem>));
+        public static readonly BindableProperty ItemsSourceProperty = BindableProperty.Create("ItemsSource", typeof(ObservableCollection<GroupItem>), typeof(ImageTab), default(ObservableCollection<GroupItem>));
 
-        public IEnumerable<GroupItem> ItemsSource
+        public ObservableCollection<GroupItem> ItemsSource
         {
-            get { return (IEnumerable<GroupItem>)GetValue(ItemsSourceProperty); }
+            get { return (ObservableCollection<GroupItem>)GetValue(ItemsSourceProperty); }
             set { SetValue(ItemsSourceProperty, value); }
         }
 
@@ -59,14 +74,42 @@ namespace TVMediaHub.Tizen.Views
             set { SetValue(ChangeSortOptionCommandProperty, value); }
         }
 
+        public static readonly BindableProperty GetInformationsCommandProperty = BindableProperty.Create("GetInformationsCommand", typeof(ICommand), typeof(VideoTab), default(ICommand));
+
+        public ICommand GetInformationsCommand
+        {
+            get { return (ICommand)GetValue(GetInformationsCommandProperty); }
+            set { SetValue(GetInformationsCommandProperty, value); }
+        }
+
         public ImageTab()
         {
             BindingContext = ImageTabViewModelLocator.ViewModel;
             InitializeComponent();
             InitializeSize();
             InitializeFooter();
-            PropertyChanged += ImageTabPropertyChanged;
-            AddGroup();
+            ItemsSource.CollectionChanged += ItemsSourceCollectionChanged;
+        }
+
+        protected override void OnAppearing()
+        {
+            base.OnAppearing();
+            GetInformationsCommand?.Execute("");
+        }
+
+        private void ItemsSourceCollectionChanged(object sender, System.Collections.Specialized.NotifyCollectionChangedEventArgs e)
+        {
+            if (e.Action.ToString().Equals("Add"))
+            {
+                var group = e.NewItems[0] as GroupItem;
+                ImageGroup galleryGroup = new ImageGroup();
+                galleryGroup.SetItemsSource(group.Title, group.Contents);
+                GalleryContentView.Children.Add(galleryGroup);
+            }
+            else if (e.Action.ToString().Equals("Reset"))
+            {
+                GalleryContentView.Children.Clear();
+            }
         }
 
         private void InitializeFooter()
@@ -104,22 +147,6 @@ namespace TVMediaHub.Tizen.Views
             ImageTabScrollView.Margin = new Thickness(Utils.SizeUtils.GetWidthSize(96), Utils.SizeUtils.GetHeightSize(74), 0, Utils.SizeUtils.GetHeightSize(84));
         }
 
-        private void AddGroup()
-        {
-            if (ItemsSource != null)
-            {
-                GalleryContentView.Children.Clear();
-                var list = ItemsSource as List<GroupItem>;
-                foreach(GroupItem group in list)
-                {
-                    ImageGroup galleryGroup = new ImageGroup();
-                    galleryGroup.SetItemsSource(group.Title, group.Contents);
-                    GalleryContentView.Children.Add(galleryGroup);
-                }
-            }
-
-        }
-
         private void GetImageData()
         {
 
@@ -138,13 +165,5 @@ namespace TVMediaHub.Tizen.Views
             //}
         }
 
-        private void ImageTabPropertyChanged(object sender, PropertyChangedEventArgs e)
-        {
-            if (e.PropertyName.Equals("ItemsSource"))
-            {
-                AddGroup();
-            }
-        }
-
     }
 }
index 41ffe0b..d3b63b0 100755 (executable)
@@ -8,5 +8,4 @@
     <Views:VideoTab/>
     <Views:ImageTab/>
     <Views:VideoPlayer/>
-
 </TabbedPage>
\ No newline at end of file
index 3e80576..7a7fe6e 100644 (file)
@@ -42,7 +42,6 @@ namespace TVMediaHub.Tizen.Views
             ContentTitle.TextColor = Color.FromRgb(255,255,255);
             ContentDescription.FontSize = SizeUtils.GetFontSize(26);
             ContentDescription.TextColor = Color.FromRgb(137,137,137);
-
         }
     }
 }
index 07ad736..ee2dc83 100644 (file)
@@ -54,7 +54,9 @@ namespace TVMediaHub.Tizen.Views
             GroupTitle.FontSize = SizeUtils.GetFontSize(24);
         }
 
-        private void VideoGroupPropertyChanged(object sender, System.ComponentModel.PropertyChangedEventArgs e)
+#pragma warning disable CS1998 // Async method lacks 'await' operators and will run synchronously
+        private async void VideoGroupPropertyChanged(object sender, System.ComponentModel.PropertyChangedEventArgs e)
+#pragma warning restore CS1998 // Async method lacks 'await' operators and will run synchronously
         {
             if (e.PropertyName.Equals("ItemsSource"))
             {
index 3806ae3..452f000 100644 (file)
@@ -5,10 +5,8 @@
                 x:Class="TVMediaHub.Tizen.Views.VideoItem">
     <!-- TODO : Change to Image -->
     <Button x:Name ="FocusArea"
-            RelativeLayout.HeightConstraint="{ConstraintExpression Type=RelativeToParent, Property=Height, Factor=0.8824}"
-            RelativeLayout.WidthConstraint="{ConstraintExpression Type=RelativeToParent, Property=Width, Factor=0.9302}"
-            RelativeLayout.YConstraint="{ConstraintExpression Type=RelativeToParent, Property=Height, Factor=0.0588}"
-            RelativeLayout.XConstraint="{ConstraintExpression Type=RelativeToParent, Property=Width, Factor=0.0349}"
+            RelativeLayout.HeightConstraint="{ConstraintExpression Type=RelativeToParent, Property=Height, Factor=1}"
+            RelativeLayout.WidthConstraint="{ConstraintExpression Type=RelativeToParent, Property=Width, Factor=1}"
             Opacity="0"
             Focused="OnFocused"
             Unfocused="OnUnfocused"/>
@@ -47,6 +45,7 @@
            RelativeLayout.YConstraint="{ConstraintExpression Type=RelativeToParent, Property=Height, Factor=0.7667}"
            RelativeLayout.XConstraint="{ConstraintExpression Type=RelativeToParent, Property=Height, Factor=0.05625}"
            TextColor="White"
+           LineBreakMode="TailTruncation"
            Text="{Binding ContentName}"/>
     <!-- TODO : remove -->
 </RelativeLayout>
index cb35877..9beff59 100644 (file)
@@ -9,7 +9,8 @@
              IsDeleteStatus="{Binding IsDeleteStatus}"
              CreateThumbnailCommand="{Binding CreateThumbnailCommand}"
              ChangeTabStatusCommand="{Binding ChangeTabStatusCommand}"
-             ChangeSortOptionCommand="{Binding ChangeSortOptionCommand}">
+             ChangeSortOptionCommand="{Binding ChangeSortOptionCommand}"
+             GetInformationsCommand="{Binding GetInformationsCommand}">
     <ContentPage.BindingContext>
         <ViewModels:VideoTabViewModel/>
     </ContentPage.BindingContext>
             RelativeLayout.WidthConstraint="{ConstraintExpression Type=RelativeToParent, Property=Width, Factor=1}"
             Orientation="Horizontal">
             <StackLayout x:Name="VideoTabScrollViewContent"
-                     RelativeLayout.HeightConstraint="{ConstraintExpression Type=RelativeToParent, Property=Height, Factor=0.1}"
-                     Orientation="Horizontal">
-                <Views:RecentlyWatchedVideoContent x:Name="RecentlyWatchedContent"/>
+                         Orientation="Horizontal"
+                         RelativeLayout.HeightConstraint="{ConstraintExpression Type=RelativeToParent, Property=Height, Factor=1}">
+                <Views:RecentlyWatchedVideoContent x:Name="RecentlyWatchedContent"
+                                                   RelativeLayout.HeightConstraint="{ConstraintExpression Type=RelativeToParent, Property=Height, Factor=1}"/>
                 <StackLayout x:Name="VideoTabList"
-                         RelativeLayout.HeightConstraint="{ConstraintExpression Type=RelativeToParent, Property=Height, Factor=0.1}"
-                         Orientation="Horizontal">
+                             RelativeLayout.HeightConstraint="{ConstraintExpression Type=RelativeToParent, Property=Height, Factor=1}"
+                             Orientation="Horizontal">
                 </StackLayout>
             </StackLayout>
         </ScrollView>
index 5198cf1..e35e9d0 100644 (file)
 
 using System;
 using System.Collections.Generic;
+using System.Collections.ObjectModel;
 using System.ComponentModel;
 using System.Threading;
 using System.Threading.Tasks;
 using System.Windows.Input;
 using TVMediaHub.Tizen.Models;
 using TVMediaHub.Tizen.Utils;
+using TVMediaHub.Tizen.ViewModels;
 using Xamarin.Forms;
 
 namespace TVMediaHub.Tizen.Views
@@ -31,14 +33,14 @@ namespace TVMediaHub.Tizen.Views
         /// <summary>
         /// Identifies the ItemsSource bindable property
         /// </summary>
-        public static readonly BindableProperty ItemsSourceProperty = BindableProperty.Create("ItemsSource", typeof(IEnumerable<GroupItem>), typeof(VideoTab), default(IEnumerable<GroupItem>));
+        public static readonly BindableProperty ItemsSourceProperty = BindableProperty.Create("ItemsSource", typeof(ObservableCollection<GroupItem>), typeof(VideoTab), default(ObservableCollection<GroupItem>));
 
         /// <summary>
         /// Gets or sets source of list items
         /// </summary>
-        public IEnumerable<GroupItem> ItemsSource
+        public ObservableCollection<GroupItem> ItemsSource
         {
-            get { return (IEnumerable<GroupItem>)GetValue(ItemsSourceProperty); }
+            get { return (ObservableCollection<GroupItem>)GetValue(ItemsSourceProperty); }
             set { SetValue(ItemsSourceProperty, value); }
         }
 
@@ -56,6 +58,14 @@ namespace TVMediaHub.Tizen.Views
             set { SetValue(CreateThumbnailCommandProperty, value); }
         }
 
+        public static readonly BindableProperty GetInformationsCommandProperty = BindableProperty.Create("GetInformationsCommand", typeof(ICommand), typeof(VideoTab), default(ICommand));
+
+        public ICommand GetInformationsCommand
+        {
+            get { return (ICommand)GetValue(GetInformationsCommandProperty); }
+            set { SetValue(GetInformationsCommandProperty, value); }
+        }
+
         public static readonly BindableProperty IsDeleteStatusProperty = BindableProperty.Create("IsDeleteStatus", typeof(bool), typeof(VideoTab), false);
 
         /// <summary>
@@ -100,8 +110,32 @@ namespace TVMediaHub.Tizen.Views
             InitializeComponent();
             InitializeSize();
             InitializeFooter();
-            PropertyChanged += VideoTabPropertyChanged;
-            SetItems();
+            ItemsSource.CollectionChanged += ItemsSource_CollectionChanged;
+        }
+
+        private void ItemsSource_CollectionChanged(object sender, System.Collections.Specialized.NotifyCollectionChangedEventArgs e)
+        {
+            if (e.Action.ToString().Equals("Add"))
+            {
+                VideoGroup groupView = new VideoGroup();
+                groupView.BindingContext = e.NewItems[0];
+                VideoTabList.Children.Add(groupView);
+            }
+            else if (e.Action.ToString().Equals("Reset"))
+            {
+                VideoTabList.Children.Clear();
+            }
+        }
+
+        protected override void OnAppearing()
+        {
+            base.OnAppearing();
+            GetInformationsCommand?.Execute("");
+        }
+
+        private void VideoTabBindingContextChanged(object sender, EventArgs e)
+        {
+            DbgPort.D("BC Changed");
         }
 
         private void InitializeFooter()
@@ -116,7 +150,7 @@ namespace TVMediaHub.Tizen.Views
 
         private void OnSourceChanged(object sender, SelectedItemChangedEventArgs e)
         {
-
+            CreateThumbnailCommand.Execute("");
         }
 
         private void OnSortOptionChanged(object sender, SelectedItemChangedEventArgs e)
@@ -142,19 +176,14 @@ namespace TVMediaHub.Tizen.Views
             VideoTabList.Spacing = SizeUtils.GetWidthSize(36);
         }
 
-        private void VideoTabPropertyChanged(object sender, PropertyChangedEventArgs e)
-        {
-            if (e.PropertyName.Equals("ItemsSource"))
-            {
-                SetItems();
-            }
-        }
+#pragma warning disable CS1998 // Async method lacks 'await' operators and will run synchronously
         private async void SetItems()
+#pragma warning restore CS1998 // Async method lacks 'await' operators and will run synchronously
         {
             DbgPort.D("SetItem");
             if (ItemsSource != null)
             {
-                var list = ItemsSource as List<GroupItem>;
+                var list = ItemsSource;
                 VideoTabList.Children.Clear();
                 foreach (var group in list)
                 {
@@ -162,21 +191,6 @@ namespace TVMediaHub.Tizen.Views
                     groupView.BindingContext = group;
                     VideoTabList.Children.Add(groupView);
                 }
-
-                await Task.Run(() =>
-                {
-                    Device.BeginInvokeOnMainThread(() =>
-                    {
-                        try
-                        {
-                            CreateThumbnailCommand.Execute("");
-                        }
-                        catch (Exception e)
-                        {
-                            DbgPort.D(e.Message);
-                        }
-                    });
-                });
             }
         }
     }