2.Modifying some files to remove redundancy.
Change-Id: Ief6afe9a0bb2b61f17742117f135541bbd7fa0d7
Signed-off-by: shivamv <shivam.v2@samsung.com>
{\r
return albumInfo.CountMember(albumId);\r
}\r
+\r
+ public static OrderedDictionary GetAlbumMemberList(int albumId)\r
+ {\r
+ OrderedDictionary mediaList = new OrderedDictionary();\r
+ MediaDataReader<MediaInfo> dataReader = albumInfo.SelectMember(albumId);\r
+\r
+ while (dataReader.Read())\r
+ {\r
+ MediaInfo info = dataReader.Current;\r
+ mediaList.Add(info.Id, info);\r
+ }\r
+ Tizen.Log.Debug(AppConstants.LogTag, "Total track retrived from currentAlbum: " + mediaList.Count);\r
+ dataReader.Dispose();\r
+ return mediaList;\r
+ }\r
}\r
}\r
--- /dev/null
+using MusicPlayer.Common;\r
+\r
+namespace MusicPlayer.Models\r
+{\r
+ class MusicAlbum : PropertyNotifier\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
+ }\r
+\r
+ private string albumName;\r
+\r
+ public string AlbumName\r
+ {\r
+ get => albumName;\r
+ set\r
+ {\r
+ string text = string.IsNullOrEmpty(value) ? "Unknown" : value;\r
+ SetProperty(ref albumName, text);\r
+ }\r
+ }\r
+\r
+ private string artistName;\r
+\r
+ public string ArtistName\r
+ {\r
+ get => artistName;\r
+ set\r
+ {\r
+ string text = string.IsNullOrEmpty(value) ? "Unknown" : value;\r
+ SetProperty(ref artistName, text);\r
+ }\r
+ }\r
+\r
+ private int id;\r
+\r
+ public int Id\r
+ {\r
+ get => id;\r
+ set => id = value;\r
+ }\r
+\r
+ private string albumArtPath;\r
+\r
+ public string AlbumArtPath\r
+ {\r
+ get => albumArtPath;\r
+ set\r
+ {\r
+ string thumb = string.IsNullOrEmpty(value) ? Resources.GetImagePath() + "thumbnail.png" : value;\r
+ SetProperty(ref albumArtPath, thumb);\r
+ }\r
+ }\r
+ }\r
+}\r
--- /dev/null
+using System.Collections.Specialized;\r
+using MusicPlayer.Media;\r
+\r
+namespace MusicPlayer.Models\r
+{\r
+ public static class AlbumDataProvider\r
+ {\r
+ private static OrderedDictionary albumsList;\r
+\r
+ static AlbumDataProvider()\r
+ {\r
+ albumsList = Contents.GetAlbumList();\r
+ Contents.MusicItemUpdate += OnMusicItemUpdate;\r
+ Contents.MusicDBUpdate += OnMusicDatabaseUpdate;\r
+ }\r
+\r
+ private static void OnMusicDatabaseUpdate(object sender, MusicDBUpdateEventArgs e)\r
+ {\r
+ albumsList = Contents.GetAlbumList();\r
+ // TODO implement database update event handler\r
+ return;\r
+ }\r
+\r
+ private static void OnMusicItemUpdate(object sender, MusicItemUpdateEventArgs e)\r
+ {\r
+ // TODO implement database item update event handler\r
+ return;\r
+ }\r
+\r
+ public static OrderedDictionary CurrentAlbumList()\r
+ {\r
+ return albumsList;\r
+ }\r
+\r
+ public static OrderedDictionary GetAlbumTrackList(int albumId)\r
+ {\r
+ OrderedDictionary albumMediaList= Contents.GetAlbumMemberList(albumId);\r
+ return albumMediaList;\r
+ }\r
+ }\r
+}\r
currentTrack = value;
TrackName = currentTrack.TrackTitle;
TrackArtist = currentTrack.ArtistName;
- TrackLength = TimeSpan.FromMilliseconds(currentTrack.Duration).ToString(AppConstants.TimeFormat);
+ TrackLength = currentTrack.Duration;
PlayingTime = TimeSpan.FromMilliseconds(0).ToString(AppConstants.TimeFormat);
ThumbnailPath = currentTrack.ThumbnailPath;
PlayingStatus = PlayingStatus.None;
-using MusicPlayer.Common;\r
+using System;\r
+using MusicPlayer.Common;\r
\r
namespace MusicPlayer.Models\r
{\r
class Track : PropertyNotifier\r
{\r
- private string title;\r
- private string album;\r
- private string id;\r
- private string artist;\r
- private int duration;\r
- private string thumbnailPath;\r
- private string filePath;\r
-\r
public Track(Tizen.Content.MediaContent.AudioInfo audioInfo)\r
{\r
TrackTitle = audioInfo.Title;\r
AlbumName = audioInfo.Album;\r
Id = audioInfo.Id;\r
ArtistName = audioInfo.Artist;\r
- Duration = audioInfo.Duration;\r
+ DurationInMS = audioInfo.Duration;\r
+ Duration = TimeSpan.FromMilliseconds(audioInfo.Duration).ToString(AppConstants.TimeFormat);\r
ThumbnailPath = audioInfo.ThumbnailPath;\r
FilePath = audioInfo.Path;\r
}\r
\r
+ private string trackTitle;\r
+\r
public string TrackTitle\r
{\r
- get => title;\r
- set => SetProperty(ref title, value);\r
+ get => trackTitle;\r
+ set => SetProperty(ref trackTitle, value);\r
}\r
\r
+ private string albumName;\r
+\r
public string AlbumName\r
{\r
- get => album;\r
+ get => albumName;\r
set\r
{\r
string name = string.IsNullOrEmpty(value) ? "Unknown" : value;\r
- SetProperty(ref album, name);\r
+ SetProperty(ref albumName, name);\r
}\r
}\r
+\r
+ private string artistName;\r
+\r
public string ArtistName\r
{\r
- get => artist;\r
+ get => artistName;\r
set\r
{\r
string name = string.IsNullOrEmpty(value) ? "Unknown" : value;\r
- SetProperty(ref artist, name);\r
+ SetProperty(ref artistName, name);\r
}\r
}\r
+\r
+ private string id;\r
+\r
public string Id\r
{\r
get => id;\r
- set { id = value; }\r
+ set => id = value;\r
}\r
- // TODO create new property of duration in string\r
- public int Duration\r
+\r
+ private string duration;\r
+\r
+ public string Duration\r
{\r
get => duration;\r
- set { duration = value; }\r
+ set => SetProperty(ref duration, value);\r
+ }\r
+\r
+ private int durationInMS;\r
+\r
+ public int DurationInMS\r
+ {\r
+ get => durationInMS;\r
+ set => SetProperty(ref durationInMS, value);\r
}\r
+\r
+ private string thumbnailPath;\r
+\r
public string ThumbnailPath\r
{\r
get => thumbnailPath;\r
}\r
}\r
\r
+ private string filePath;\r
+\r
public string FilePath\r
{\r
get => filePath;\r
// TODO implement database update event handler\r
return;\r
}\r
+\r
private static void OnMusicItemUpdate(object sender, MusicItemUpdateEventArgs e)\r
{\r
// TODO implement database item update event handler\r
return;\r
}\r
+\r
public static OrderedDictionary CurrentTrackList()\r
{\r
return tracksList;\r
}\r
-\r
}\r
}\r
--- /dev/null
+using System.Collections.Specialized;\r
+using MusicPlayer.Models;\r
+using MusicPlayer.Common;\r
+\r
+namespace MusicPlayer.ViewModels\r
+{\r
+ using AudioInfo = Tizen.Content.MediaContent.AudioInfo;\r
+ class AlbumDetailViewModel : PropertyNotifier\r
+ {\r
+ public AlbumDetailViewModel(MusicAlbum album)\r
+ {\r
+ Id = album.Id;\r
+ AlbumName = album.AlbumName;\r
+ ArtistName = album.ArtistName;\r
+ AlbumArtPath = album.AlbumArtPath;\r
+ OrderedDictionary trackList = AlbumDataProvider.GetAlbumTrackList(album.Id);\r
+ listViewModel = new ListViewModel<Track>();\r
+ listViewModel.CreateData<AudioInfo>(trackList);\r
+ listViewModel.CollectionChanged += OnAlbumDetailListChanges;\r
+ TotalTracks = listViewModel.Count.ToString();\r
+ }\r
+\r
+ private void OnAlbumDetailListChanges(object sender, NotifyCollectionChangedEventArgs e)\r
+ {\r
+ //TODO\r
+ TotalTracks = listViewModel.Count.ToString();\r
+ }\r
+\r
+ private int id;\r
+\r
+ public int Id\r
+ {\r
+ get => id;\r
+ set => id = value;\r
+ }\r
+\r
+ private string albumName;\r
+\r
+ public string AlbumName\r
+ {\r
+ get => albumName;\r
+ set\r
+ {\r
+ string text = string.Equals(value,"Unknown") ? null : value;\r
+ SetProperty(ref albumName, text);\r
+ }\r
+ }\r
+\r
+ private string artistName;\r
+\r
+ public string ArtistName\r
+ {\r
+ get => artistName;\r
+ set\r
+ {\r
+ string text = string.Equals(value, "Unknown") ? null : value;\r
+ SetProperty(ref artistName, text);\r
+ }\r
+ }\r
+\r
+ private string albumArtPath;\r
+\r
+ public string AlbumArtPath\r
+ {\r
+ get => albumArtPath;\r
+ set => SetProperty(ref albumArtPath, value);\r
+ }\r
+\r
+ private ListViewModel<Track> listViewModel;\r
+\r
+ public ListViewModel<Track> ListViewModel\r
+ {\r
+ get => listViewModel;\r
+ }\r
+\r
+ private string totalTracks;\r
+\r
+ public string TotalTracks\r
+ {\r
+ get => totalTracks;\r
+ set\r
+ {\r
+ string text = string.Equals(value, "1") ? " Track" : " Tracks";\r
+ SetProperty(ref totalTracks, value + text);\r
+ }\r
+ }\r
+ }\r
+}\r
--- /dev/null
+using System.Collections.Specialized;\r
+using MusicPlayer.Models;\r
+using MusicPlayer.Common;\r
+\r
+namespace MusicPlayer.ViewModels\r
+{\r
+ using Album = Tizen.Content.MediaContent.Album;\r
+ class AlbumViewModel : PropertyNotifier\r
+ {\r
+ private AlbumDetailViewModel albumDetailViewModel;\r
+\r
+ public AlbumViewModel()\r
+ {\r
+ OrderedDictionary albumList = AlbumDataProvider.CurrentAlbumList();\r
+ listViewModel = new ListViewModel<MusicAlbum>();\r
+ listViewModel.CreateData<Album>(albumList);\r
+ listViewModel.CollectionChanged += OnAlbumListChanges;\r
+ AlbumCount = listViewModel.Count.ToString();\r
+ }\r
+\r
+ private void OnAlbumListChanges(object sender, NotifyCollectionChangedEventArgs e)\r
+ {\r
+ AlbumCount = listViewModel.Count.ToString();\r
+ }\r
+\r
+ public AlbumDetailViewModel getDetailViewModel(MusicAlbum musicAlbum)\r
+ {\r
+ if(!albumDetailViewModel)\r
+ albumDetailViewModel = new AlbumDetailViewModel(musicAlbum);\r
+ else if (albumDetailViewModel.Id != musicAlbum.Id)\r
+ albumDetailViewModel = new AlbumDetailViewModel(musicAlbum);\r
+ return albumDetailViewModel;\r
+ }\r
+\r
+ private ListViewModel<MusicAlbum> listViewModel;\r
+\r
+ public ListViewModel<MusicAlbum> ListViewModel\r
+ {\r
+ get => listViewModel;\r
+ }\r
+\r
+ private string albumCount;\r
+\r
+ public string AlbumCount\r
+ {\r
+ get => albumCount;\r
+ set\r
+ {\r
+ string text = string.Equals(value, "1") ? " album" : " albums";\r
+ SetProperty(ref albumCount, value + text);\r
+ }\r
+ }\r
+ }\r
+}\r
--- /dev/null
+using System.Collections;\r
+using System.Collections.Specialized;\r
+using System.Collections.ObjectModel;\r
+using MusicPlayer.Models;\r
+using Tizen.Content.MediaContent;\r
+using MusicPlayer.Common;\r
+using System;\r
+\r
+namespace MusicPlayer.ViewModels\r
+{\r
+ class ListViewModel<T> : ObservableCollection<T> where T : new()\r
+ {\r
+ public ListViewModel()\r
+ {\r
+ }\r
+\r
+ public void CreateData<U>(OrderedDictionary dict)\r
+ {\r
+ foreach (DictionaryEntry item in dict)\r
+ {\r
+ Add((T)Activator.CreateInstance(typeof(T), new object[] { (U)item.Value }));\r
+ }\r
+ Tizen.Log.Debug(AppConstants.LogTag, "Observable list item count: " + this.Count);\r
+ }\r
+ }\r
+}\r
}
internal PlayingListViewModel playingListViewModel;
+
public PlayingListViewModel CurrentPlayingListViewModel
{
get => playingListViewModel;
}
private string playPauseUrl;
+
public string PlayPauseUrl
{
get => playPauseUrl;
set => SetProperty(ref hasNextTrack, value);
}
- public void SetPlayingList(TrackListViewModel trackListVM)
+ public void SetPlayingList(ListViewModel<Track> trackListVM)
{
playingListViewModel.SetTrackListViewModel(trackListVM);
}
using MusicPlayer.ViewModels;
using System.Threading;
using MusicPlayer.Common;
+using MusicPlayer.Models;
namespace MusicPlayer.ViewModels
{
class PlayingListViewModel : PropertyNotifier
{
- private TrackListViewModel tracklistViewModel;
+ private ListViewModel<Track> tracklistViewModel;
private List<int> shuffleList;
private int currentIndex;
private RepeatMode repeatMode;
ItemsSourceChanged?.Invoke(this, eventArgs);
}
- public void SetTrackListViewModel(TrackListViewModel trackListVM)
+ public void SetTrackListViewModel(ListViewModel<Track> trackListVM)
{
// Need to check for same VM and in case same VM just update the playing track
Tizen.Log.Info(AppConstants.LogTag, "Setting Current Playing list");
OnItemsSourceChanged(new EventArgs());
}
- public TrackListViewModel TrackListVM
+ public ListViewModel<Track> TrackListVM
{
get => tracklistViewModel;
}
+++ /dev/null
-using System.Collections;\r
-using System.Collections.Specialized;\r
-using System.Collections.ObjectModel;\r
-using MusicPlayer.Models;\r
-using Tizen.Content.MediaContent;\r
-using MusicPlayer.Common;\r
-\r
-namespace MusicPlayer.ViewModels\r
-{\r
- class TrackListViewModel : ObservableCollection<Track>\r
- {\r
- public TrackListViewModel()\r
- {\r
- }\r
-\r
- public void CreateData(OrderedDictionary dict)\r
- {\r
- foreach(DictionaryEntry item in dict)\r
- {\r
- Add(new Track((AudioInfo)item.Value));\r
- }\r
- Tizen.Log.Debug(AppConstants.LogTag, "Observable list item count: " + this.Count);\r
- }\r
- }\r
-}\r
\r
namespace MusicPlayer.ViewModels\r
{\r
+ using AudioInfo = Tizen.Content.MediaContent.AudioInfo;\r
class TrackViewModel : PropertyNotifier\r
{\r
- private string trackCount;\r
- private TrackListViewModel listViewModel;\r
-\r
public TrackViewModel()\r
{\r
OrderedDictionary trackList = TrackDataProvider.CurrentTrackList();\r
- listViewModel = new TrackListViewModel();\r
- listViewModel.CreateData(trackList);\r
+ listViewModel = new ListViewModel<Track>();\r
+ listViewModel.CreateData<AudioInfo>(trackList);\r
listViewModel.CollectionChanged += OnTrackListChanges;\r
TrackCount = listViewModel.Count.ToString();\r
}\r
TrackCount = listViewModel.Count.ToString();\r
}\r
\r
- public TrackListViewModel ListViewModel\r
+ private ListViewModel<Track> listViewModel;\r
+\r
+ public ListViewModel<Track> ListViewModel\r
{\r
get => listViewModel;\r
}\r
\r
+ private string trackCount;\r
+\r
public string TrackCount\r
{\r
get => trackCount;\r
- set => SetProperty(ref trackCount, value + " tracks");\r
+ set\r
+ {\r
+ string text = string.Equals(value, "1") ? " track" : " tracks";\r
+ SetProperty(ref trackCount, value + text);\r
+ }\r
}\r
}\r
}\r
--- /dev/null
+using Tizen.NUI.Components;\r
+using Tizen.NUI.BaseComponents;\r
+using Tizen.NUI;\r
+using MusicPlayer.Common;\r
+\r
+namespace MusicPlayer.Views\r
+{\r
+ class AlbumDetailLayout : RecyclerViewItem\r
+ {\r
+ private View itemSeperator;\r
+ private TextLabel titleLabel;\r
+ private TextLabel subtitleLabel;\r
+ private TextLabel additionalLabel;\r
+\r
+ private const int LayoutMargin = 16;\r
+ private const int LayoutPadding = 32;\r
+ private const int SeperatorHeight = 1;\r
+ private const int LeftPadding = 64;\r
+ private const int X = 0;\r
+\r
+ public AlbumDetailLayout(int width = 832, int height = 108) : base()\r
+ {\r
+ base.OnInitialize();\r
+ base.IsCreateByXaml = true;\r
+ WidthSpecification = width;\r
+ HeightSpecification = height;\r
+\r
+ // to show the rounded rect of the bg\r
+ BackgroundColor = Color.Transparent;\r
+\r
+ titleLabel = CreateTitleLabel();\r
+ subtitleLabel = CreateSubTitleLabel();\r
+ additionalLabel = CreateAdditionalLabel(width);\r
+ itemSeperator = CreateItemSeparator(width, height);\r
+ IsCreateByXaml = true;\r
+ }\r
+\r
+ private TextLabel CreateTitleLabel()\r
+ {\r
+ TextLabel titleLabel = new TextLabel()\r
+ {\r
+ Size2D = new Size2D(596, 40),\r
+ TextColor = UIColors.HEX001447,\r
+ PixelSize = 32,\r
+ FontFamily = "BreezeSans",\r
+ VerticalAlignment = VerticalAlignment.Center,\r
+ Padding=new Extents(LayoutPadding,0,0,0),\r
+ IsCreateByXaml = true,\r
+ Position2D = new Position2D(X , LayoutMargin),\r
+ };\r
+ base.Add(titleLabel);\r
+ return titleLabel;\r
+ }\r
+\r
+ private TextLabel CreateSubTitleLabel()\r
+ {\r
+ TextLabel subtitleLabel = new TextLabel()\r
+ {\r
+ Size2D= new Size2D(596,36),\r
+ TextColor = UIColors.HEX001447,\r
+ PixelSize = 28,\r
+ FontFamily = "BreezeSans",\r
+ VerticalAlignment = VerticalAlignment.Center,\r
+ Padding = new Extents(LayoutPadding, 0, 0, 0),\r
+ IsCreateByXaml = true,\r
+ Position2D = new Position2D(X , LayoutMargin + 40)\r
+ };\r
+ base.Add(subtitleLabel);\r
+ return subtitleLabel;\r
+ }\r
+\r
+ private TextLabel CreateAdditionalLabel(int width)\r
+ {\r
+ TextLabel additionalLabel = new TextLabel()\r
+ {\r
+ Size2D= new Size2D(108,36),\r
+ TextColor = UIColors.HEX001447,\r
+ PixelSize = 28,\r
+ FontFamily = "BreezeSans",\r
+ VerticalAlignment = VerticalAlignment.Center,\r
+ HorizontalAlignment =HorizontalAlignment.End,\r
+ IsCreateByXaml = true,\r
+ Position2D = new Position2D(width-LayoutPadding-LeftPadding-108, 36)\r
+ };\r
+ base.Add(additionalLabel);\r
+ return additionalLabel;\r
+ }\r
+\r
+ private View CreateItemSeparator(int width, int height)\r
+ {\r
+ View itemSeperator = new View()\r
+ {\r
+ Size2D = new Size2D(width, SeperatorHeight),\r
+ ExcludeLayouting = true,\r
+ Position2D = new Position2D(X , height - SeperatorHeight),\r
+ BackgroundColor = UIColors.ItemSeperator,\r
+ };\r
+ base.Add(itemSeperator);\r
+ return itemSeperator;\r
+ }\r
+\r
+ public TextLabel TitleLabel\r
+ {\r
+ get => titleLabel;\r
+ }\r
+ public TextLabel SubtitleLabel\r
+ {\r
+ get => subtitleLabel;\r
+ }\r
+ public TextLabel AdditionalLabel\r
+ {\r
+ get => additionalLabel;\r
+ }\r
+\r
+ protected override void Dispose(DisposeTypes type)\r
+ {\r
+ if (Disposed)\r
+ {\r
+ return;\r
+ }\r
+ if (type == DisposeTypes.Explicit)\r
+ {\r
+ base.Remove(itemSeperator);\r
+ itemSeperator?.Dispose();\r
+ itemSeperator = null;\r
+\r
+ base.Remove(titleLabel);\r
+ titleLabel?.Dispose();\r
+ titleLabel = null;\r
+\r
+ base.Remove(subtitleLabel);\r
+ subtitleLabel?.Dispose();\r
+ subtitleLabel = null;\r
+\r
+ base.Remove(additionalLabel);\r
+ additionalLabel?.Dispose();\r
+ additionalLabel = null;\r
+ }\r
+ base.Dispose(type);\r
+ }\r
+ }\r
+}\r
--- /dev/null
+using MusicPlayer.ViewModels;\r
+using Tizen.NUI.Components;\r
+using Tizen.NUI.BaseComponents;\r
+using Tizen.NUI;\r
+using Tizen.NUI.Binding;\r
+using MusicPlayer.Common;\r
+\r
+namespace MusicPlayer.Views\r
+{\r
+ class AlbumDetailView : View\r
+ {\r
+ private const int LayoutPadding = 64;\r
+ private const int IconSize = 48;\r
+ private const int AlbumArtSize = 520;\r
+ private const int ControlViewWidth = 960;\r
+ private const int ControlViewHeight = 60;\r
+ private const int ControlViewMargin = 6;\r
+\r
+ private BaseView baseView;\r
+ private View contentView;\r
+ private View leftView;\r
+ private View rightView;\r
+ private ImageView albumArtIcon;\r
+ private TextLabel albumNameLabel;\r
+ private TextLabel albumArtistLabel;\r
+ private View controlsView;\r
+ private TextLabel trackCountLabel;\r
+ private Button playAllIcon; // TODO need to implement playall feature\r
+ private Button shuffleAndPlayAllIcon; // TODO need to implement playlist manager\r
+ private CollectionView collectionView;\r
+\r
+ private AlbumDetailViewModel viewModel;\r
+ public AlbumDetailView(AlbumDetailViewModel viewModel) : base()\r
+ {\r
+ this.viewModel = viewModel;\r
+ BindingContext = viewModel;\r
+ BackgroundColor = UIColors.HEXEEEFF1;\r
+ WidthResizePolicy = ResizePolicyType.FillToParent;\r
+ HeightResizePolicy = ResizePolicyType.FillToParent;\r
+\r
+ //TODO need to change this part after implementation of Command Interface\r
+ baseView = new BaseView()\r
+ {\r
+ Title = viewModel.AlbumName,\r
+ BackButton = true,\r
+ MoreButton = true,\r
+ SearchButton = true,\r
+ BackgroundColor = UIColors.HEXEEEFF1,\r
+ };\r
+ base.Add(baseView);\r
+ contentView = new View()\r
+ {\r
+ WidthSpecification = LayoutParamPolicies.MatchParent,\r
+ HeightSpecification = 876,\r
+ Layout = new FlexLayout()\r
+ {\r
+ Direction = FlexLayout.FlexDirection.Row,\r
+ ItemsAlignment = FlexLayout.AlignmentType.FlexStart,\r
+ Justification = FlexLayout.FlexJustification.FlexStart,\r
+ },\r
+ };\r
+ baseView.SetContent = contentView;\r
+\r
+ leftView = CreateLeftView();\r
+ rightView = CreateRightView();\r
+ controlsView = AddControlView();\r
+ AddControlElements();\r
+ collectionView = AddCollectionView();\r
+ AddAlbumArt();\r
+ AddAlbumInfo();\r
+ }\r
+\r
+ private void OnTrackSelection(object sender, SelectionChangedEventArgs e)\r
+ {\r
+\r
+ }\r
+\r
+ private Button CreatButton(string url, int x, int y)\r
+ {\r
+ ButtonStyle buttonStyle = new ButtonStyle()\r
+ {\r
+ Icon = new ImageViewStyle()\r
+ {\r
+ ResourceUrl = url,\r
+ },\r
+ IsSelectable = false,\r
+ IsEnabled = true,\r
+ };\r
+\r
+ Button button = new Button(buttonStyle)\r
+ {\r
+ Size2D = new Size2D(IconSize, IconSize),\r
+ Position2D = new Position2D(x, y),\r
+ };\r
+ return button;\r
+ }\r
+\r
+ private View CreateLeftView()\r
+ {\r
+ View leftView = new View()\r
+ {\r
+ BackgroundColor = UIColors.HEXEEEFF1,\r
+ Size2D = new Size2D(Window.Instance.WindowSize.Width / 2, 752),\r
+ Position2D = new Position2D(0, 0),\r
+ Layout = new FlexLayout\r
+ {\r
+ Direction = FlexLayout.FlexDirection.Column,\r
+ ItemsAlignment = FlexLayout.AlignmentType.Center,\r
+ Justification = FlexLayout.FlexJustification.FlexStart,\r
+ },\r
+ Padding = new Extents(0, 0, ControlViewHeight, 42),\r
+ };\r
+ contentView.Add(leftView);\r
+ return leftView;\r
+ }\r
+\r
+ private View CreateRightView()\r
+ {\r
+ View rightView = new View()\r
+ {\r
+ BackgroundColor = UIColors.HEXEEEFF1,\r
+ Size2D = new Size2D(Window.Instance.WindowSize.Width / 2, 752),\r
+ Position2D = new Position2D(Window.Instance.WindowSize.Width / 2, 0),\r
+ Layout = new FlexLayout\r
+ {\r
+ Direction = FlexLayout.FlexDirection.Column,\r
+ ItemsAlignment = FlexLayout.AlignmentType.Center,\r
+ Justification = FlexLayout.FlexJustification.FlexStart,\r
+ },\r
+ };\r
+ contentView.Add(rightView);\r
+ return rightView;\r
+ }\r
+\r
+ private void AddAlbumArt()\r
+ {\r
+ albumArtIcon = new ImageView()\r
+ {\r
+ BackgroundColor = UIColors.HEXEEEFF1,\r
+ Size2D = new Size2D(AlbumArtSize, AlbumArtSize),\r
+ };\r
+ albumArtIcon.SetBinding(ImageView.ResourceUrlProperty, "AlbumArtPath");\r
+ leftView.Add(albumArtIcon);\r
+ }\r
+ private void AddAlbumInfo()\r
+ {\r
+ albumNameLabel = new TextLabel()\r
+ {\r
+ Text = "ALBUM NAME",\r
+ Size2D = new Size2D(640, 48),\r
+ PixelSize = 36,\r
+ Margin = new Extents(0, 0, 32, 0),\r
+ FontFamily = "BreezeSans",\r
+ TextColor = UIColors.HEX001447,\r
+ HorizontalAlignment = HorizontalAlignment.Center,\r
+ VerticalAlignment = VerticalAlignment.Center,\r
+ Ellipsis = true,\r
+ };\r
+ albumNameLabel.SetBinding(TextLabel.TextProperty, "AlbumName");\r
+ leftView.Add(albumNameLabel);\r
+ albumArtistLabel = new TextLabel()\r
+ {\r
+ Text = "ARTIST NAME",\r
+ Size2D = new Size2D(640, 36),\r
+ PixelSize = 28,\r
+ Margin = new Extents(0, 0, 14, 0),\r
+ FontFamily = "BreezeSans",\r
+ TextColor = UIColors.HEX000209,\r
+ HorizontalAlignment = HorizontalAlignment.Center,\r
+ VerticalAlignment = VerticalAlignment.Center,\r
+ Ellipsis = true,\r
+ };\r
+ albumArtistLabel.SetBinding(TextLabel.TextProperty, "ArtistName");\r
+ leftView.Add(albumArtistLabel);\r
+\r
+ }\r
+ private View AddControlView()\r
+ {\r
+ View controlsView = new View()\r
+ {\r
+ BackgroundColor = UIColors.HEXEEEFF1,\r
+ Size2D = new Size2D(ControlViewWidth, ControlViewHeight),\r
+ Padding = new Extents(LayoutPadding, LayoutPadding, ControlViewMargin, ControlViewMargin),\r
+ };\r
+ rightView.Add(controlsView);\r
+ return controlsView;\r
+ }\r
+\r
+ private void AddControlElements()\r
+ {\r
+ trackCountLabel = new TextLabel()\r
+ {\r
+ Text = "TRACK COUNT",\r
+ Size2D = new Size2D(664, 36),\r
+ Position2D = new Position2D(LayoutPadding, 12),\r
+ PixelSize = 28,\r
+ Margin = new Extents(0, 0, ControlViewMargin, ControlViewMargin),\r
+ FontFamily = "BreezeSans",\r
+ TextColor = UIColors.HEX001447,\r
+ HorizontalAlignment = HorizontalAlignment.Begin,\r
+ VerticalAlignment = VerticalAlignment.Center,\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.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
+ playAllIcon.Margin = new Extents(32, 0, 0, 0);\r
+ controlsView.Add(shuffleAndPlayAllIcon);\r
+\r
+ }\r
+\r
+ private CollectionView AddCollectionView()\r
+ {\r
+ CollectionView collectionView = new CollectionView()\r
+ {\r
+ Size2D = new Size2D(832, 108),\r
+ BackgroundImage = Resources.GetImagePath() + "list_view_bg.png",\r
+ ItemsLayouter = new LinearLayouter(),\r
+ ItemTemplate = new DataTemplate(() =>\r
+ {\r
+ AlbumDetailLayout layout = new AlbumDetailLayout();\r
+ layout.TitleLabel.SetBinding(TextLabel.TextProperty, "TrackTitle");\r
+ layout.SubtitleLabel.SetBinding(TextLabel.TextProperty, "ArtistName");\r
+ layout.AdditionalLabel.SetBinding(TextLabel.TextProperty, "Duration");\r
+ return layout;\r
+ }),\r
+ ScrollingDirection = ScrollableBase.Direction.Vertical,\r
+ HeightSpecification = LayoutParamPolicies.WrapContent,\r
+ SelectionMode = ItemSelectionMode.Single,\r
+ };\r
+ rightView.Add(collectionView);\r
+ FlexLayout.SetFlexGrow(collectionView, 1);\r
+ FlexLayout.SetFlexShrink(collectionView, 1);\r
+ collectionView.ItemsSource = viewModel.ListViewModel;\r
+ collectionView.SelectionChanged += OnTrackSelection;\r
+ return collectionView;\r
+ }\r
+ }\r
+}\r
--- /dev/null
+using MusicPlayer.ViewModels;\r
+using Tizen.NUI.Components;\r
+using Tizen.NUI.BaseComponents;\r
+using Tizen.NUI;\r
+using Tizen.NUI.Binding;\r
+using MusicPlayer.Common;\r
+using MusicPlayer.Models;\r
+\r
+namespace MusicPlayer.Views\r
+{\r
+ class AlbumView : BaseContentView\r
+ {\r
+ private AlbumViewModel viewModel;\r
+ private TextLabel albumCountLabel;\r
+\r
+ public AlbumView(AlbumViewModel viewModel)\r
+ {\r
+ this.viewModel = viewModel;\r
+ BindingContext = viewModel;\r
+ collectionView.ItemsSource = viewModel.ListViewModel;\r
+ collectionView.ItemTemplate = new DataTemplate(() =>\r
+ {\r
+ ListItemLayout layout = new ListItemLayout();\r
+ layout.Icon.SetBinding(ImageView.ResourceUrlProperty, "AlbumArtPath");\r
+ layout.TitleLabel.SetBinding(TextLabel.TextProperty, "AlbumName");\r
+ layout.SubtitleLabel.SetBinding(TextLabel.TextProperty, "ArtistName");\r
+ return layout;\r
+ });\r
+ collectionView.ScrollingDirection = ScrollableBase.Direction.Vertical;\r
+ collectionView.WidthSpecification = LayoutParamPolicies.WrapContent;\r
+ collectionView.SelectionMode = ItemSelectionMode.Single;\r
+ collectionView.SelectionChanged += OnAlbumSelection;\r
+\r
+ albumCountLabel = new TextLabel()\r
+ {\r
+ PixelSize = 28,\r
+ Text = "ALBUM COUNT",\r
+ TextColor = UIColors.HEX001447,\r
+ VerticalAlignment = VerticalAlignment.Center,\r
+ FontFamily = "BreezeSans",\r
+ IsCreateByXaml = true,\r
+ };\r
+ titleView.Add(albumCountLabel);\r
+ albumCountLabel.SetBinding(TextLabel.TextProperty, "AlbumCount");\r
+ RelativeLayout.SetLeftTarget(albumCountLabel, titleView);\r
+ RelativeLayout.SetLeftRelativeOffset(albumCountLabel, 1.0f);\r
+ RelativeLayout.SetRightRelativeOffset(albumCountLabel, 0.0f);\r
+ RelativeLayout.SetFillHorizontal(albumCountLabel, true);\r
+ }\r
+ private void OnAlbumSelection(object sender, SelectionChangedEventArgs e)\r
+ {\r
+ MusicAlbum currentAlbum= (MusicAlbum)collectionView.SelectedItem;\r
+ // viewModel.getDetailViewModel(currentAlbum) => need to replace direct function call on viewModel class with command interface\r
+ AlbumDetailView view = new AlbumDetailView(viewModel.getDetailViewModel(currentAlbum));\r
+ Window.Instance.Add(view);\r
+ }\r
+ protected override void Dispose(DisposeTypes type)\r
+ {\r
+ if (Disposed)\r
+ {\r
+ return;\r
+ }\r
+ if (type == DisposeTypes.Explicit)\r
+ {\r
+ titleView.Remove(albumCountLabel);\r
+ albumCountLabel.Dispose();\r
+ albumCountLabel = null;\r
+ }\r
+ base.Dispose(type);\r
+ }\r
+ }\r
+}\r
using MusicPlayer.Common;\r
using Tizen.NUI;\r
using Tizen.NUI.BaseComponents;\r
-using Tizen.NUI.Binding;\r
using Tizen.NUI.Components;\r
\r
namespace MusicPlayer.Views\r
Margin = new Extents(0, 0, 0, 2),\r
BackgroundImage = Resources.GetImagePath() + "list_view_bg.png",\r
ItemsLayouter = new LinearLayouter(),\r
- ItemTemplate = new DataTemplate(() =>\r
- {\r
- TrackLayout layout = new TrackLayout();\r
- layout.Icon.SetBinding(ImageView.ResourceUrlProperty, "ThumbnailPath");\r
- layout.TitleLabel.SetBinding(TextLabel.TextProperty, "TrackTitle");\r
- layout.SubtitleLabel.SetBinding(TextLabel.TextProperty, "ArtistName");\r
- return layout;\r
- }),\r
ScrollingDirection = ScrollableBase.Direction.Vertical,\r
WidthSpecification = LayoutParamPolicies.MatchParent,\r
HeightSpecification = LayoutParamPolicies.WrapContent,\r
using Tizen.NUI;\r
using Tizen.NUI.BaseComponents;\r
using Tizen.NUI.Components;\r
+using Tizen.NUI.Binding;\r
using MusicPlayer.Common;\r
\r
namespace MusicPlayer.Views\r
Ellipsis = true,\r
};\r
topView.Add(titleLabel);\r
+ titleLabel.SetBinding(TextLabel.TextProperty, "Title");\r
RelativeLayout.SetLeftTarget(titleLabel, topView);\r
RelativeLayout.SetLeftRelativeOffset(titleLabel, 0.0f);\r
RelativeLayout.SetRightTarget(titleLabel, topView);\r
backButton = new Button(buttonStyle)\r
{\r
Size2D = new Size2D(48, 48),\r
- Margin = new Extents(0, 32, 6, 6),\r
+ Margin = new Extents(0, 24, 6, 6),\r
};\r
topView.Add(backButton);\r
\r
moreButton = new Button(buttonStyle)\r
{\r
Size2D = new Size2D(48, 48),\r
- Margin = new Extents(24, 0, 6, 6),\r
+ Margin = new Extents(32, 0, 6, 6),\r
};\r
topView.Add(moreButton);\r
RelativeLayout.SetLeftRelativeOffset(moreButton, 1.0f);\r
{\r
Size2D = new Size2D(96, 60),\r
BackgroundImage = Resources.GetImagePath() + "search_button_bg.png",\r
- Margin = new Extents(0, 32, 0, 0),\r
+ Margin = new Extents(24, 0, 0, 0),\r
};\r
topView.Add(searchButton);\r
RelativeLayout.SetRightTarget(searchButton, moreButton);\r
--- /dev/null
+using Tizen.NUI.Components;\r
+using Tizen.NUI.BaseComponents;\r
+using Tizen.NUI;\r
+using MusicPlayer.Common;\r
+\r
+namespace MusicPlayer.Views\r
+{\r
+ class ListItemLayout : RecyclerViewItem\r
+ {\r
+ private static int Width = 1792;\r
+ private static int Height = 108;\r
+\r
+ private const int IconSize = 64;\r
+ private const int LayoutMargin = 16;\r
+ private const int LayoutPadding = 32;\r
+ private const int SeperatorHeight = 1;\r
+ private const int LeftPadding = 64;\r
+ private const int x = 0;\r
+\r
+ private View itemSeperator;\r
+ private TextLabel titleLabel;\r
+ private TextLabel subtitleLabel;\r
+ private ImageView icon;\r
+\r
+ public ListItemLayout(int width = 1792, int height = 108) : base()\r
+ {\r
+ base.OnInitialize();\r
+ base.IsCreateByXaml = true;\r
+ Width = width;\r
+ Height = height;\r
+ WidthSpecification = Width;\r
+ HeightSpecification = Height;\r
+\r
+ // to show the rounded rect of the bg\r
+ BackgroundColor = Color.Transparent;\r
+\r
+ icon = new ImageView()\r
+ {\r
+ WidthSpecification = IconSize,\r
+ HeightSpecification = IconSize,\r
+ IsCreateByXaml = true,\r
+ Position2D = new Position2D(x, ((Height / 2) - (IconSize / 2))),\r
+ };\r
+ base.Add(icon);\r
+\r
+ itemSeperator = new View()\r
+ {\r
+ WidthSpecification = (Width - (2 * LeftPadding)),\r
+ HeightSpecification = SeperatorHeight,\r
+ ExcludeLayouting = true,\r
+ Position2D = new Position2D(x, Height - SeperatorHeight),\r
+ BackgroundColor = UIColors.ItemSeperator,\r
+ };\r
+ base.Add(itemSeperator);\r
+\r
+ titleLabel = new TextLabel()\r
+ {\r
+ WidthSpecification = (Width - (2 * LeftPadding) - IconSize - LayoutPadding),\r
+ HeightSpecification = 40,\r
+ TextColor = Color.Blue,\r
+ PixelSize = 32,\r
+ FontFamily = "BreezeSans",\r
+ VerticalAlignment = VerticalAlignment.Center,\r
+ IsCreateByXaml = true,\r
+ Position2D = new Position2D((x + IconSize + LayoutPadding), LayoutMargin),\r
+ };\r
+ base.Add(titleLabel);\r
+\r
+ subtitleLabel = new TextLabel()\r
+ {\r
+ WidthSpecification = (Width - (2 * LeftPadding) - IconSize - LayoutPadding),\r
+ HeightSpecification = 36,\r
+ TextColor = Color.Black,\r
+ PixelSize = 28,\r
+ FontFamily = "BreezeSans",\r
+ VerticalAlignment = VerticalAlignment.Center,\r
+ IsCreateByXaml = true,\r
+ Position2D = new Position2D((x + IconSize + LayoutPadding), LayoutMargin + 40)\r
+ };\r
+ base.Add(subtitleLabel);\r
+ IsCreateByXaml = true;\r
+ }\r
+ public ImageView Icon\r
+ {\r
+ get => icon;\r
+ }\r
+ public TextLabel TitleLabel\r
+ {\r
+ get => titleLabel;\r
+ }\r
+ public TextLabel SubtitleLabel\r
+ {\r
+ get => subtitleLabel;\r
+ }\r
+\r
+ protected override void Dispose(DisposeTypes type)\r
+ {\r
+ if(Disposed)\r
+ {\r
+ return;\r
+ }\r
+ if (type == DisposeTypes.Explicit)\r
+ {\r
+ base.Remove(itemSeperator);\r
+ itemSeperator?.Dispose();\r
+ itemSeperator = null;\r
+\r
+ base.Remove(icon);\r
+ icon?.Dispose();\r
+ icon = null;\r
+\r
+ base.Remove(titleLabel);\r
+ titleLabel?.Dispose();\r
+ titleLabel = null;\r
+\r
+ base.Remove(subtitleLabel);\r
+ subtitleLabel?.Dispose();\r
+ subtitleLabel = null;\r
+ }\r
+\r
+ base.Dispose(type);\r
+ }\r
+ }\r
+}\r
ItemsLayouter = new LinearLayouter(),
ItemTemplate = new DataTemplate(() =>
{
- TrackLayout layout = new TrackLayout(832, 108);
+ ListItemLayout layout = new ListItemLayout(832, 108);
layout.Icon.SetBinding(ImageView.ResourceUrlProperty, "ThumbnailPath");
layout.TitleLabel.SetBinding(TextLabel.TextProperty, "TrackTitle");
layout.SubtitleLabel.SetBinding(TextLabel.TextProperty, "ArtistName");
+++ /dev/null
-using Tizen.NUI.Components;\r
-using Tizen.NUI.BaseComponents;\r
-using Tizen.NUI;\r
-using MusicPlayer.Common;\r
-\r
-namespace MusicPlayer.Views\r
-{\r
- class TrackLayout : RecyclerViewItem\r
- {\r
- private static int Width = 1792;\r
- private static int Height = 108;\r
-\r
- private const int IconSize = 64;\r
- private const int LayoutMargin = 16;\r
- private const int LayoutPadding = 32;\r
- private const int SeperatorHeight = 1;\r
- private const int LeftPadding = 64;\r
- private const int x = 0;\r
-\r
- private View itemSeperator;\r
- private TextLabel titleLabel;\r
- private TextLabel subtitleLabel;\r
- private ImageView icon;\r
-\r
- public TrackLayout(int width = 1792, int height = 108) : base()\r
- {\r
- base.OnInitialize();\r
- base.IsCreateByXaml = true;\r
- Width = width;\r
- Height = height;\r
- WidthSpecification = Width;\r
- HeightSpecification = Height;\r
-\r
- // to show the rounded rect of the bg\r
- BackgroundColor = Color.Transparent;\r
-\r
- icon = new ImageView()\r
- {\r
- WidthSpecification = IconSize,\r
- HeightSpecification = IconSize,\r
- IsCreateByXaml = true,\r
- Position2D = new Position2D(x, ((Height / 2) - (IconSize / 2))),\r
- };\r
- base.Add(icon);\r
-\r
- itemSeperator = new View()\r
- {\r
- WidthSpecification = (Width - (2 * LeftPadding)),\r
- HeightSpecification = SeperatorHeight,\r
- ExcludeLayouting = true,\r
- Position2D = new Position2D(x, Height - SeperatorHeight),\r
- BackgroundColor = UIColors.ItemSeperator,\r
- };\r
- base.Add(itemSeperator);\r
-\r
- titleLabel = new TextLabel()\r
- {\r
- WidthSpecification = (Width - (2 * LeftPadding) - IconSize - LayoutPadding),\r
- HeightSpecification = 40,\r
- TextColor = Color.Blue,\r
- PixelSize = 32,\r
- FontFamily = "BreezeSans",\r
- VerticalAlignment = VerticalAlignment.Center,\r
- IsCreateByXaml = true,\r
- Position2D = new Position2D((x + IconSize + LayoutPadding), LayoutMargin),\r
- };\r
- base.Add(titleLabel);\r
-\r
- subtitleLabel = new TextLabel()\r
- {\r
- WidthSpecification = (Width - (2 * LeftPadding) - IconSize - LayoutPadding),\r
- HeightSpecification = 36,\r
- TextColor = Color.Black,\r
- PixelSize = 28,\r
- FontFamily = "BreezeSans",\r
- VerticalAlignment = VerticalAlignment.Center,\r
- IsCreateByXaml = true,\r
- Position2D = new Position2D((x + IconSize + LayoutPadding), LayoutMargin + 40)\r
- };\r
- base.Add(subtitleLabel);\r
- IsCreateByXaml = true;\r
- }\r
- public ImageView Icon\r
- {\r
- get => icon;\r
- }\r
- public TextLabel TitleLabel\r
- {\r
- get => titleLabel;\r
- }\r
- public TextLabel SubtitleLabel\r
- {\r
- get => subtitleLabel;\r
- }\r
-\r
- protected override void Dispose(DisposeTypes type)\r
- {\r
- if(Disposed)\r
- {\r
- return;\r
- }\r
- if (type == DisposeTypes.Explicit)\r
- {\r
- base.Remove(itemSeperator);\r
- itemSeperator?.Dispose();\r
- itemSeperator = null;\r
-\r
- base.Remove(icon);\r
- icon?.Dispose();\r
- icon = null;\r
-\r
- base.Remove(titleLabel);\r
- titleLabel?.Dispose();\r
- titleLabel = null;\r
-\r
- base.Remove(subtitleLabel);\r
- subtitleLabel?.Dispose();\r
- subtitleLabel = null;\r
- }\r
-\r
- base.Dispose(type);\r
- }\r
- }\r
-}\r
this.viewModel = viewModel;\r
BindingContext = viewModel;\r
collectionView.ItemsSource = viewModel.ListViewModel;\r
+ collectionView.ItemTemplate= new DataTemplate(()=>\r
+ {\r
+ ListItemLayout layout = new ListItemLayout();\r
+ layout.Icon.SetBinding(ImageView.ResourceUrlProperty, "ThumbnailPath");\r
+ layout.TitleLabel.SetBinding(TextLabel.TextProperty, "TrackTitle");\r
+ layout.SubtitleLabel.SetBinding(TextLabel.TextProperty, "ArtistName");\r
+ return layout;\r
+ });\r
collectionView.ScrollingDirection = ScrollableBase.Direction.Vertical;\r
collectionView.WidthSpecification = LayoutParamPolicies.WrapContent;\r
collectionView.SelectionMode = ItemSelectionMode.Single;\r
\r
private void OnTrackSelection(object sender, SelectionChangedEventArgs e)\r
{\r
-\r
+ //TODO\r
}\r
\r
protected override void Dispose(DisposeTypes type)\r