Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
theweavr committed Dec 19, 2017
1 parent 66776ea commit cf64d82
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 26 deletions.
16 changes: 8 additions & 8 deletions BreadPlayer.Views.UWP/Shell.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -89,15 +89,15 @@ private async void HandleNavigationMessage(Message message)
if (message.Payload != null)
{
dynamic payload = message.Payload;
if (NowPlayingFrame.CurrentSourcePageType != payload.pageType)
{
if (!InitializeSwitch.IsMobile)
if (!InitializeSwitch.IsMobile)
{
await Dispatcher.RunAsync(CoreDispatcherPriority.Normal, () =>
{
await Dispatcher.RunAsync(CoreDispatcherPriority.Normal, () =>
{
NowPlayingFrame.Width = payload.parameter is string ? 700 : 900;
});
}
NowPlayingFrame.Width = payload.parameter is string ? 700 : 900;
});
}
if (NowPlayingFrame.CurrentSourcePageType != payload.pageType)
{
NowPlayingFrame.Navigate(payload.pageType, payload.parameter, new Windows.UI.Xaml.Media.Animation.SlideNavigationTransitionInfo());
}
else if(payload.pageType == typeof(PlaylistView))
Expand Down
3 changes: 1 addition & 2 deletions BreadPlayer.Views.UWP/Themes/DataTemplates.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -89,9 +89,8 @@
<MenuFlyout x:Key="Flyout">
<Extensions:MenuFlyoutIconItem
x:Name="playMenuItem"
Command="{Binding Path=PlayCommand}"
Command="{Binding Source={StaticResource LibVM}, Path=PlayCommand}"
CommandParameter="{Binding}"
DataContext="{StaticResource LibVM}"
Glyph="&#xE768;"
Text="Play" />
<Extensions:MenuFlyoutIconItem
Expand Down
27 changes: 12 additions & 15 deletions BreadPlayer.Views.UWP/ViewModels/PlaylistsCollectionViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -209,27 +209,24 @@ IEnumerable<ChildSong> playlistSongs
});
var db = new KeyValueStoreDatabaseService(SharedLogic.Instance.DatabasePath, "PlaylistSongs");
await db.InsertRecords(playlistSongs);
var s = await db.GetRecords<ChildSong>();
//await AddSongsToPlaylist(plist, songs.ToList());
await AddSongsToPlaylist(plist);
}
});
}

private async Task AddSongsToPlaylist(Playlist list, IReadOnlyCollection<Mediafile> songsToadd)
private async Task AddSongsToPlaylist(Playlist list)
{
if (songsToadd.Any())
{
await PlaylistService.InsertTracksAsync(songsToadd.Where(t => !PlaylistService.Exists(t.Id)), list);
var pSongs = (await PlaylistService.GetTracksAsync(list.Id)).ToList();
//await PlaylistService.InsertTracksAsync(songsToadd.Where(t => !PlaylistService.Exists(t.Id)), list);
var pSongs = (await PlaylistService.GetTracksAsync(list.Id)).ToList();

//update duration and songs count
var collectionPlaylist = Playlists.FirstOrDefault(t => t.Name == list.Name);
collectionPlaylist.SongsCount = pSongs.Count + " songs";
collectionPlaylist.ImagePath = pSongs.First(t => t.AttachedPicture != null)?.AttachedPicture ?? "";
collectionPlaylist.ImageColor = (await SharedLogic.Instance.GetDominantColor(await StorageFile.GetFileFromPathAsync(list.ImagePath))).ToHexString();
collectionPlaylist.Duration = string.Format("{0:0.0}", Math.Truncate(pSongs.Sum(t => TimeSpan.ParseExact(IsHour(t.Length) ? t.Length : "00:" + t.Length, @"hh\:mm\:ss", CultureInfo.InvariantCulture).TotalMinutes) * 10) / 10) + " Minutes";
await PlaylistService.UpdatePlaylistAsync(collectionPlaylist).ConfigureAwait(false);
}
//update duration and songs count
var collectionPlaylist = Playlists.FirstOrDefault(t => t.Name == list.Name);
collectionPlaylist.SongsCount = pSongs.Count + " songs";
collectionPlaylist.ImagePath = pSongs.First(t => t.AttachedPicture != null)?.AttachedPicture ?? "";
if(!string.IsNullOrEmpty(collectionPlaylist.ImagePath))
collectionPlaylist.ImageColor = (await SharedLogic.Instance.GetDominantColor(await StorageFile.GetFileFromPathAsync(collectionPlaylist.ImagePath))).ToHexString();
collectionPlaylist.Duration = string.Format("{0:0.0}", Math.Truncate(pSongs.Sum(t => TimeSpan.ParseExact(IsHour(t.Length) ? t.Length : "00:" + t.Length, @"hh\:mm\:ss", CultureInfo.InvariantCulture).TotalMinutes) * 10) / 10) + " Minutes";
await PlaylistService.UpdatePlaylistAsync(collectionPlaylist).ConfigureAwait(false);
}

private async void AddToPlaylist(object file)
Expand Down
3 changes: 2 additions & 1 deletion BreadPlayer.Views.UWP/Views/PlaylistsCollectionView.xaml.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using BreadPlayer.Controls;
using BreadPlayer.Messengers;
using BreadPlayer.Services;
using Windows.UI.Xaml.Controls;
using Windows.UI.Xaml.Navigation;
Expand All @@ -22,7 +23,7 @@ private void OnPlaylistClicked(object sender, ItemClickEventArgs e)
if (e.ClickedItem != null)
{
SplitViewMenu.UnSelectAll();
NavigationService.Instance.Frame.Navigate(typeof(PlaylistView), e.ClickedItem);
Messenger.Instance.NotifyColleagues(MessageTypes.MsgNavigate, new { pageType = typeof(PlaylistView), parameter = e.ClickedItem });
}
}
}
Expand Down

0 comments on commit cf64d82

Please sign in to comment.