private void SourceFoldersCollectionChanged(object sender, NotifyCollectionChangedEventArgs e) { switch (e.Action) { case NotifyCollectionChangedAction.Add: AddTvShows(e.NewItems.Cast <string>()); break; case NotifyCollectionChangedAction.Remove: RemoveTvShows(e.OldItems.Cast <string>()); break; case NotifyCollectionChangedAction.Replace: RemoveTvShows(e.OldItems.Cast <string>()); AddTvShows(e.NewItems.Cast <string>()); break; case NotifyCollectionChangedAction.Reset: TvShows.Clear(); break; } }
private async void LoadTvShowsAsync() { if (IsLoading) { return; } IsLoading = true; TvShows.Clear(); if (App.Context.Connection.Xbmc.IsMocked) { var videoDetailsTvShow = new VideoDetailsTvShow { TvShowId = 1, Title = "Saturday Night Live", Art = new MediaArtwork { Banner = "http://thetvdb.com/banners/_cache/graphical/76177-g5.jpg" } }; TvShows.Add(new ExtendedVideoDetailsTvShow(videoDetailsTvShow)); IsLoading = false; return; } try { var tvshows = await App.Context.Connection.Xbmc.VideoLibrary.GetTvShowsAsync( fields : new[] { VideoFieldsTVShow.art, VideoFieldsTVShow.title, VideoFieldsTVShow.plot, VideoFieldsTVShow.episode, VideoFieldsTVShow.watchedepisodes, VideoFieldsTVShow.playcount }); if (tvshows.TvShows == null || !tvshows.TvShows.Any()) { MessageBox.Show(AppResources.Page_Tv_Shows_Message_No_Tv_Show, AppResources.ApplicationTitle, MessageBoxButton.OK); if (NavigationService.CanGoBack) { NavigationService.GoBack(); } return; } var items = tvshows.TvShows.Where(s => _keepWatched || (!_keepWatched && !s.IsWatched)) .OrderBy(s => s.Label) .Select(s => new ExtendedVideoDetailsTvShow(s)); foreach (var extendedVideoDetailsTvShow in items) { TvShows.Add(extendedVideoDetailsTvShow); } } catch (Exception ex) { App.TrackException(ex); MessageBox.Show(AppResources.Global_Error_Message, AppResources.ApplicationTitle, MessageBoxButton.OK); } finally { IsLoading = false; } }
private async Task LoadTvShowsAsync(bool keepWatched) { if (IsLoading) { return; } IsLoading = true; TvShows.Clear(); if (App.Context.Connection.Kodi.IsMocked) { var videoDetailsTvShow = new VideoDetailsTvShow { TvShowId = 1, Title = "Saturday Night Live", Art = new MediaArtwork { Banner = "http://thetvdb.com/banners/_cache/graphical/76177-g5.jpg" } }; TvShows.Add(new ExtendedVideoDetailsTvShow(videoDetailsTvShow)); IsLoading = false; return; } try { var tvshows = await App.Context.Connection.Kodi.VideoLibrary.GetTvShowsAsync( fields : new[] { VideoFieldsTVShow.art, VideoFieldsTVShow.title, VideoFieldsTVShow.plot, VideoFieldsTVShow.episode, VideoFieldsTVShow.watchedepisodes, VideoFieldsTVShow.playcount }); if (tvshows.TvShows == null || !tvshows.TvShows.Any()) { return; } var items = tvshows.TvShows.Where(s => keepWatched || (!keepWatched && !s.IsWatched)) .OrderBy(s => s.Label) .Select(s => new ExtendedVideoDetailsTvShow(s)); foreach (var extendedVideoDetailsTvShow in items) { TvShows.Add(extendedVideoDetailsTvShow); } } catch (Exception ex) { App.TrackException(ex); var dialog = new MessageDialog(_resourceLoader.GetString("GlobalErrorMessage"), _resourceLoader.GetString("ApplicationTitle")); await dialog.ShowAsync(); } finally { IsLoading = false; } }