mirror of
https://github.com/geometer/FBReaderJ.git
synced 2025-10-05 19:42:17 +02:00
no book duplicates in library
This commit is contained in:
parent
655ad0a634
commit
6d09e0e233
2 changed files with 10 additions and 5 deletions
|
@ -1,6 +1,7 @@
|
||||||
===== 1.5.2 (May ??, 2012) =====
|
===== 1.5.2 (May ??, 2012) =====
|
||||||
* Fixed reading of zip archives with 0x08 bit in entry flag
|
* Fixed reading of zip archives with 0x08 bit in entry flag
|
||||||
* Fixed reading of opf files with defined :opf prefix
|
* Fixed reading of opf files with defined :opf prefix
|
||||||
|
* No book duplicates in library
|
||||||
|
|
||||||
===== 1.5.1 (May 15, 2012) =====
|
===== 1.5.1 (May 15, 2012) =====
|
||||||
* Fixed pt/px measured font size processing for CSS's
|
* Fixed pt/px measured font size processing for CSS's
|
||||||
|
|
|
@ -48,7 +48,8 @@ public final class Library extends AbstractLibrary {
|
||||||
|
|
||||||
private final BooksDatabase myDatabase;
|
private final BooksDatabase myDatabase;
|
||||||
|
|
||||||
private final List<Book> myBooks = Collections.synchronizedList(new LinkedList<Book>());
|
private final Map<ZLFile,Book> myBooks =
|
||||||
|
Collections.synchronizedMap(new HashMap<ZLFile,Book>());
|
||||||
private final RootTree myRootTree = new RootTree();
|
private final RootTree myRootTree = new RootTree();
|
||||||
private boolean myDoGroupTitlesByFirstLetter;
|
private boolean myDoGroupTitlesByFirstLetter;
|
||||||
|
|
||||||
|
@ -193,7 +194,10 @@ public final class Library extends AbstractLibrary {
|
||||||
}
|
}
|
||||||
|
|
||||||
private synchronized void addBookToLibrary(Book book) {
|
private synchronized void addBookToLibrary(Book book) {
|
||||||
myBooks.add(book);
|
if (myBooks.containsKey(book.File)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
myBooks.put(book.File, book);
|
||||||
|
|
||||||
List<Author> authors = book.authors();
|
List<Author> authors = book.authors();
|
||||||
if (authors.isEmpty()) {
|
if (authors.isEmpty()) {
|
||||||
|
@ -270,7 +274,7 @@ public final class Library extends AbstractLibrary {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
myBooks.remove(book);
|
myBooks.remove(book.File);
|
||||||
refreshInTree(ROOT_FAVORITES, book);
|
refreshInTree(ROOT_FAVORITES, book);
|
||||||
refreshInTree(ROOT_RECENT, book);
|
refreshInTree(ROOT_RECENT, book);
|
||||||
removeFromTree(ROOT_FOUND, book);
|
removeFromTree(ROOT_FOUND, book);
|
||||||
|
@ -487,7 +491,7 @@ public final class Library extends AbstractLibrary {
|
||||||
FirstLevelTree newSearchResults = null;
|
FirstLevelTree newSearchResults = null;
|
||||||
final List<Book> booksCopy;
|
final List<Book> booksCopy;
|
||||||
synchronized (myBooks) {
|
synchronized (myBooks) {
|
||||||
booksCopy = new ArrayList<Book>(myBooks);
|
booksCopy = new ArrayList<Book>(myBooks.values());
|
||||||
}
|
}
|
||||||
for (Book book : booksCopy) {
|
for (Book book : booksCopy) {
|
||||||
if (book.matches(pattern)) {
|
if (book.matches(pattern)) {
|
||||||
|
@ -573,7 +577,7 @@ public final class Library extends AbstractLibrary {
|
||||||
if (removeMode == REMOVE_DONT_REMOVE) {
|
if (removeMode == REMOVE_DONT_REMOVE) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
myBooks.remove(book);
|
myBooks.remove(book.File);
|
||||||
if (getFirstLevelTree(ROOT_RECENT).removeBook(book, false)) {
|
if (getFirstLevelTree(ROOT_RECENT).removeBook(book, false)) {
|
||||||
final List<Long> ids = myDatabase.loadRecentBookIds();
|
final List<Long> ids = myDatabase.loadRecentBookIds();
|
||||||
ids.remove(book.getId());
|
ids.remove(book.getId());
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue