newGroupFlag = true;
newTitle = mediaInformationEx.MediaContentInformation.MediaType.ToString();
}
+ break;
+ case SortOption.Album:
+ if (lastGroupItem == null || lastGroupItem.Title != (mediaInformationEx.MediaContentInformation as AudioInformation).Album)
+ {
+ newGroupFlag = true;
+ newTitle = (mediaInformationEx.MediaContentInformation as AudioInformation).Album.ToString();
+ }
+ break;
+ case SortOption.Artist:
+ if (lastGroupItem == null || lastGroupItem.Title != (mediaInformationEx.MediaContentInformation as AudioInformation).Artist)
+ {
+ newGroupFlag = true;
+ newTitle = (mediaInformationEx.MediaContentInformation as AudioInformation).Artist.ToString();
+ }
break;
default:
case SortOption.Type:
contentFilter.OrderKey = "MEDIA_TYPE";
break;
+ case SortOption.Album:
+ contentFilter.OrderKey = "MEDIA_ALBUM";
+ break;
+ case SortOption.Artist:
+ contentFilter.OrderKey = "MEDIA_ARTIST";
+ break;
default:
throw new System.ArgumentException("Invalid sorting option.");
}
case SortOption.Type:
contentFilter.OrderKey = "MEDIA_TYPE";
break;
+ case SortOption.Album:
+ contentFilter.OrderKey = "MEDIA_ALBUM";
+ break;
+ case SortOption.Artist:
+ contentFilter.OrderKey = "MEDIA_ARTIST";
+ break;
default:
throw new System.ArgumentException("Invalid sorting option.");
}
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.ComponentModel;
+using System.Threading;
+using System.Windows.Input;
using TVMediaHub.Tizen.Models;
using TVMediaHub.Tizen.Utils;
+using Xamarin.Forms;
namespace TVMediaHub.Tizen.ViewModels
{
/// </summary>
public ObservableCollection<GroupItem> MusicList { get; set; }
+ /// <summary>
+ /// Gets or sets the SortOption list
+ /// </summary>
+ public IEnumerable<string> SortOptions { get; set; }
+
+ /// <summary>
+ /// Gets or sets the Option list
+ /// </summary>
+ public IEnumerable<string> OptionList { get; set; }
+
+ /// <summary>
+ /// A dictionary list of the source and storage id
+ /// </summary>
+ private Dictionary<string, string> sourcePairList;
+
+ /// <summary>
+ /// A command for executing when SortOption is changed
+ /// </summary>
+ public ICommand ChangeSortOptionCommand { get; set; }
+
private SortOption option = SortOption.Title;
/// <summary>
+ /// A command for executing to get informations
+ /// </summary>
+ public ICommand GetInformationsCommand { get; set; }
+
+ /// <summary>
/// An event that is occurred when property of ViewModel is changed
/// </summary>
public event PropertyChangedEventHandler PropertyChanged;
public MusicTabViewModel()
{
MusicList = new ObservableCollection<GroupItem>();
+ InitializeFooterItemsSource();
+ InitializeCommands();
+
OnPropertyChanged("MusicList");
MediaHubImpl.GetInstance.MusicProviderInstance.SetContentUpdatedEventListener((s, e) =>
{
}
}
- public void TestRead()
+ /// <summary>
+ /// A method for initializing the SourceList, SortOptionList and OptionList
+ /// </summary>
+ private void InitializeFooterItemsSource()
{
- ReadMusicList(option);
+ var list = new List<string>
+ {
+ "SONG",
+ "ALBUM",
+ "ARTIST",
+ "GENRE",
+ };
+ SortOptions = list;
+ OnPropertyChanged("SortOptions");
+
+ list = new List<string>
+ {
+ "DETAIL INFO",
+ "DELETE"
+ };
+ OptionList = list;
+ OnPropertyChanged("OptionList");
+ }
+
+ /// <summary>
+ /// A method for initializing commands that are used in Image tab
+ /// </summary>
+ private void InitializeCommands()
+ {
+ ChangeSortOptionCommand = new Command<string>((opt) =>
+ {
+ var optionString = opt.ToLower();
+ switch (optionString)
+ {
+ case "song":
+ ReadMusicList(SortOption.Title);
+ option = SortOption.Title;
+ break;
+ case "album":
+ ReadMusicList(SortOption.Album);
+ option = SortOption.Album;
+ break;
+ case "artist":
+ ReadMusicList(SortOption.Artist);
+ option = SortOption.Artist;
+ break;
+ case "genre":
+ ReadMusicList(SortOption.Genre);
+ option = SortOption.Genre;
+ break;
+ }
+ });
+
+ GetInformationsCommand = new Command(() =>
+ {
+ SynchronizationContext.Current.Post((o) =>
+ {
+ ReadMusicList(option);
+ }, "");
+ });
+ OnPropertyChanged("ChangeSortOptionCommand");
}
}
}
InitializeFooter();
ItemsSource.CollectionChanged += ItemsSourceCollectionChanged;
PropertyChanged += ImageTabPropertyChanged;
-
- SynchronizationContext.Current.Post((o) =>
- {
- InitializePage();
- }, "");
}
/// <summary>
<Label x:Name="SongTitle"
Grid.Row="0"
Grid.Column="1"
+ LineBreakMode="TailTruncation"
Text="{Binding ContentName}"/>
<Label x:Name="Artist"
Grid.Row="1"
- Grid.Column="1"/>
+ Grid.Column="1"
+ LineBreakMode="TailTruncation"/>
<Label x:Name="AlbumTitle"
Grid.Row="2"
- Grid.Column="1"/>
+ Grid.Column="1"
+ LineBreakMode="TailTruncation"/>
</Grid>
</RelativeLayout>
\ No newline at end of file
HeightRequest = SizeUtils.GetHeightSize(134);
AlbumCover.WidthRequest = SizeUtils.GetWidthSize(134);
AlbumCover.HeightRequest = SizeUtils.GetHeightSize(134);
+ SongTitle.WidthRequest = SizeUtils.GetWidthSize(266);
SongTitle.FontSize = SizeUtils.GetFontSize(20);
+ Artist.WidthRequest = SizeUtils.GetWidthSize(266);
Artist.FontSize = SizeUtils.GetFontSize(17);
+ AlbumTitle.WidthRequest = SizeUtils.GetWidthSize(266);
AlbumTitle.FontSize = SizeUtils.GetFontSize(17);
}
xmlns:Views="clr-namespace:TVMediaHub.Tizen.Views"
Title="Music"
ChangeSortOptionCommand="{Binding ChangeSortOptionCommand}"
+ GetInformationsCommand="{Binding GetInformationsCommand}"
ItemsSource="{Binding MusicList}">
<!-- TODO : Fix to Guide -->
RelativeLayout.WidthConstraint="{ConstraintExpression Type=RelativeToParent, Property=Width, Factor=1}">
<RelativeLayout RelativeLayout.HeightConstraint="{ConstraintExpression Type=RelativeToParent, Property=Height, Factor=1}"
RelativeLayout.WidthConstraint="{ConstraintExpression Type=RelativeToParent, Property=Width, Factor=1}">
+ <Views:FooterDeleteStatus x:Name="FooterDelete" IsVisible="False"
+ RelativeLayout.HeightConstraint="{ConstraintExpression Type=RelativeToParent, Property=Height, Factor=1}"
+ RelativeLayout.WidthConstraint="{ConstraintExpression Type=RelativeToParent, Property=Width, Factor=1}"
+ SelectedCount="{Binding SelectedCount}"/>
<Views:FooterNormalStatus x:Name="FooterNormal" IsVisible="True"
IsFooterEnabled="True"
RelativeLayout.HeightConstraint="{ConstraintExpression Type=RelativeToParent, Property=Height, Factor=1}"
OptionList="{Binding OptionList}"/>
</RelativeLayout>
<ScrollView x:Name="MusicTabScrollView"
- RelativeLayout.HeightConstraint="{ConstraintExpression Type=RelativeToParent, Property=Height, Factor=1}"
+ RelativeLayout.HeightConstraint="{ConstraintExpression Type=RelativeToParent, Property=Height, Factor=0.855}"
RelativeLayout.WidthConstraint="{ConstraintExpression Type=RelativeToParent, Property=Width, Factor=1}"
Orientation="Horizontal" IsVisible="False">
<StackLayout x:Name="MusicContentView"
using System;
using System.Collections.ObjectModel;
using System.Collections.Specialized;
+using System.ComponentModel;
+using System.Threading;
using System.Windows.Input;
using TVMediaHub.Tizen.Controls;
using TVMediaHub.Tizen.DataModels;
namespace TVMediaHub.Tizen.Views
{
+
/// <summary>
/// A custom ContentPage for displaying Music tab
/// </summary>
public partial class MusicTab : ContentPageEx
{
+ /// <summary>
+ /// The flag whether content is ready
+ /// </summary>
+ private bool IsContentReady = false;
/// <summary>
/// Identifies the ItemsSource bindable property
get { return (ICommand)GetValue(ChangeSortOptionCommandProperty); }
set { SetValue(ChangeSortOptionCommandProperty, value); }
}
+
+ /// <summary>
+ /// Identifies the GetInformationsCommand bindable property
+ /// </summary>
+ public static readonly BindableProperty GetInformationsCommandProperty = BindableProperty.Create("GetInformationsCommand", typeof(ICommand), typeof(MusicTab), default(ICommand));
+
+ /// <summary>
+ /// Gets or sets GetInformationsCommand
+ /// </summary>
+ public ICommand GetInformationsCommand
+ {
+ get { return (ICommand)GetValue(GetInformationsCommandProperty); }
+ set { SetValue(GetInformationsCommandProperty, value); }
+ }
+
/// <summary>
/// A constructor
/// Initializes the size of the items that are used in Music tab
InitializeFooter();
ItemsSource.CollectionChanged += ItemsSourceCollectionChanged;
-
- MusicTabViewModelLocator.ViewModel.TestRead();
- // TODO : for the test
}
-
/// <summary>
/// A method for initializing the size of the items that are used in Music tab
/// </summary>
/// </summary>
protected override void InitializePage()
{
+ if (IsContentReady == false)
+ {
+ GetInformationsCommand?.Execute("");
+ IsContentReady = true;
+ }
}
/// <summary>
{
}
+
/// <summary>
/// Occurs when an item is added, removed, changed, moved, or the entire list is refreshed.
/// </summary>
/// <param name="e">Information about the event</param>
private void ItemsSourceCollectionChanged(object sender, NotifyCollectionChangedEventArgs e)
{
- if (e.Action.ToString().Equals("Add"))
+ if (e.Action.ToString().Equals(NotifyCollectionChangedAction.Add.ToString()))
{
if (MusicNoContents.IsVisible)
{
groupView.BindingContext = groupItem;
MusicContentView.Children.Add(groupView);
}
+ else if (e.Action.ToString().Equals(NotifyCollectionChangedAction.Reset.ToString()))
+ {
+ MusicContentView.Children.Clear();
+ if (!MusicNoContents.IsVisible)
+ {
+ MusicTabScrollView.IsVisible = false;
+ MusicNoContents.IsVisible = true;
+ }
+ }
}