Example #1
0
 /// <summary>
 /// Called when the user taps on an item in a word list.
 /// </summary>
 /// <param name="sender">The object sending the event.</param>
 /// <param name="e">The event parameters.</param>
 private async void ListView_ItemTapped(object sender, ItemTappedEventArgs e)
 {
     if (await ConnectivityCheck.AskToEnableConnectivity(this))
     {
         await this.CallSearchPage(((IWord)e.Item).Term);
     }
 }
Example #2
0
 /// <summary>
 /// Called when the "Log in" button is clicked.
 /// </summary>
 /// <param name="sender">The object sending the event.</param>
 /// <param name="e">The event parameters.</param>
 private async void LoginButton_Clicked(object sender, EventArgs e)
 {
     if (await ConnectivityCheck.AskToEnableConnectivity(this))
     {
         await this.Navigation.PushModalAsync(new Authentication());
     }
 }
Example #3
0
 /// <summary>
 /// Called when the user taps on the "Refresh" button.
 /// </summary>
 /// <param name="sender">The object sending the event.</param>
 /// <param name="e">The event parameters.</param>
 private async void Refresh_Clicked(object sender, EventArgs e)
 {
     if (await ConnectivityCheck.AskToEnableConnectivity(this))
     {
         ((ExerciseAnalysisDataModel)this.BindingContext).RefreshAnalysis();
     }
 }
Example #4
0
        /// <summary>
        /// Called when an item in the exercise list is tapped.
        /// </summary>
        /// <param name="sender">The object sending the event.</param>
        /// <param name="e">The event parameters.</param>
        private async void ExerciseList_ItemTapped(object sender, ItemTappedEventArgs e)
        {
            if (await ConnectivityCheck.AskToEnableConnectivity(this))
            {
                // TODO: support other exercise types
                try
                {
                    ExerciseApi   exerciseEndpoint = new ExerciseApi(App.OAuth2Account, ((EssayExercise)e.Item).Uid);
                    EssayExercise essay            = await Task.Run(async() => await exerciseEndpoint.CallEndpointAsExerciseModel()) as EssayExercise;

                    if (essay == null)
                    {
                        await this.DisplayAlert(Properties.Resources.Error, Properties.Resources.Exercise_UnableToDisplay, Properties.Resources.ButtonOK);
                    }
                    else
                    {
                        await this.Navigation.PushAsync(new EssayExerciseView(essay));
                    }
                }
                catch (UnsuccessfulApiCallException ex)
                {
                    Tools.Logger.Log("ExerciseList_ItemTapped", ex);
                    await this.DisplayAlert(Properties.Resources.Error, Properties.Resources.Exercise_UnableToDisplay, Properties.Resources.ButtonOK);
                }
            }
        }
 /// <summary>
 /// Called when an item in the exercise list is tapped.
 /// </summary>
 /// <param name="sender">The object sending the event.</param>
 /// <param name="e">The event parameters.</param>
 private async void HistoryList_ItemTapped(object sender, ItemTappedEventArgs e)
 {
     // TODO: support other exercise types
     if (await ConnectivityCheck.AskToEnableConnectivity(this.page))
     {
         await this.Navigation.PushAsync(new EssayExerciseView((EssayExercise)e.Item));
     }
 }
Example #6
0
 /// <summary>
 /// Called when the "Refresh" button is clicked.
 /// </summary>
 /// <param name="sender">The object sending the event.</param>
 /// <param name="e">The event parameters.</param>
 private async void RefreshButton_Clicked(object sender, EventArgs e)
 {
     if (await ConnectivityCheck.AskToEnableConnectivity(this))
     {
         if (this.CurrentPage is DashboardTabHistory)
         {
             ((DashboardTabHistory)this.CurrentPage).Refresh();
         }
         else if (this.CurrentPage is DashboardTabFeatured)
         {
             ((DashboardTabFeatured)this.CurrentPage).Refresh();
         }
     }
 }
Example #7
0
        /// <summary>
        /// Called when the "Refresh" button is clicked.
        /// </summary>
        /// <param name="sender">The object sending the event.</param>
        /// <param name="e">The event parameters.</param>
        private async void RefreshButton_Clicked(object sender, EventArgs e)
        {
            if (await ConnectivityCheck.AskToEnableConnectivity(this))
            {
                if (this.featureGrid.GetBindingContext().CanRefresh())
                {
                    this.featureGrid.GetBindingContext().RefreshExercises();
                }

                if (this.historyGrid.GetBindingContext().CanRefresh())
                {
                    this.historyGrid.GetBindingContext().RefreshHistory();
                }
            }
        }
Example #8
0
        /// <summary>
        /// Called when the user taps on a word in the list.
        /// </summary>
        /// <param name="sender">The object sending the event.</param>
        /// <param name="e">The event parameters.</param>
        private async void TableWord_Tapped(object sender, EventArgs e)
        {
            if (await ConnectivityCheck.AskToEnableConnectivity(this))
            {
                TextCell senderCell = sender as TextCell;
                if (senderCell == null)
                {
                    return;
                }

                if (senderCell.BindingContext is IWord)
                {
                    await this.CallSearchPage(((IWord)senderCell.BindingContext).Term);
                }
                else
                {
                    await this.CallSearchPage(senderCell.Text);
                }
            }
        }
Example #9
0
        /// <summary>
        /// Called when the user taps on "Search" in the search bar.
        /// </summary>
        /// <param name="sender">The object sending the event.</param>
        /// <param name="e">The event parameters.</param>
        private async void SearchBar_SearchButtonPressed(object sender, System.EventArgs e)
        {
            SearchBar searchBar = (SearchBar)sender;

            // Note: this warning might not appear on Android platforms where null/empty/whitespace strings are already
            // handled and refused by the component itself.
            if (string.IsNullOrWhiteSpace(searchBar.Text))
            {
                await this.DisplayAlert(Properties.Resources.Search_NoTermEntered_Title, Properties.Resources.Search_NoTermEntered_Text, Properties.Resources.ButtonOK);

                return;
            }

            if (await ConnectivityCheck.AskToEnableConnectivity(this))
            {
                ((ISearchDataModel)this.BindingContext).SearchForWord(searchBar.Text);

                // Hide all panels, enable the buttons
                this.EnableDefinitionsPanel(true, false);
            }

            this.StringNetAfterTitle.Text  = string.Format(Properties.Resources.MainSearch_StringNet_CollocationsAfterTitle, searchBar.Text);
            this.StringNetBeforeTitle.Text = string.Format(Properties.Resources.MainSearch_StringNet_CollocationsBeforeTitle, searchBar.Text);
        }