Beispiel #1
0
        public async Task <IEnumerable <int> > LoadAllPreviewBookIdsAsync(BookCategory.Category category)
        {
            await Task.Delay(250);

            if (category == BookCategory.Category.Manga)
            {
                return(MangaPreviewItems.Select(book => book.Id).ToList());
            }
            else
            {
                return(RecommendationPreviewItems.Select(book => book.Id).ToList());
            }
        }
        public BookCarouselPage(int selectedBookId, IEnumerable <int> allBookIds, BookCategory.Category selectedBookCategory)
        {
            InitializeComponent();


            Title = (selectedBookCategory == BookCategory.Category.Manga) ? "Mangaa suoraan Jaappanista" : "Suosittelemme sinulle";

            SetChildrenPages(selectedBookId, allBookIds, selectedBookCategory);

            var messaging = App.Container.Resolve <IMessageQueue>();

            messaging.Subscribe <PurchaseBookViewModel, byte[]>(this, PurchaseBookViewModel.ShowBookCoverMessage, async(sender, imageBytes) =>
            {
                await Navigation.PushAsync(new BookCoverPage(imageBytes));
            });
        }
        public async void LoadNextBooks(BookCategory.Category category)
        {
            if (!m_searchForMoreBooks || IsBusy)
            {
                return;
            }

            IsBusy = true;

            try
            {
                IEnumerable <BookPreview> loadedBooks = await m_bookStore.LoadPreviewBookAsync(m_currentBookItemIndex, LoadItemsCount, category);

                UpdateLoadedBooks(loadedBooks);
            }
            catch (Exception ex)
            {
                m_messaging.Send(this, ex);
            }


            IsBusy = false;
        }
Beispiel #4
0
        public async Task <IEnumerable <BookPreview> > LoadPreviewBookAsync(int startFrom, int takeCount, BookCategory.Category category)
        {
            await Task.Delay(500);

            if (category == BookCategory.Category.Manga)
            {
                return(MangaPreviewItems.Skip(startFrom).Take(takeCount).ToList());
            }
            else
            {
                return(RecommendationPreviewItems.Skip(startFrom).Take(takeCount).ToList());
            }
        }
        private void SetChildrenPages(int selectedBookId, IEnumerable <int> allBookIds, BookCategory.Category selectedBookCategory)
        {
            IList <PurchaseBookPage> allBookPages = new List <PurchaseBookPage>();

            foreach (var id in allBookIds)
            {
                allBookPages.Add(new PurchaseBookPage(id));
            }

            foreach (var page in allBookPages)
            {
                Children.Add(page);
            }

            SelectedItem = allBookPages.First(b => b.BookId == selectedBookId);
        }