Esempio n. 1
0
 /// <summary>
 /// Conducts a search of the online database
 /// </summary>
 /// <returns></returns>
 private async Task SearchAsync()
 {
     try
     {
         this.isLoading = true;
         Device.BeginInvokeOnMainThread(() =>
         {
             this.SearchedStack.Children.Clear();
             this.ActivityIndicator.IsRunning = true;
         });
         List <QuizInfo> chunk = new List <QuizInfo>();
         if (this.searchType == SearchType.Title)
         {
             chunk = SearchUtils.GetQuizzesByQuizNameChunked(this.SearchBar.Text, this.currentChunk);
         }
         else
         {
             chunk = SearchUtils.GetQuizzesByAuthorChunked(this.SearchBar.Text, this.currentChunk);
         }
         if (chunk.Count < 20)
         {
             await Task.Run(() => this.AddQuizzes(chunk));
         }
         Device.BeginInvokeOnMainThread(() =>
         {
             if (this.SearchedStack.Children.Count() == 0)
             {
                 this.LableNone.IsVisible = true;
             }
             else
             {
                 this.LableNone.IsVisible = false;
             }
             this.ActivityIndicator.IsRunning = false;
         });
         this.isLoading = false;
     }
     catch (Exception ex)
     {
         BugReportHandler.SaveReport(ex);
         await this.DisplayAlert("Search Failed", "Try again later", "Ok");
     }
 }