2. Adding Artist : Details View and related classes.
3. Modifying MediaContent classes.
Change-Id: I66dcf5d5ca6156fac07e4fd6e71e1ce40242b558
Signed-off-by: shivamv <shivam.v2@samsung.com>
{\r
OrderedDictionary albumList = new OrderedDictionary();\r
\r
- SelectArguments arguments = CreateSelectArgument(MEDIA_STORAGE_TYPE_QUERY, AlbumColumns.Name + MEDIA_SORT_ORDER_ASC);\r
- MediaDataReader<Album> dataReader = albumInfo.Select(arguments);\r
+ SelectArguments albumSelectArguments = CreateSelectArgument(MEDIA_STORAGE_TYPE_QUERY, AlbumColumns.Name + MEDIA_SORT_ORDER_ASC);\r
+ MediaDataReader<Album> dataReader = albumInfo.Select(albumSelectArguments);\r
\r
while (dataReader.Read())\r
{\r
Album info = dataReader.Current;\r
- albumList.Add(info.Id, info);\r
+ SelectArguments audioSelectArguments = CreateSelectArgument(MEDIA_STORAGE_TYPE_QUERY, MediaInfoColumns.Title + MEDIA_SORT_ORDER_ASC);\r
+ MediaDataReader<MediaInfo> albumDataReader = albumInfo.SelectMember(info.Id, audioSelectArguments);\r
+ if (albumDataReader.Read())\r
+ albumList.Add(info.Id, info);\r
}\r
Tizen.Log.Debug(AppConstants.LogTag, "Total album retrived from database: " + albumList.Count);\r
dataReader.Dispose();\r
public static OrderedDictionary GetAlbumMemberList(int albumId)\r
{\r
OrderedDictionary mediaList = new OrderedDictionary();\r
- MediaDataReader<MediaInfo> dataReader = albumInfo.SelectMember(albumId);\r
+ SelectArguments audioSelectArguments = CreateSelectArgument(MEDIA_STORAGE_TYPE_QUERY, MediaInfoColumns.Title + MEDIA_SORT_ORDER_ASC);\r
+ MediaDataReader<MediaInfo> dataReader = albumInfo.SelectMember(albumId, audioSelectArguments);\r
\r
while (dataReader.Read())\r
{\r
dataReader.Dispose();\r
return mediaList;\r
}\r
+\r
+ public static string GetAlbumArtPath(int albumId)\r
+ {\r
+ string path = "";\r
+ SelectArguments audioSelectArguments = CreateSelectArgument(MEDIA_STORAGE_TYPE_QUERY, MediaInfoColumns.Title + MEDIA_SORT_ORDER_ASC);\r
+ MediaDataReader<MediaInfo> dataReader = albumInfo.SelectMember(albumId, audioSelectArguments);\r
+ while (dataReader.Read())\r
+ {\r
+ MediaInfo info = dataReader.Current;\r
+ if (!string.IsNullOrEmpty(info.ThumbnailPath))\r
+ path = info.ThumbnailPath;\r
+ }\r
+ dataReader.Dispose();\r
+ return path;\r
+ }\r
}\r
}\r
{\r
List<string> artistList = new List<string>();\r
\r
- SelectArguments arguments = CreateSelectArgument(MEDIA_STORAGE_TYPE_QUERY, MediaInfoColumns.Artist + MEDIA_SORT_ORDER_ASC);\r
- MediaDataReader<string> dataReader = mediaInfo.SelectGroupBy(MediaInfoColumnKey.Artist, arguments);\r
+ SelectArguments artistSelectArguments = CreateSelectArgument(MEDIA_STORAGE_TYPE_QUERY, MediaInfoColumns.Artist + MEDIA_SORT_ORDER_ASC);\r
+ MediaDataReader<string> dataReader = mediaInfo.SelectGroupBy(MediaInfoColumnKey.Artist, artistSelectArguments);\r
\r
while (dataReader.Read())\r
{\r
{\r
OrderedDictionary albumList = new OrderedDictionary();\r
string expression = MEDIA_STORAGE_TYPE_QUERY + "AND " + AlbumColumns.Artist + "=\"" + artistName + "\"";\r
- SelectArguments arguments = CreateSelectArgument(expression, AlbumColumns.Name + MEDIA_SORT_ORDER_ASC);\r
- MediaDataReader<Album> dataReader = albumInfo.Select(arguments);\r
+ SelectArguments albumSelectArguments = CreateSelectArgument(expression, AlbumColumns.Name + MEDIA_SORT_ORDER_ASC);\r
+ MediaDataReader<Album> dataReader = albumInfo.Select(albumSelectArguments);\r
\r
while (dataReader.Read())\r
{\r
Album info = dataReader.Current;\r
- albumList.Add(info.Id, info);\r
+ SelectArguments audioSelectArguments = CreateSelectArgument(MEDIA_STORAGE_TYPE_QUERY, MediaInfoColumns.Title + MEDIA_SORT_ORDER_ASC);\r
+ MediaDataReader<MediaInfo> albumDataReader = albumInfo.SelectMember(info.Id, audioSelectArguments);\r
+ if(albumDataReader.Read())\r
+ albumList.Add(info.Id, info);\r
}\r
dataReader.Dispose();\r
+ Tizen.Log.Debug(AppConstants.LogTag, "Total Albums retrived from Artist: " + albumList.Count);\r
return albumList;\r
}\r
\r
- public static int GetAlblumCountForArtist(string artistName)\r
+ public static OrderedDictionary GetTrackListForArtist(string artistName)\r
+ {\r
+ OrderedDictionary mediaList = new OrderedDictionary();\r
+ string expression = MEDIA_STORAGE_TYPE_QUERY + "AND " + AlbumColumns.Artist + "=\"" + artistName + "\"";\r
+ SelectArguments albumSelectArguments = CreateSelectArgument(expression, AlbumColumns.Name + MEDIA_SORT_ORDER_ASC);\r
+ MediaDataReader<Album> dataReader = albumInfo.Select(albumSelectArguments);\r
+\r
+ while (dataReader.Read())\r
+ {\r
+ Album info = dataReader.Current;\r
+ SelectArguments audioSelectArguments = CreateSelectArgument(MEDIA_STORAGE_TYPE_QUERY, MediaInfoColumns.Title + MEDIA_SORT_ORDER_ASC);\r
+ MediaDataReader<MediaInfo> albumDataReader = albumInfo.SelectMember(info.Id, audioSelectArguments);\r
+\r
+ while (albumDataReader.Read())\r
+ {\r
+ MediaInfo mediaInfo = albumDataReader.Current;\r
+ mediaList.Add(mediaInfo.Id, mediaInfo);\r
+ }\r
+ albumDataReader.Dispose();\r
+ }\r
+ dataReader.Dispose();\r
+ Tizen.Log.Debug(AppConstants.LogTag, "Total track retrived from Artist: " + mediaList.Count);\r
+ return mediaList;\r
+ }\r
+\r
+ public static string GetAlbumArtPathForArtist(string artistName)\r
+ {\r
+ string expression = MEDIA_STORAGE_TYPE_QUERY + "AND " + AlbumColumns.Artist + "=\"" + artistName + "\"";\r
+ SelectArguments albumSelectArguments = CreateSelectArgument(expression, AlbumColumns.Name + MEDIA_SORT_ORDER_ASC);\r
+ MediaDataReader<Album> dataReader = albumInfo.Select(albumSelectArguments);\r
+ string albumArtPath = "";\r
+\r
+ while (dataReader.Read())\r
+ {\r
+ Album info = dataReader.Current;\r
+ string path = "";\r
+ if (!string.IsNullOrEmpty(info.AlbumArtPath))\r
+ path = info.AlbumArtPath;\r
+ else\r
+ path = GetAlbumArtPath(info.Id);\r
+ if (!string.IsNullOrEmpty(path))\r
+ albumArtPath = path;\r
+ }\r
+ dataReader.Dispose();\r
+ return albumArtPath;\r
+ }\r
+\r
+ public static int GetAlbumCountForArtist(string artistName)\r
{\r
string expression = MEDIA_STORAGE_TYPE_QUERY + "AND " + AlbumColumns.Artist + "=\"" + artistName+"\"";\r
- CountArguments arguments = CreateCountArgument(expression);\r
+ int count = 0;\r
+\r
+ SelectArguments albumSelectArguments = CreateSelectArgument(expression, AlbumColumns.Name + MEDIA_SORT_ORDER_ASC);\r
+ MediaDataReader<Album> dataReader = albumInfo.Select(albumSelectArguments);\r
+\r
+ while (dataReader.Read())\r
+ {\r
+ Album info = dataReader.Current;\r
+ SelectArguments audioSelectArguments = CreateSelectArgument(MEDIA_STORAGE_TYPE_QUERY, MediaInfoColumns.Title + MEDIA_SORT_ORDER_ASC);\r
+ MediaDataReader<MediaInfo> albumDataReader = albumInfo.SelectMember(info.Id, audioSelectArguments);\r
+ if (albumDataReader.Read())\r
+ count++;\r
+ }\r
+ dataReader.Dispose();\r
+ return count;\r
+ }\r
+\r
+ public static int GetMediaCountForArtist(string artistName)\r
+ {\r
+ string expression = MEDIA_STORAGE_TYPE_QUERY + "AND " + MediaInfoColumns.Artist + "=\"" + artistName+"\"";\r
+ CountArguments audioCountArguments = CreateCountArgument(expression);\r
int count = 0;\r
try\r
{\r
- count = albumInfo.Count(arguments);\r
+ count = mediaInfo.CountMedia(audioCountArguments);\r
}\r
catch (ObjectDisposedException ex)\r
{\r
{\r
class MusicAlbum : PropertyNotifier\r
{\r
+ public MusicAlbum()\r
+ {\r
+ //this is required for Activator.CreateInstance in ListViewModel\r
+ }\r
+\r
public MusicAlbum(Tizen.Content.MediaContent.Album album)\r
{\r
AlbumName = album.Name;\r
ArtistName = album.Artist;\r
Id = album.Id;\r
- AlbumArtPath = album.AlbumArtPath;\r
+ string text = album.AlbumArtPath;\r
+ if (string.IsNullOrEmpty(album.AlbumArtPath))\r
+ {\r
+ text = AlbumDataProvider.GetAlbumArtFromTracks(album.Id);\r
+ }\r
+ AlbumArtPath = text;\r
}\r
\r
private string albumName;\r
\r
public static OrderedDictionary GetAlbumTrackList(int albumId)\r
{\r
- OrderedDictionary albumMediaList= Contents.GetAlbumMemberList(albumId);\r
- return albumMediaList;\r
+ return Contents.GetAlbumMemberList(albumId);\r
+ }\r
+\r
+ public static string GetAlbumArtFromTracks(int albumId)\r
+ {\r
+ return Contents.GetAlbumArtPath(albumId);\r
}\r
}\r
}\r
--- /dev/null
+using System;
+using MusicPlayer.Common;
+
+namespace MusicPlayer.Models
+{
+ class Artist : PropertyNotifier
+ {
+ public Artist()
+ {
+ //this is required for Activator.CreateInstance in ListViewModel
+ }
+
+ public Artist(string artistName)
+ {
+ ArtistName = artistName;
+ AlbumCount = ArtistDataProvider.GetArtistAlbumCount(artistName).ToString();
+ TrackCount = ArtistDataProvider.GetArtistTrackCount(artistName).ToString();
+ TotalCount = AlbumCount + " / " + TrackCount;
+ AlbumArtPath = ArtistDataProvider.GetArtistAlbumArtPath(artistName);
+ }
+
+ private string artistName;
+
+ public string ArtistName
+ {
+ get => artistName;
+ set
+ {
+ string text = string.IsNullOrEmpty(value) ? "Unknown" : value;
+ SetProperty(ref artistName, text);
+ }
+ }
+
+ private string albumCount;
+
+ public string AlbumCount
+ {
+ get => albumCount;
+ set
+ {
+ string text = string.Equals(value, "1") ? " album" : " albums";
+ SetProperty(ref albumCount, value + text);
+ }
+ }
+
+ private string trackCount;
+
+ public string TrackCount
+ {
+ get => trackCount;
+ set
+ {
+ string text = string.Equals(value, "1") ? " track" : " tracks";
+ SetProperty(ref trackCount, value + text);
+ }
+ }
+
+ private string totalCount;
+
+ public string TotalCount
+ {
+ get => totalCount;
+ set => SetProperty(ref totalCount, value);
+ }
+
+ private string albumArtPath;
+
+ public string AlbumArtPath
+ {
+ get => albumArtPath;
+ set
+ {
+ string thumb = string.IsNullOrEmpty(value) ? Resources.GetImagePath() + "thumbnail.png" : value;
+ SetProperty(ref albumArtPath, thumb);
+ }
+ }
+ }
+}
--- /dev/null
+using System.Collections.Specialized;
+using System.Collections.Generic;
+using MusicPlayer.Media;
+
+namespace MusicPlayer.Models
+{
+ public static class ArtistDataProvider
+ {
+ private static List<string> artistsList;
+
+ static ArtistDataProvider()
+ {
+ artistsList = Contents.GetArtistList();
+ Contents.MusicItemUpdate += OnMusicItemUpdate;
+ Contents.MusicDBUpdate += OnMusicDatabaseUpdate;
+ }
+
+ private static void OnMusicDatabaseUpdate(object sender, MusicDBUpdateEventArgs e)
+ {
+ artistsList = Contents.GetArtistList();
+ // TODO implement database update event handler
+ return;
+ }
+
+ private static void OnMusicItemUpdate(object sender, MusicItemUpdateEventArgs e)
+ {
+ // TODO implement database item update event handler
+ return;
+ }
+
+ public static List<string> CurrentArtistList()
+ {
+ return artistsList;
+ }
+
+ public static int GetArtistTrackCount(string artistName)
+ {
+ return Contents.GetMediaCountForArtist(artistName);
+ }
+
+ public static int GetArtistAlbumCount(string artistName)
+ {
+ return Contents.GetAlbumCountForArtist(artistName);
+ }
+
+ public static string GetArtistAlbumArtPath(string artistName)
+ {
+ return Contents.GetAlbumArtPathForArtist(artistName);
+ }
+
+ public static OrderedDictionary GetArtistAlbumList(string artistName)
+ {
+ return Contents.GetAlbumListForArtist(artistName);
+ }
+
+ public static OrderedDictionary GetArtistTrackList(string artistName)
+ {
+ return Contents.GetTrackListForArtist(artistName);
+ }
+ }
+}
\ No newline at end of file
--- /dev/null
+using System;
+using System.Collections.Generic;
+using System.Text;
+using MusicPlayer.Common;
+using System.Collections.ObjectModel;
+
+namespace MusicPlayer.Models
+{
+ class ArtistDetailAlbum: ObservableCollection <Track>
+ {
+ public ArtistDetailAlbum()
+ {
+ //this is required for Activator.CreateInstance in ListViewModel
+ }
+
+ public ArtistDetailAlbum(MusicAlbum album)
+ {
+ AlbumArtPath = album.AlbumArtPath;
+ AlbumName = album.AlbumName;
+ }
+
+ public string AlbumName { get; set; }
+
+ public string AlbumArtPath { get; set; }
+ }
+}
{\r
class Track : PropertyNotifier\r
{\r
+ public Track()\r
+ {\r
+ //this is required for Activator.CreateInstance in ListViewModel\r
+ }\r
+\r
public Track(Tizen.Content.MediaContent.AudioInfo audioInfo)\r
{\r
TrackTitle = audioInfo.Title;\r
\r
public AlbumDetailViewModel getDetailViewModel(MusicAlbum musicAlbum)\r
{\r
- if(!albumDetailViewModel)\r
+ if(albumDetailViewModel == null)\r
albumDetailViewModel = new AlbumDetailViewModel(musicAlbum);\r
else if (albumDetailViewModel.Id != musicAlbum.Id)\r
albumDetailViewModel = new AlbumDetailViewModel(musicAlbum);\r
--- /dev/null
+using System.Collections.Specialized;
+using MusicPlayer.Models;
+using MusicPlayer.Common;
+
+namespace MusicPlayer.ViewModels
+{
+ using Album = Tizen.Content.MediaContent.Album;
+ using AudioInfo = Tizen.Content.MediaContent.AudioInfo;
+ class ArtistDetailViewModel : PropertyNotifier
+ {
+
+ public ArtistDetailViewModel(Artist artist)
+ {
+ ArtistName = artist.ArtistName;
+ TotalCount = artist.TotalCount;
+ string text = string.Equals(ArtistName, "Unknown") ? "" : ArtistName;
+
+ OrderedDictionary albumList = ArtistDataProvider.GetArtistAlbumList(text);
+ albumListViewModel = new ListViewModel<MusicAlbum>();
+ albumListViewModel.CreateData<Album>(albumList);
+
+ OrderedDictionary trackList = ArtistDataProvider.GetArtistTrackList(text);
+ trackListViewModel = new ListViewModel<Track>();
+ trackListViewModel.CreateData<AudioInfo>(trackList);
+
+ groupListViewModel = new ListViewModel<ArtistDetailAlbum>();
+
+ foreach(MusicAlbum album in albumListViewModel)
+ {
+ ArtistDetailAlbum artistAlbum = new ArtistDetailAlbum(album);
+ OrderedDictionary albumTrackList = AlbumDataProvider.GetAlbumTrackList(album.Id);
+ ListViewModel<Track> albumTrackListViewModel = new ListViewModel<Track>();
+ albumTrackListViewModel.CreateData<AudioInfo>(albumTrackList);
+ foreach (Track track in albumTrackListViewModel)
+ artistAlbum.Add(track);
+ groupListViewModel.Add(artistAlbum);
+ }
+ }
+
+ private string artistName;
+
+ public string ArtistName
+ {
+ get => artistName;
+ set => SetProperty(ref artistName, value);
+ }
+
+ private string totalCount;
+
+ public string TotalCount
+ {
+ get => totalCount;
+ set => SetProperty(ref totalCount, value);
+ }
+
+ private readonly ListViewModel<ArtistDetailAlbum> groupListViewModel;
+ public ListViewModel<ArtistDetailAlbum> GroupListViewModel => groupListViewModel;
+
+ private readonly ListViewModel<MusicAlbum> albumListViewModel;
+ public ListViewModel<MusicAlbum> AlbumListViewModel => albumListViewModel;
+
+ private readonly ListViewModel<Track> trackListViewModel;
+ public ListViewModel<Track> TrackListViewModel => trackListViewModel;
+ }
+}
--- /dev/null
+using System.Collections.Specialized;
+using System.Collections.Generic;
+using MusicPlayer.Models;
+using MusicPlayer.Common;
+
+namespace MusicPlayer.ViewModels
+{
+ class ArtistViewModel : PropertyNotifier
+ {
+ private ArtistDetailViewModel artistDetailViewModel;
+
+ public ArtistViewModel()
+ {
+ List<string> artistList = ArtistDataProvider.CurrentArtistList();
+ listViewModel = new ListViewModel<Artist>();
+ listViewModel.CreateData<string>(artistList);
+ listViewModel.CollectionChanged += OnArtistListChanges;
+ ArtistCount = listViewModel.Count.ToString();
+ }
+
+ private void OnArtistListChanges(object sender, NotifyCollectionChangedEventArgs e)
+ {
+ artistCount = listViewModel.Count.ToString();
+ }
+
+ public ArtistDetailViewModel getDetailViewModel(Artist artist)
+ {
+ if (artistDetailViewModel == null)
+ artistDetailViewModel = new ArtistDetailViewModel(artist);
+ else if (artistDetailViewModel.ArtistName != artist.ArtistName)
+ artistDetailViewModel = new ArtistDetailViewModel(artist);
+ return artistDetailViewModel;
+ }
+
+ private ListViewModel<Artist> listViewModel;
+
+ public ListViewModel<Artist> ListViewModel
+ {
+ get => listViewModel;
+ }
+
+ private string artistCount;
+
+ public string ArtistCount
+ {
+ get => artistCount;
+ set
+ {
+ string text = string.Equals(value, "1") ? " artist" : " artists";
+ SetProperty(ref artistCount, value + text);
+ }
+ }
+ }
+}
\ No newline at end of file
\r
}\r
\r
- private Button CreatButton(string url, int x, int y)\r
+ private Button CreateButton(string url, int x, int y)\r
{\r
ButtonStyle buttonStyle = new ButtonStyle()\r
{\r
trackCountLabel.SetBinding(TextLabel.TextProperty, "TotalTracks");\r
controlsView.Add(trackCountLabel);\r
\r
- playAllIcon = CreatButton(Resources.GetImagePath() + "playing_queue.png", Window.Instance.WindowSize.Width / 2 - LayoutPadding - IconSize, ControlViewMargin); // The required png waas not available. So temporarily using this.\r
+ playAllIcon = CreateButton(Resources.GetImagePath() + "playlist_active.png.png", Window.Instance.WindowSize.Width / 2 - LayoutPadding - IconSize, ControlViewMargin);\r
playAllIcon.Margin = new Extents(40, 0, 0, 0);\r
controlsView.Add(playAllIcon);\r
\r
- shuffleAndPlayAllIcon = CreatButton(Resources.GetImagePath() + "shuffle_on.png", Window.Instance.WindowSize.Width / 2 - LayoutPadding - 2 * IconSize - 40, ControlViewMargin);\r
+ shuffleAndPlayAllIcon = CreateButton(Resources.GetImagePath() + "shuffle_on.png", Window.Instance.WindowSize.Width / 2 - LayoutPadding - 2 * IconSize - 40, ControlViewMargin);\r
playAllIcon.Margin = new Extents(32, 0, 0, 0);\r
controlsView.Add(shuffleAndPlayAllIcon);\r
\r
--- /dev/null
+using Tizen.NUI.Components;
+using Tizen.NUI.BaseComponents;
+using Tizen.NUI;
+using MusicPlayer.Common;
+
+namespace MusicPlayer.Views
+{
+ class ArtistDetailGroupLayout : RecyclerViewItem
+ {
+ private static int Width = 1792;
+ private static int Height = 108;
+
+ private const int IconSize = 64;
+ private const int LayoutPadding = 32;
+ private const int SeperatorHeight = 1;
+ private const int LeftPadding = 64;
+ private const int x = 0;
+
+ private View itemSeperator;
+ private TextLabel titleLabel;
+ private ImageView icon;
+
+ public ArtistDetailGroupLayout(int width = 1792, int height = 108) : base()
+ {
+ base.OnInitialize();
+ base.IsCreateByXaml = true;
+ Width = width;
+ Height = height;
+ WidthSpecification = Width;
+ HeightSpecification = Height;
+
+ // to show the rounded rect of the bg
+ BackgroundColor = Color.Transparent;
+
+ icon = CreateIcon();
+ titleLabel = CreateTitleLabel();
+ itemSeperator = CreateItemSeparator();
+ IsCreateByXaml = true;
+ }
+
+ private ImageView CreateIcon()
+ {
+ ImageView icon = new ImageView()
+ {
+ WidthSpecification = IconSize,
+ HeightSpecification = IconSize,
+ IsCreateByXaml = true,
+ Position2D = new Position2D(x, (Height / 2) - (IconSize / 2)),
+ };
+ base.Add(icon);
+ return icon;
+ }
+
+ private View CreateItemSeparator()
+ {
+ View itemSeperator = new View()
+ {
+ WidthSpecification = (Width - (2 * LeftPadding)),
+ HeightSpecification = SeperatorHeight,
+ ExcludeLayouting = true,
+ Position2D = new Position2D(x, Height - SeperatorHeight),
+ BackgroundColor = UIColors.ItemSeperator,
+ };
+ base.Add(itemSeperator);
+ return itemSeperator;
+ }
+
+ private TextLabel CreateTitleLabel()
+ {
+ TextLabel titleLabel = new TextLabel()
+ {
+ WidthSpecification = (Width - (2 * LeftPadding) - IconSize - LayoutPadding),
+ HeightSpecification = 40,
+ TextColor = UIColors.HEX001447,
+ PixelSize = 32,
+ FontFamily = "BreezeSans",
+ VerticalAlignment = VerticalAlignment.Center,
+ IsCreateByXaml = true,
+ Position2D = new Position2D(x + IconSize + LayoutPadding, 34),
+ };
+ base.Add(titleLabel);
+ return titleLabel;
+ }
+
+ public ImageView Icon
+ {
+ get => icon;
+ }
+
+ public TextLabel TitleLabel
+ {
+ get => titleLabel;
+ }
+
+ protected override void Dispose(DisposeTypes type)
+ {
+ if (Disposed)
+ {
+ return;
+ }
+ if (type == DisposeTypes.Explicit)
+ {
+ base.Remove(itemSeperator);
+ itemSeperator?.Dispose();
+ itemSeperator = null;
+
+ base.Remove(icon);
+ icon?.Dispose();
+ icon = null;
+
+ base.Remove(titleLabel);
+ titleLabel?.Dispose();
+ titleLabel = null;
+ }
+ base.Dispose(type);
+ }
+ }
+}
--- /dev/null
+using Tizen.NUI.Components;
+using Tizen.NUI.BaseComponents;
+using Tizen.NUI;
+using MusicPlayer.Common;
+
+namespace MusicPlayer.Views
+{
+ class ArtistDetailItemLayout : RecyclerViewItem
+ {
+ private static int Width = 1792;
+ private static int Height = 108;
+
+ private const int LayoutPadding = 32;
+ private const int SeperatorHeight = 1;
+ private const int LeftPadding = 64;
+ private const int x = 0;
+
+ private View itemSeperator;
+ private TextLabel titleLabel;
+ private TextLabel extraLabel;
+
+ public ArtistDetailItemLayout(int width = 1792, int height = 108) : base()
+ {
+ base.OnInitialize();
+ base.IsCreateByXaml = true;
+ Width = width;
+ Height = height;
+ WidthSpecification = Width;
+ HeightSpecification = Height;
+
+ // to show the rounded rect of the bg
+ BackgroundColor = Color.Transparent;
+
+ titleLabel = CreateTitleLabel();
+ extraLabel = CreateExtraLabel();
+ itemSeperator = CreateItemSeparator();
+ IsCreateByXaml = true;
+ }
+
+ private View CreateItemSeparator()
+ {
+ View itemSeperator = new View()
+ {
+ WidthSpecification = (Width - (2 * LeftPadding)),
+ HeightSpecification = SeperatorHeight,
+ ExcludeLayouting = true,
+ Position2D = new Position2D(x, Height - SeperatorHeight),
+ BackgroundColor = UIColors.ItemSeperator,
+ };
+ base.Add(itemSeperator);
+ return itemSeperator;
+ }
+
+ private TextLabel CreateTitleLabel()
+ {
+ TextLabel titleLabel = new TextLabel()
+ {
+ WidthSpecification = 1272,
+ HeightSpecification = 40,
+ TextColor = UIColors.HEX001447,
+ PixelSize = 32,
+ FontFamily = "BreezeSans",
+ VerticalAlignment = VerticalAlignment.Center,
+ IsCreateByXaml = true,
+ Position2D = new Position2D(x, 34),
+ };
+ base.Add(titleLabel);
+ return titleLabel;
+ }
+
+ private TextLabel CreateExtraLabel()
+ {
+ TextLabel extraLabel = new TextLabel()
+ {
+ WidthSpecification = 360,
+ HeightSpecification = 36,
+ TextColor = UIColors.HEX001447,
+ PixelSize = 28,
+ FontFamily = "BreezeSans",
+ VerticalAlignment = VerticalAlignment.Center,
+ HorizontalAlignment = HorizontalAlignment.End,
+ IsCreateByXaml = true,
+ Position2D = new Position2D((x + 1272 + LayoutPadding), 36)
+ };
+ base.Add(extraLabel);
+ return extraLabel;
+ }
+
+ public TextLabel TitleLabel
+ {
+ get => titleLabel;
+ }
+
+ public TextLabel ExtraLabel
+ {
+ get => extraLabel;
+ }
+
+ protected override void Dispose(DisposeTypes type)
+ {
+ if (Disposed)
+ {
+ return;
+ }
+ if (type == DisposeTypes.Explicit)
+ {
+ base.Remove(itemSeperator);
+ itemSeperator?.Dispose();
+ itemSeperator = null;
+
+ base.Remove(titleLabel);
+ titleLabel?.Dispose();
+ titleLabel = null;
+
+ base.Remove(extraLabel);
+ extraLabel?.Dispose();
+ extraLabel = null;
+ }
+ base.Dispose(type);
+ }
+ }
+}
--- /dev/null
+using MusicPlayer.ViewModels;
+using Tizen.NUI.Components;
+using Tizen.NUI.BaseComponents;
+using Tizen.NUI;
+using Tizen.NUI.Binding;
+using MusicPlayer.Common;
+using MusicPlayer.Models;
+
+namespace MusicPlayer.Views
+{
+ class ArtistDetailView : View //BaseContentView
+ {
+ private const int LayoutPadding = 64;
+ private const int IconSize = 48;
+
+ private BaseView baseView;
+ private View contentView;
+ private View topView;
+ private TextLabel totalCountLabel;
+ private Button playAllIcon; // TODO need to implement playall feature
+ private Button shuffleAndPlayAllIcon; // TODO need to implement playlist manager
+ private CollectionView collectionView;
+
+ private ArtistDetailViewModel viewModel;
+
+ public ArtistDetailView(ArtistDetailViewModel viewModel) : base()
+ {
+ this.viewModel = viewModel;
+ BindingContext = viewModel;
+ BackgroundColor = UIColors.HEXEEEFF1;
+ WidthResizePolicy = ResizePolicyType.FillToParent;
+ HeightResizePolicy = ResizePolicyType.FillToParent;
+
+ //TODO need to change this part after implementation of Command Interface
+ baseView = new BaseView()
+ {
+ Title = viewModel.ArtistName,
+ BackButton = true,
+ MoreButton = true,
+ SearchButton = true,
+ BackgroundColor = UIColors.HEXEEEFF1,
+ };
+ base.Add(baseView);
+ contentView = new View()
+ {
+ WidthSpecification = LayoutParamPolicies.MatchParent,
+ HeightSpecification = 876,
+ Layout = new FlexLayout()
+ {
+ Direction = FlexLayout.FlexDirection.Column,
+ Padding = new Extents(LayoutPadding, LayoutPadding, 0, 0),
+ },
+ };
+ baseView.SetContent = contentView;
+
+ topView = CreateTopView();
+ AddTitle();
+ AddButtons();
+ collectionView = AddCollectionView();
+ }
+
+ private void OnTrackSelection(object sender, SelectionChangedEventArgs e)
+ {
+
+ }
+
+ private Button CreateButton(string url, int x, int y)
+ {
+ ButtonStyle buttonStyle = new ButtonStyle()
+ {
+ Icon = new ImageViewStyle()
+ {
+ ResourceUrl = url,
+ },
+ IsSelectable = false,
+ IsEnabled = true,
+ };
+
+ Button button = new Button(buttonStyle)
+ {
+ Size2D = new Size2D(IconSize, IconSize),
+ Position2D = new Position2D(x, y),
+ };
+ return button;
+ }
+
+ private View CreateTopView()
+ {
+ View topView = new View()
+ {
+ BackgroundColor = UIColors.HEXEEEFF1,
+ Size2D = new Size2D(Window.Instance.WindowSize.Width - 2 * LayoutPadding, 60),
+ };
+ contentView.Add(topView);
+ return topView;
+ }
+
+ private void AddTitle()
+ {
+ totalCountLabel = new TextLabel()
+ {
+ Size2D = new Size2D(1624, 36),
+ Position2D = new Position2D(0, 12),
+ PixelSize = 28,
+ Text = "TOTAL COUNT",
+ TextColor = UIColors.HEX001447,
+ VerticalAlignment = VerticalAlignment.Center,
+ FontFamily = "BreezeSans",
+ IsCreateByXaml = true,
+ };
+ topView.Add(totalCountLabel);
+ totalCountLabel.SetBinding(TextLabel.TextProperty, "TotalCount");
+ }
+
+ private void AddButtons()
+ {
+ playAllIcon = CreateButton(Resources.GetImagePath() + "playlist_active.png", Window.Instance.WindowSize.Width - 2 * LayoutPadding - IconSize, 6);
+ playAllIcon.Margin = new Extents(40, 0, 0, 0);
+ topView.Add(playAllIcon);
+
+ shuffleAndPlayAllIcon = CreateButton(Resources.GetImagePath() + "shuffle_on.png", Window.Instance.WindowSize.Width - 2 * LayoutPadding - 2 * IconSize - 40, 6);
+ playAllIcon.Margin = new Extents(32, 0, 0, 0);
+ topView.Add(shuffleAndPlayAllIcon);
+ }
+
+ private CollectionView AddCollectionView()
+ {
+ CollectionView collectionView = new CollectionView()
+ {
+ Size2D = new Size2D(1792, 108),
+ BackgroundImage = Resources.GetImagePath() + "list_view_bg.png",
+ ItemsLayouter = new LinearLayouter(),
+ ItemTemplate = new DataTemplate(() =>
+ {
+ ArtistDetailItemLayout layout = new ArtistDetailItemLayout();
+ layout.TitleLabel.SetBinding(TextLabel.TextProperty, "TrackTitle");
+ layout.ExtraLabel.SetBinding(TextLabel.TextProperty, "Duration");
+ return layout;
+ }),
+ GroupHeaderTemplate = new DataTemplate(() =>
+ {
+ ArtistDetailGroupLayout group = new ArtistDetailGroupLayout();
+ group.Icon.SetBinding(ImageView.ResourceUrlProperty, "AlbumArtPath");
+ group.TitleLabel.SetBinding(TextLabel.TextProperty, "AlbumName");
+ return group;
+ }),
+ IsGrouped = true,
+ ScrollingDirection = ScrollableBase.Direction.Vertical,
+ HeightSpecification = LayoutParamPolicies.WrapContent,
+ SelectionMode = ItemSelectionMode.Single,
+ };
+ contentView.Add(collectionView);
+ FlexLayout.SetFlexGrow(collectionView, 1);
+ FlexLayout.SetFlexShrink(collectionView, 1);
+ collectionView.ItemsSource = viewModel.GroupListViewModel;
+ collectionView.SelectionChanged += OnTrackSelection;
+ return collectionView;
+ }
+ }
+}
--- /dev/null
+using MusicPlayer.ViewModels;
+using Tizen.NUI.Components;
+using Tizen.NUI.BaseComponents;
+using Tizen.NUI;
+using Tizen.NUI.Binding;
+using MusicPlayer.Common;
+using MusicPlayer.Models;
+
+namespace MusicPlayer.Views
+{
+ class ArtistView : BaseContentView
+ {
+ private ArtistViewModel viewModel;
+ private TextLabel artistCountLabel;
+
+ public ArtistView(ArtistViewModel viewModel)
+ {
+ this.viewModel = viewModel;
+ BindingContext = viewModel;
+ collectionView.ItemsSource = viewModel.ListViewModel;
+ collectionView.ItemTemplate = new DataTemplate(() =>
+ {
+ ListItemLayout layout = new ListItemLayout();
+ layout.Icon.SetBinding(ImageView.ResourceUrlProperty, "AlbumArtPath");
+ layout.TitleLabel.SetBinding(TextLabel.TextProperty, "ArtistName");
+ layout.SubtitleLabel.SetBinding(TextLabel.TextProperty, "TotalCount");
+ return layout;
+ });
+ collectionView.ScrollingDirection = ScrollableBase.Direction.Vertical;
+ collectionView.WidthSpecification = LayoutParamPolicies.WrapContent;
+ collectionView.SelectionMode = ItemSelectionMode.Single;
+ collectionView.SelectionChanged += OnArtistSelection;
+
+ artistCountLabel = new TextLabel()
+ {
+ PixelSize = 28,
+ Text = "ARTIST COUNT",
+ TextColor = UIColors.HEX001447,
+ VerticalAlignment = VerticalAlignment.Center,
+ FontFamily = "BreezeSans",
+ IsCreateByXaml = true,
+ };
+ titleView.Add(artistCountLabel);
+ artistCountLabel.SetBinding(TextLabel.TextProperty, "ArtistCount");
+ RelativeLayout.SetLeftTarget(artistCountLabel, titleView);
+ RelativeLayout.SetLeftRelativeOffset(artistCountLabel, 1.0f);
+ RelativeLayout.SetRightRelativeOffset(artistCountLabel, 0.0f);
+ RelativeLayout.SetFillHorizontal(artistCountLabel, true);
+ }
+ private void OnArtistSelection(object sender, SelectionChangedEventArgs e)
+ {
+ Artist currentArtist = (Artist)collectionView.SelectedItem;
+ ArtistDetailView view = new ArtistDetailView(viewModel.getDetailViewModel(currentArtist));
+ Window.Instance.Add(view);
+ }
+ protected override void Dispose(DisposeTypes type)
+ {
+ if (Disposed)
+ {
+ return;
+ }
+ if (type == DisposeTypes.Explicit)
+ {
+ titleView.Remove(artistCountLabel);
+ artistCountLabel.Dispose();
+ artistCountLabel = null;
+ }
+ base.Dispose(type);
+ }
+ }
+}
\ No newline at end of file