From: Geunsun, Lee Date: Mon, 5 Jun 2017 04:02:48 +0000 (+0900) Subject: Implement viewmodel for music tab X-Git-Tag: accepted/tizen/unified/20170811.133302~30^2 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=8694d4a71cff0b8a891f9bcd3eb8d6a1b66f3161;p=profile%2Ftv%2Fapps%2Fdotnet%2Fmediahub.git Implement viewmodel for music tab Change-Id: Iba23c8e3308cc11a7184e90d45832ba17e12b6a1 --- diff --git a/TVMediaHub/TVMediaHub.Tizen/Models/MusicProvider.cs b/TVMediaHub/TVMediaHub.Tizen/Models/MusicProvider.cs index 370525a..25b5a5b 100755 --- a/TVMediaHub/TVMediaHub.Tizen/Models/MusicProvider.cs +++ b/TVMediaHub/TVMediaHub.Tizen/Models/MusicProvider.cs @@ -37,7 +37,7 @@ namespace TVMediaHub.Tizen.Models /// A condition string protected override string GetConditionStringForSelection() { - return "(MEDIA_TYPE=8)"; + return "(MEDIA_TYPE=3)"; } public override void SetContentUpdatedEventListener(EventHandler listener) diff --git a/TVMediaHub/TVMediaHub.Tizen/ViewModels/MusicTabViewModel.cs b/TVMediaHub/TVMediaHub.Tizen/ViewModels/MusicTabViewModel.cs index ba505da..2709d99 100755 --- a/TVMediaHub/TVMediaHub.Tizen/ViewModels/MusicTabViewModel.cs +++ b/TVMediaHub/TVMediaHub.Tizen/ViewModels/MusicTabViewModel.cs @@ -14,12 +14,74 @@ * limitations under the License. */ +using System.Collections.Generic; +using System.Collections.ObjectModel; +using System.ComponentModel; +using TVMediaHub.Tizen.Models; +using TVMediaHub.Tizen.Utils; + namespace TVMediaHub.Tizen.ViewModels { /// /// A class for ViewModel of Music tab /// - class MusicTabViewModel + public class MusicTabViewModel : INotifyPropertyChanged { + /// + /// Gets or sets the list of music group item + /// + public ObservableCollection MusicList { get; set; } + + private SortOption option = SortOption.Title; + + /// + /// An event that is occurred when property of ViewModel is changed + /// + public event PropertyChangedEventHandler PropertyChanged; + + /// + /// A method for invoking PropertyChanged event + /// + /// The name of property + public void OnPropertyChanged(string name) + { + PropertyChangedEventHandler handler = PropertyChanged; + if (handler != null) + { + handler(this, new PropertyChangedEventArgs(name)); + } + } + + /// + /// A constructor + /// + public MusicTabViewModel() + { + MusicList = new ObservableCollection(); + OnPropertyChanged("MusicList"); + MediaHubImpl.GetInstance.MusicProviderInstance.SetContentUpdatedEventListener((s, e) => + { + DbgPort.D("Content updated"); + }); + } + + /// + /// A method for reading music contents through MusicProvider and updating MusicList + /// + /// A current sort option + private async void ReadMusicList(SortOption option) + { + MusicList.Clear(); + IEnumerable templist = await MediaHubImpl.GetInstance.MusicProviderInstance.ReadAsync(option); + foreach (var group in templist) + { + await MediaHubImpl.GetInstance.MusicProviderInstance.CheckThumbnail(group.Contents); + } + + foreach (var group in templist) + { + MusicList.Add(group); + } + } } }