Beispiel #1
0
        private async void SearchView_QueryTextSubmit(object sender, SearchView.QueryTextSubmitEventArgs e)
        {
            try
            {
                this.searchToken?.Cancel();
                this.searchToken = new CancellationTokenSource();
                this.ShowListViewMessage("Loading...");
                this.adapter.Clear();
                var client  = new WebClient();
                var qstring = e.Query.Replace(".", string.Empty).Replace("/", string.Empty);
                var uri     = new System.Uri("http://hq.skivent.com.co:8080/search/" + qstring + ".json", UriKind.Absolute);
                var ret     = await Run(() => client.DownloadString(uri), this.searchToken.Token);

                var songs = this.MapSongs(ret);
                if (songs.Any())
                {
                    this.adapter          = new SongResultsAdapter(this, songs);
                    this.listView.Adapter = this.adapter;
                    this.ShowListView();
                }
                else
                {
                    this.ShowListViewMessage("No results");
                }
            }
            catch (Exception ex)
            {
                this.ShowListViewMessage($"Error loading search results: {ex.Message}");
            }
            finally
            {
                this.searchToken = null;
            }
        }
Beispiel #2
0
		private async void SearchView_QueryTextSubmit(object sender, SearchView.QueryTextSubmitEventArgs e)
		{
			try
			{
				this.searchToken?.Cancel();
				this.searchToken = new CancellationTokenSource();
				this.ShowListViewMessage("Loading...");
				this.adapter.Clear();
				var client = new WebClient();
				var qstring = e.Query.Replace(".", string.Empty).Replace("/", string.Empty);
				var uri = new System.Uri("http://hq.skivent.com.co:8080/search/" + qstring + ".json", UriKind.Absolute);
				var ret = await Run(() => client.DownloadString(uri), this.searchToken.Token);
				var songs = this.MapSongs(ret);
				if (songs.Any())
				{
					this.adapter = new SongResultsAdapter(this, songs);
					this.listView.Adapter = this.adapter;
					this.ShowListView();
				}
				else
				{
					this.ShowListViewMessage("No results");
				}
			}
			catch (Exception ex)
			{
				this.ShowListViewMessage($"Error loading search results: {ex.Message}");
			}
			finally
			{
				this.searchToken = null;
			}
		}