}
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)
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);
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
{
{
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; }
public Command DeleteModeChangeCommand { get; set; }
+ public ICommand GetInformationsCommand { get; set; }
+
public event PropertyChangedEventHandler PropertyChanged;
protected void OnPropertyChanged([CallerMemberName] string propertyName = null)
public ImageTabViewModel()
{
+ ImageList = new ObservableCollection<GroupItem>();
InitializeFooterItemsSource();
InitializeCommands();
MakeImageInfoList();
// 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"))
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)
{
break;
}
});
+
+ GetInformationsCommand = new Command(() =>
+ {
+ ReadImageList(SortOption.Title);
+ });
}
private void GetImageData(int source, int sortby)
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()
using System;
using System.Collections.Generic;
+using System.Collections.ObjectModel;
using System.ComponentModel;
using System.Threading.Tasks;
using System.Windows.Input;
// 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; }
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;
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;
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()
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);
+ }
}
}
}
<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
{
InitializeComponent();
}
+
+ private void OnSelectAllButtonClicked(object sender, EventArgs e)
+ {
+ }
+ private void OnOKButtonClicked(object sender, EventArgs e)
+ {
+ }
+ private void OnCancelClicked(object sender, EventArgs e)
+ {
+ }
}
}
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)));
}
}
<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
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;
{
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); }
}
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()
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()
{
//}
}
- private void ImageTabPropertyChanged(object sender, PropertyChangedEventArgs e)
- {
- if (e.PropertyName.Equals("ItemsSource"))
- {
- AddGroup();
- }
- }
-
}
}
<Views:VideoTab/>
<Views:ImageTab/>
<Views:VideoPlayer/>
-
</TabbedPage>
\ No newline at end of file
ContentTitle.TextColor = Color.FromRgb(255,255,255);
ContentDescription.FontSize = SizeUtils.GetFontSize(26);
ContentDescription.TextColor = Color.FromRgb(137,137,137);
-
}
}
}
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"))
{
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"/>
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>
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>
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
/// <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); }
}
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>
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()
private void OnSourceChanged(object sender, SelectedItemChangedEventArgs e)
{
-
+ CreateThumbnailCommand.Execute("");
}
private void OnSortOptionChanged(object sender, SelectedItemChangedEventArgs e)
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)
{
groupView.BindingContext = group;
VideoTabList.Children.Add(groupView);
}
-
- await Task.Run(() =>
- {
- Device.BeginInvokeOnMainThread(() =>
- {
- try
- {
- CreateThumbnailCommand.Execute("");
- }
- catch (Exception e)
- {
- DbgPort.D(e.Message);
- }
- });
- });
}
}
}