Ejemplo n.º 1
0
        private async void searchTimer_Tick(object sender, EventArgs e)
        {
            searchTimer.Stop();
            var query = vm.query;

            if (String.IsNullOrEmpty(query))
            {
                vm.subtitles      = new List <Subtitle>();
                vm.lastSearchType = SearchType.ST_NONE;
                vm.isWorking      = false;
                return;
            }

            vm.isWorking = true;
            if (debug)
            {
                await Task.Run(() => Thread.Sleep(3000));

                vm.subtitles = new List <Subtitle>
                {
                    new Subtitle
                    {
                        fileName     = "Doctor.Who.2005.S10E02.720p.HDTV.x264-FoV[eztv]",
                        rating       = "0",
                        languageName = "English"
                    },
                    new Subtitle
                    {
                        fileName     = "Doctor.Who.2005.S10E02.1080p.HEVC.x265-MeGusta",
                        rating       = "10.0",
                        languageName = "English"
                    }
                };
            }
            else
            {
                vm.lastSearchType = SearchType.ST_QUERY;
                try
                {
                    vm.subtitles = await service.searchSubtitlesFromQueryAsync(vm.selectedLanguage.service_id, query);
                }
                catch
                {
                    this.ShowMessageAsync("Error", "An error happened while fetching subtitles, please try again.");
                }
            }
            vm.isWorking = false;
        }