public static void MarkAsRemovedBook(Book book) { book.Removed = true; book.UserModifiedDate = DateTime.UtcNow; BooksDataAccessor.UpdateBook(book); }
public BookshelfBookView(Book book, bool updateMenu, BookshelfViewController parentVC) : base(new CGRect(0, 0, 280, 280)) { this.BookshelfBook = book; this.updateMenu = updateMenu; this.BackgroundColor = UIColor.White; this.Layer.ShadowColor = UIColor.Black.CGColor; this.Layer.ShadowOpacity = 0.3f; this.Layer.ShadowRadius = 2f; this.Layer.ShadowOffset = new CGSize(5f, 5f); // imageView imageView = new UIImageView(); imageView.Frame = new CGRect(0, 0, this.Frame.Width, 150); this.AddSubview(imageView); // recognizer this.AddGestureRecognizer(new UILongPressGestureRecognizer(this, new Selector("HandleLongPress:"))); if (!String.IsNullOrEmpty(BookshelfBook.LargeImageURL)) { // imageSpinner imageSpinner = eBriefingAppearance.GenerateBounceSpinner(); imageSpinner.Center = imageView.Center; this.AddSubview(imageSpinner); // Download image bool exist = FileDownloader.Download(BookshelfBook.LargeImageURL, parentVC); if (exist) { bool outDated = false; var item = BooksOnDeviceAccessor.GetBook(BookshelfBook.ID); if (item != null) { if (item.ImageVersion < BookshelfBook.ImageVersion) { DownloadedFilesCache.RemoveFile(item.LargeImageURL); DownloadedFilesCache.RemoveFile(item.SmallImageURL); outDated = true; } } if (outDated) { FileDownloader.Download(BookshelfBook.LargeImageURL, parentVC, true); } else { UpdateImage(BookshelfBook.LargeImageURL); } } } // favoriteView if (BooksDataAccessor.IsFavorite(book.ID)) { AddFavorite(); } if (book.New) { AddRibbon(); } // titleLabel titleLabel = eBriefingAppearance.GenerateLabel(16); titleLabel.Frame = new CGRect(10, imageView.Frame.Bottom + 8, 260, 21); titleLabel.Lines = 2; titleLabel.LineBreakMode = UILineBreakMode.WordWrap; titleLabel.Text = book.Title; titleLabel.SizeToFit(); titleLabel.Frame = new CGRect(10, titleLabel.Frame.Y, 260, titleLabel.Frame.Height); this.AddSubview(titleLabel); UpdateUI(); }
public static void UpdateFavorite(Book book, bool value) { book.IsFavorite = value; book.UserModifiedDate = DateTime.UtcNow; BooksDataAccessor.UpdateFavorite(book.ID, value); }
public static bool IsFavorite(String bookID) { return(BooksDataAccessor.IsFavorite(bookID)); }
public static Book GetBook(String bookID) { return(BooksDataAccessor.GetBook(bookID)); }
public static List <Book> GetFavoriteBooks() { return(BooksDataAccessor.GetFavoriteBooks()); }
public static List <Book> GetAllBooks() { return(BooksDataAccessor.GetAllBooks()); }
public static List <Book> GetRemovedBooks() { return(BooksDataAccessor.GetRemovedBooks()); }
public static void UpdateUserModifiedDate(Book book) { BooksDataAccessor.UpdateUserModifiedDate(book); }
public static void UpdateBook(Book book) { BooksDataAccessor.UpdateBook(book); }
public static void RemoveBook(String bookID) { BooksDataAccessor.RemoveBook(bookID); }
public static void AddBook(Book book) { BooksDataAccessor.AddBook(book); }
private static void UpdateDatabase(Book book) { try { List <Chapter> chapterList = BooksOnServerAccessor.GetChapters(book.ID); List <Page> pageList = BooksOnServerAccessor.GetPages(book.ID); // Update notes if (BooksOnDeviceAccessor.GetNotes(book.ID) != null) { // Remove orphans BooksOnDeviceAccessor.RemoveOrphanNotes(book.ID, pageList); } // Update bookmarks if (BooksOnDeviceAccessor.GetBookmarks(book.ID) != null) { // Remove orphans BooksOnDeviceAccessor.RemoveOrphanBookmarks(book.ID, pageList); } // Update new chapters if (BooksOnDeviceAccessor.GetChapters(book.ID) == null) { BooksOnDeviceAccessor.AddChapters(book.ID, chapterList); } else { BooksOnDeviceAccessor.UpdateChapters(book.ID, chapterList); } BooksOnDeviceAccessor.MapPagesToChapter(chapterList, pageList); // ML: 4/9/2013 We need to map them after each update // Update new pages if (BooksOnDeviceAccessor.GetPages(book.ID) == null) { BooksOnDeviceAccessor.AddPages(book.ID, pageList); } else { BooksOnDeviceAccessor.UpdatePages(book.ID, pageList); } // Remove chapters and pages list from BooksOnServer because they now exist on the device BooksOnServerAccessor.RemoveChapters(book.ID); BooksOnServerAccessor.RemovePages(book.ID); // Update new book book.New = true; book.Status = Book.BookStatus.DOWNLOADED; book.UserAddedDate = DateTime.UtcNow; if (BooksOnDeviceAccessor.GetBook(book.ID) == null) { BooksOnDeviceAccessor.AddBook(book); } else { if (BooksDataAccessor.IsFavorite(book.ID)) { book.IsFavorite = true; } BooksOnDeviceAccessor.UpdateBook(book); } } catch (Exception ex) { Logger.WriteLineDebugging("BookUpdater - UpdateDatabase: {0}", ex.ToString()); } }