예제 #1
0
        public bool RemovePlaylist(LocalPlaylist localPlaylist)
        {
            var result = _playlistRepository.Delete(localPlaylist.Id);

            RemoveHandleItemsChanged(localPlaylist);
            return(_playlists.Remove(localPlaylist));
        }
예제 #2
0
        void HandleItemsChanged(LocalPlaylist playlist)
        {
            CompositeDisposable disposables = new CompositeDisposable();

            LocalMylistPropertyChangedObserverMap.Add(playlist.Id, disposables);

            Observable.FromEventPattern <LocalPlaylistItemAddedEventArgs>(
                h => playlist.ItemAdded += h,
                h => playlist.ItemAdded -= h
                )
            .Subscribe(args =>
            {
                var sender = args.Sender as LocalPlaylist;
                _notificationService.ShowInAppNotification(new InAppNotificationPayload()
                {
                    Content = "InAppNotification_LocalPlaylistAddedItems".Translate(sender.Label, args.EventArgs.AddedItems.Count)
                });
            })
            .AddTo(disposables);

            Observable.FromEventPattern <LocalPlaylistItemRemovedEventArgs>(
                h => playlist.ItemRemoved += h,
                h => playlist.ItemRemoved -= h
                )
            .Subscribe(args =>
            {
                var sender = args.Sender as LocalPlaylist;
                _notificationService.ShowInAppNotification(new InAppNotificationPayload()
                {
                    Content = "InAppNotification_LocalPlaylistRemovedItems".Translate(sender.Label, args.EventArgs.RemovedItems.Count)
                });
            })
            .AddTo(disposables);
        }
예제 #3
0
 void RemoveHandleItemsChanged(LocalPlaylist playlist)
 {
     if (LocalMylistPropertyChangedObserverMap.Remove(playlist.Id, out var disposables))
     {
         disposables.Dispose();
     }
 }
예제 #4
0
        private LocalPlaylist CreatePlaylist_Internal(string label)
        {
            var entity = new PlaylistEntity()
            {
                Id             = LiteDB.ObjectId.NewObjectId().ToString(),
                Count          = 0,
                Label          = label,
                PlaylistOrigin = PlaylistOrigin.Local
            };

            _playlistRepository.Upsert(entity);
            _playlistIdToEntity.Add(entity.Id, entity);

            var playlist = new LocalPlaylist(entity.Id, _playlistRepository)
            {
                Label = label,
            };

            HandleItemsChanged(playlist);

            _playlists.Add(playlist);
            return(playlist);
        }