Ejemplo n.º 1
0
 public bool AddAyahBookmark(QuranAyah ayah)
 {
     try
     {
         using (var adapter = new BookmarksDatabaseHandler())
         {
             if (ayah == null)
             {
                 adapter.AddBookmarkIfNotExists(null, null, CurrentPageNumber);
             }
             else
             {
                 adapter.AddBookmarkIfNotExists(ayah.Surah, ayah.Ayah, CurrentPageNumber);
             }
         }
         CurrentPageBookmarked = BookmarksDatabaseHandler.IsPageBookmarked(CurrentPageNumber);
         return(true);
     }
     catch (Exception e)
     {
         QuranApp.NativeProvider.Log("error creating bookmark");
         telemetry.TrackException(e, new Dictionary <string, string> {
             { "Scenario", "AddBookmark" }
         });
         return(false);
     }
 }
Ejemplo n.º 2
0
        private async Task LoadCurrentPage()
        {
            await LoadPage(CurrentPage);

            if (CurrentPageIndex - 1 > 0)
            {
                LoadPage(Pages[CurrentPageIndex - 1]);
            }

            if (CurrentPageIndex + 1 < Pages.Count)
            {
                LoadPage(Pages[CurrentPageIndex + 1]);
            }

            var pageNumber = GetPageNumberFromIndex(CurrentPageIndex);

            CurrentSurahName   = QuranUtils.GetSurahNameFromPage(pageNumber, false);
            CurrentSurahNumber = QuranUtils.GetSurahNumberFromPage(pageNumber);
            var rub = QuranUtils.GetRub3FromPage(pageNumber);

            CurrentJuzName = string.Format("{0} {1}{2} {3} {4}", QuranUtils.GetJuzTitle(),
                                           QuranUtils.GetJuzFromPage(pageNumber),
                                           getJuzPart(rub), Resources.quran_rub3, rub + 1);
            CurrentPageBookmarked = BookmarksDatabaseHandler.IsPageBookmarked(CurrentPageNumber);

            if (!IsLoading)
            {
                SettingsUtils.Set <int>(Constants.PREF_LAST_PAGE, pageNumber);
            }
        }
Ejemplo n.º 3
0
        private async Task LoadBookmarkList()
        {
            Bookmarks.Clear();
            var lastPage = SettingsUtils.Get <int>(Constants.PREF_LAST_PAGE);

            if (lastPage > 0)
            {
                var lastPageItem = new ItemViewModel();
                lastPageItem.Title   = QuranUtils.GetSurahNameFromPage(lastPage, true);
                lastPageItem.Details = string.Format("{0} {1}, {2} {3}", Resources.quran_page, lastPage,
                                                     QuranUtils.GetJuzTitle(),
                                                     QuranUtils.GetJuzFromPage(lastPage));
                lastPageItem.PageNumber = lastPage;
                lastPageItem.Image      = new BitmapImage(new Uri("ms-appx:///Assets/Images/favorite.png"));
                lastPageItem.ItemType   = ItemViewModelType.Bookmark;
                lastPageItem.Group      = Resources.bookmarks_current_page;
                lastPageItem.Id         = lastPageItem.Group;
                Bookmarks.Add(lastPageItem);
            }

            using (var bookmarksAdapter = new BookmarksDatabaseHandler())
            {
                try
                {
                    var bookmarks = bookmarksAdapter.GetBookmarks(true, BoomarkSortOrder.Location);
                    if (bookmarks.Count > 0)
                    {
                        //Load untagged first
                        foreach (var bookmark in bookmarks)
                        {
                            if (bookmark.Tags == null)
                            {
                                Bookmarks.Add(await CreateBookmarkModel(bookmark));
                            }
                        }

                        //Load tagged
                        foreach (var bookmark in bookmarks)
                        {
                            if (bookmark.Tags != null)
                            {
                                Bookmarks.Add(await CreateBookmarkModel(bookmark));
                            }
                        }
                    }
                }
                catch (Exception ex)
                {
                    telemetry.TrackException(ex, new Dictionary <string, string> {
                        { "Scenario", "LoadingBookmarks" }
                    });
                    QuranApp.NativeProvider.Log("failed to load bookmarks: " + ex.Message);
                }
            }
        }
Ejemplo n.º 4
0
        public void DeleteBookmark(ItemViewModel item)
        {
            int id = 0;

            if (item != null && item.Id != null && int.TryParse(item.Id, NumberStyles.None, CultureInfo.InvariantCulture, out id))
            {
                Bookmarks.Remove(item);
                using (var bookmarksAdapter = new BookmarksDatabaseHandler())
                {
                    bookmarksAdapter.RemoveBookmark(id);
                }
            }
        }
Ejemplo n.º 5
0
        private async Task LoadCurrentPage()
        {
            var tempCurrentPageIndex = CurrentPageIndex;
            var _currentPage         = GetPageFromIndex(tempCurrentPageIndex);

            if (_currentPage == null)
            {
                return;
            }

            await _currentPage.Load(this.TranslationFile, _bismillahTranslation);

            var pageNumber = GetPageNumberFromIndex(tempCurrentPageIndex);

            CurrentSurahName   = QuranUtils.GetSurahNameFromPage(pageNumber, false);
            CurrentSurahNumber = QuranUtils.GetSurahNumberFromPage(pageNumber);
            var rub = QuranUtils.GetRub3FromPage(pageNumber);

            CurrentJuzName = string.Format("{0} {1}{2} {3} {4}", QuranUtils.GetJuzTitle(),
                                           QuranUtils.GetJuzFromPage(pageNumber),
                                           getJuzPart(rub), Resources.quran_rub3, rub + 1);
            CurrentPageBookmarked = BookmarksDatabaseHandler.IsPageBookmarked(pageNumber);

            // Load previous and next pages
            var _previousPage = GetPageFromIndex(tempCurrentPageIndex - 1);

            if (_previousPage != null)
            {
                await _previousPage.Load(this.TranslationFile, _bismillahTranslation);
            }
            var _nextPage = GetPageFromIndex(tempCurrentPageIndex + 1);

            if (_nextPage != null)
            {
                await _nextPage.Load(this.TranslationFile, _bismillahTranslation);
            }

            if (!IsLoading)
            {
                SettingsUtils.Set <int>(Constants.PREF_LAST_PAGE, pageNumber);
            }
        }
Ejemplo n.º 6
0
 public bool TogglePageBookmark()
 {
     try
     {
         using (var adapter = new BookmarksDatabaseHandler())
         {
             adapter.TogglePageBookmark(CurrentPageNumber);
         }
         CurrentPageBookmarked = BookmarksDatabaseHandler.IsPageBookmarked(CurrentPageNumber);
         return(true);
     }
     catch (Exception e)
     {
         QuranApp.NativeProvider.Log("error creating bookmark");
         telemetry.TrackException(e, new Dictionary <string, string> {
             { "Scenario", "TogglePageBookmark" }
         });
         return(false);
     }
 }