You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
//MainWindow.xaml.cs
private void AutoSuggestBox_QuerySubmitted(AutoSuggestBox sender, AutoSuggestBoxQuerySubmittedEventArgs args)
{
string Keywords = Search_music.Text;
if (args.ChosenSuggestion != null)
{
//Searchlist.xaml.cs
protected override void OnNavigatedTo(NavigationEventArgs e)
{
if (e.Parameter == null)
{
base.OnNavigatedTo(e);
return;
}
Receive_search_keywords = e.Parameter;
base.OnNavigatedTo(e);
SongListView.Items.Clear();
Search_result_loads();
}
public async void Search_result_loads()
{
isLoading = true;
Search_progress.IsActive = true;
SongListView.IsEnabled = false;
datas = await Search_model.Getsongs(Receive_search_keywords, offset);
if (datas == null)
{
SongListView.IsEnabled = true;
isLoading = false;
return;
}
foreach (var song in datas.Result.Songs)
{
SongListView.Items.Add(new
{
SongName = song.Name,
ArtistName = song.Artists[0].Name,
AlbumName = song.Album.Name,
SongId = song.Id,
});
}
Search_progress.IsActive = false;
isLoading = false;
SongListView.IsEnabled = true;
}
//Search_model.cs
public async static Task<Search_result> Getsongs(string Keywords,int offset)
{
var timestamp = DateTimeOffset.UtcNow.ToUnixTimeMilliseconds();
var Search_url = $"XXXXXX";
try
{
using var Search_response = await App.client.GetAsync(Search_url);
if (!Search_response.IsSuccessStatusCode)
{
return null;
}
var Search_content = await Search_response.Content.ReadAsStringAsync();
Search_result search_Result = new Search_result();
var result = JsonConvert.DeserializeObject<Search_result>(Search_content);
Search_response.Dispose();
return result;
}
catch (HttpRequestException)
{
return null;
}
}
Beta Was this translation helpful? Give feedback.
All reactions