/// <summary> /// Event handler for search button /// </summary> /// <param name="sender">Search bar sender object</param> /// <param name="e">EventArgs param</param> private async void SearchBar_SearchButtonPressed(object sender, EventArgs e) { string word = ((SearchBar)sender).Text; this.MainStack.Children.Clear(); try { this.SwitchActivityIndicator(true); Stands4Dictionary s4d = new Stands4Dictionary(App.OAuth2Account, word); IList <Stands4Word> s4wResult = await s4d.CallEndpointAsStands4Word().ConfigureAwait(false); foreach (Stands4Word w in s4wResult) { this.MainStack.Children.Add(new Stands4SearchListItemView(w)); } this.SwitchActivityIndicator(false); } catch (UnsuccessfulApiCallException ex) { Tools.Logger.Log(this.GetType().ToString(), "Stands4 Exception", ex); this.SwitchActivityIndicator(false); } catch (Exception ex) { Tools.Logger.Log(this.GetType().ToString(), "Stands4 Exception", ex); this.SwitchActivityIndicator(false); } try { this.SwitchActivityIndicator(true); CollinsEnglishDictionary dictionaryAPI = new CollinsEnglishDictionary(App.OAuth2Account, word); CollinsJsonEnglishDictionary result = await dictionaryAPI.CallEndpointAsObjectAsync().ConfigureAwait(false); // Create a panel, but avoid the remote call foreach (CollinsJsonEnglishDictionarySingleResult entry in result.Results) { this.MainStack.Children.Add(new CollinsEntriesWrapper(entry)); } this.SwitchActivityIndicator(false); } catch (UnsuccessfulApiCallException ex) { Tools.Logger.Log(this.GetType().ToString(), "Collins Exception", ex); this.SwitchActivityIndicator(false); } catch (Exception ex) { Tools.Logger.Log(this.GetType().ToString(), "Collins Exception", ex); this.SwitchActivityIndicator(false); } }
public async Task <IList <CollinsWord> > CallEndpointAsCollinsWord() { CollinsJsonEnglishDictionary apiResult = await this.CallEndpointAsObjectAsync().ConfigureAwait(false); // TODO: we assume that the first definition is the right one if (apiResult.Results.Count > 0) { CollinsEnglishDictionaryGetEntry entryEndpoint = new CollinsEnglishDictionaryGetEntry(this.OAuthAccount, apiResult.Results[0].EntryId); return(await entryEndpoint.CallEndpointAsCollinsWord().ConfigureAwait(false)); } else { return(new List <CollinsWord>()); } }