示例#1
0
        public NoteDataSource(Book book, UICollectionView collectionView, String cellID)
        {
            this.cellID         = new NSString(cellID);
            this.bookID         = book.ID;
            this.collectionView = collectionView;

            // dictionary
            dictionary = new Dictionary <Chapter, List <Note> > ();

            List <Page> pageList = BooksOnDeviceAccessor.GetPages(bookID);

            if (pageList != null)
            {
                foreach (var page in pageList)
                {
                    List <Note> notesOnPage = BooksOnDeviceAccessor.GetNotes(bookID, page.ID);
                    if (notesOnPage != null && notesOnPage.Count > 0)
                    {
                        // chapter
                        Chapter chapter = BooksOnDeviceAccessor.GetChapter(bookID, page.ChapterID);
                        if (chapter != null)
                        {
                            if (!dictionary.ContainsKey(chapter))
                            {
                                dictionary.Add(chapter, new List <Note> ());
                            }
                        }
                    }
                }
            }
        }
示例#2
0
        private static List <Chapter> DownloadChaptersWork(String bookID, List <String> fileUrlsToDownload)
        {
            // If chapters are not downloaded yet or expired, download them again
            List <Chapter> chapterList = null;

            if (!BooksOnServerAccessor.HasChapters(bookID) || CurrentBook.Status == Book.BookStatus.UPDATING)
            {
                chapterList = eBriefingService.StartDownloadChapters(bookID);
                if (chapterList != null)
                {
                    BooksOnServerAccessor.SaveChapters(bookID, chapterList);
                }
            }
            else
            {
                // Or get them from the cache
                chapterList = BooksOnServerAccessor.GetChapters(bookID);
            }

            // Queue up cover images for the chapter only if the image version is different
            if (chapterList != null)
            {
                foreach (Chapter serverCh in chapterList)
                {
                    // Remove cover image if this is an update
                    bool download = false;
                    if (CurrentBook.Status == Book.BookStatus.UPDATING)
                    {
                        Chapter deviceCh = BooksOnDeviceAccessor.GetChapter(CurrentBook.ID, serverCh.ID);
                        if (deviceCh == null)
                        {
                            download = true;
                        }
                        else if (serverCh.ImageVersion != deviceCh.ImageVersion)
                        {
                            DownloadedFilesCache.RemoveFile(deviceCh.LargeImageURL);
                            DownloadedFilesCache.RemoveFile(deviceCh.SmallImageURL);

                            download = true;
                        }
                    }
                    else
                    {
                        download = true;
                    }

                    if (download)
                    {
                        fileUrlsToDownload.Add(serverCh.LargeImageURL);
                        fileUrlsToDownload.Add(serverCh.SmallImageURL);
                    }
                }
            }

            return(chapterList);
        }