예제 #1
0
        private async void SaveButtonClicked()
        {
            controller.FirstTourStepCompleted();

            var nonEmptyVerseReferenceTextField = verseReference.Text.Length != 0;

            if (nonEmptyVerseReferenceTextField)
            {
                var verse = new Verse {
                    Category  = Category.Queue,
                    Content   = "Verse downloading...",
                    Memorized = false,
                    Title     = verseReference.Text,
                    Comments  = verseComments.Text == "Comments" ? "" : verseComments.Text
                };

                if (Reachability.IsHostReachable("www.google.com"))
                {
                    try {
                        UIApplication.SharedApplication.NetworkActivityIndicatorVisible = true;

                        if (VersesTableViewController.Current.Verses.Any(item => item.Title == verse.Title))
                        {
                            new UIAlertView("Verse Already Exists", "Whoops, this verse is already in your library.", null, "Okay", null).Show();
                        }
                        else
                        {
                            VersesTableViewController.Current.Locked = true;
                            var translation = TranslationHelper.GetCurrentTranslationForDownload();
                            verse.Translation = translation;
                            verse.Content     = await BiblesDotOrg.GetVerseTextWithoutHtmlOrDigitsAsync(verseReference.Text, translation);

                            controller.AddVerse(verse);
                            VersesTableViewController.Current.Locked = false;
                            LocalyticsSession.Shared.TagEvent("Verse Saved");
                        }
                    } catch (InvalidVerseException) {
                        new UIAlertView("Invalid Input", "Oops! That verse was not found!", null, "Okay", null).Show();
                    } finally {
                        UIApplication.SharedApplication.NetworkActivityIndicatorVisible = false;
                    }
                }
                else
                {
                    new UIAlertView("Network Failure", "Oops! Please connect to the internet to download verses.", null, "Okay", null).Show();
                }
            }
            else
            {
                new UIAlertView("Invalid Input", "Oops! Don't forget to add a verse reference!", null, "Okay", null).Show();
            }
        }
예제 #2
0
        private async void SaveButtonClicked()
        {
            if (VerseReference.Text != "")
            {
                var verse = new Verse {
                    Category    = MemorizationCategory.Queue,
                    Content     = "Verse downloading...",
                    Memorizable = true,
                    Memorized   = false,
                    Timestamp   = DateTime.Now,
                    Title       = VerseReference.Text,
                    Comments    = VerseComments.Text == "Comments" ? "" : VerseComments.Text
                };

                TranslationHelper.AddVerseTranslation(verse);

                if (Reachability.IsHostReachable("www.google.com"))
                {
                    var path        = DatabaseSetupHelper.GetDatabasePath("verses.db3");
                    var db          = new DatabaseHelper(path);
                    var translation = TranslationHelper.GetCurrentTranslationForDownload();

                    try {
                        UIApplication.SharedApplication.NetworkActivityIndicatorVisible = true;
                        verse.Content = await BiblesDotOrg.GetVerseTextWithoutHtmlOrDigitsAsync(VerseReference.Text, translation);

                        db.AddVerse(verse);
                        LocalyticsSession.Shared.TagEvent("Verse Saved");
                    } catch (InvalidVerseException ex) {
                        Console.WriteLine(ex);
                        new UIAlertView("Invalid Input", "Oops! That verse was not found!", null, "Okay", null).Show();
                    } finally {
                        UIApplication.SharedApplication.NetworkActivityIndicatorVisible = false;
                    }

                    ManagingController.ViewDidAppear(true);
                    ManagingController.VersesTable.ReloadData();
                }
                else
                {
                    new UIAlertView("Network Failure", "Oops! Please connect to the internet to download verses.", null, "Okay", null).Show();
                }
            }
            else
            {
                new UIAlertView("Invalid Input", "Oops! Don't forget to add a verse reference!", null, "Okay", null).Show();
            }
        }