Esempio n. 1
0
        void ResetCacheRequests(Interfaces.IVideoContent video, CacheRequest cacheRequest)
        {
            ClearHandleProgress();

            _ = _dispatcher.RunAsync(CoreDispatcherPriority.Normal, async() =>
            {
                // Note: 表示バグのワークアラウンドのため必要
                CacheRequest = null;

                if (cacheRequest?.CacheState == NicoVideoCacheState.Downloading)
                {
                    var progress = await _cacheManager.GetCacheProgress(video.Id);
                    if (progress != null)
                    {
                        HandleProgress(progress);
                    }

                    cacheRequest = new CacheRequest(cacheRequest, cacheRequest.CacheState)
                    {
                        PriorityQuality = progress.Quality
                    };
                }

                if (cacheRequest?.CacheState == NicoVideoCacheState.Cached &&
                    cacheRequest.PriorityQuality == NicoVideoQuality.Unknown)
                {
                    var cached = await _cacheManager.GetCachedAsync(video.Id);
                    if (cached?.Any() ?? false)
                    {
                        cacheRequest = new CacheRequest(cacheRequest, cacheRequest.CacheState)
                        {
                            PriorityQuality = cached.First().Quality
                        };
                    }
                }

                CacheRequest = cacheRequest;
            });
        }
        protected override async void Execute(IVideoContent content)
        {
            var video         = Database.NicoVideoDb.Get(content.Id);
            var cacheRequests = await VideoCacheManager.GetCachedAsync(content.Id);

            if (cacheRequests.Any())
            {
                var confirmed = await DialogService.ShowMessageDialog(
                    "ConfirmCacheRemoveContent".Translate(content.Label),
                    $"ConfirmCacheRemoveTitle".Translate(),
                    acceptButtonText : "Delete".Translate(),
                    "Cancel".Translate()
                    );

                if (confirmed)
                {
                    await VideoCacheManager.CancelCacheRequest(content.Id);
                }
            }
            else
            {
                await VideoCacheManager.CancelCacheRequest(content.Id);
            }
        }