예제 #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
 private List<Book> books(List<Long> ids) {
   final List<Book> bookList = new ArrayList<Book>(ids.size());
   for (long id : ids) {
     final Book book = getBookById(id);
     if (book != null) {
       bookList.add(book);
     }
   }
   return bookList;
 }
예제 #3
0
 public Book getRecentBook(int index) {
   List<Long> recentIds = myDatabase.loadRecentBookIds();
   return recentIds.size() > index ? getBookById(recentIds.get(index)) : null;
 }