Пример #1
0
 public void addBookToRecentList(Book book) {
   final List<Long> ids = myDatabase.loadRecentBookIds();
   final Long bookId = book.getId();
   ids.remove(bookId);
   ids.add(0, bookId);
   if (ids.size() > 12) {
     ids.remove(12);
   }
   myDatabase.saveRecentBookIds(ids);
 }
Пример #2
0
  public void removeBook(Book book, boolean deleteFromDisk) {
    synchronized (myBooksByFile) {
      myBooksByFile.remove(book.File);
      myBooksById.remove(book.getId());

      final List<Long> ids = myDatabase.loadRecentBookIds();
      if (ids.remove(book.getId())) {
        myDatabase.saveRecentBookIds(ids);
      }
      if (deleteFromDisk) {
        book.File.getPhysicalFile().delete();
      }
    }
    fireBookEvent(BookEvent.Removed, book);
  }
Пример #3
0
 public Book getRecentBook(int index) {
   List<Long> recentIds = myDatabase.loadRecentBookIds();
   return recentIds.size() > index ? getBookById(recentIds.get(index)) : null;
 }
Пример #4
0
 public List<Book> recentBooks() {
   return books(myDatabase.loadRecentBookIds());
 }