mirror of
https://github.com/geometer/FBReaderJ.git
synced 2025-10-04 18:29:23 +02:00
send BookAdded event for each 16th book (and for the last book) instead of sending for each book
This commit is contained in:
parent
b853db3728
commit
edb3e640e0
2 changed files with 10 additions and 3 deletions
|
@ -151,6 +151,7 @@ public final class Library {
|
|||
Book book = orphanedBooksByFileId.get(fileId);
|
||||
if (book != null && (!doReadMetaInfo || book.readMetaInfo())) {
|
||||
addBookToLibrary(book);
|
||||
fireModelChangedEvent(ChangeListener.Code.BookAdded);
|
||||
newBooks.add(book);
|
||||
return;
|
||||
}
|
||||
|
@ -158,6 +159,7 @@ public final class Library {
|
|||
book = new Book(file);
|
||||
if (book.readMetaInfo()) {
|
||||
addBookToLibrary(book);
|
||||
fireModelChangedEvent(ChangeListener.Code.BookAdded);
|
||||
newBooks.add(book);
|
||||
return;
|
||||
}
|
||||
|
@ -260,8 +262,6 @@ public final class Library {
|
|||
if (found != null && book.matches(found.getPattern())) {
|
||||
found.getBookSubTree(book, true);
|
||||
}
|
||||
|
||||
fireModelChangedEvent(ChangeListener.Code.BookAdded);
|
||||
}
|
||||
|
||||
private void fireModelChangedEvent(ChangeListener.Code code) {
|
||||
|
@ -304,6 +304,7 @@ public final class Library {
|
|||
removeFromTree(ROOT_BY_AUTHOR, book);
|
||||
removeFromTree(ROOT_BY_TAG, book);
|
||||
addBookToLibrary(book);
|
||||
fireModelChangedEvent(ChangeListener.Code.BookAdded);
|
||||
}
|
||||
|
||||
private void build() {
|
||||
|
@ -362,6 +363,7 @@ public final class Library {
|
|||
}
|
||||
|
||||
final Set<Book> orphanedBooks = new HashSet<Book>();
|
||||
int count = 0;
|
||||
for (Book book : savedBooksByFileId.values()) {
|
||||
synchronized (this) {
|
||||
if (book.File.exists()) {
|
||||
|
@ -380,6 +382,9 @@ public final class Library {
|
|||
}
|
||||
if (doAdd) {
|
||||
addBookToLibrary(book);
|
||||
if (++count % 16 == 0) {
|
||||
fireModelChangedEvent(ChangeListener.Code.BookAdded);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
myRootTree.removeBook(book, true);
|
||||
|
@ -388,6 +393,7 @@ public final class Library {
|
|||
}
|
||||
}
|
||||
}
|
||||
fireModelChangedEvent(ChangeListener.Code.BookAdded);
|
||||
db.setExistingFlag(orphanedBooks, false);
|
||||
|
||||
// Step 3: collect books from physical files; add new, update already added,
|
||||
|
@ -414,6 +420,7 @@ public final class Library {
|
|||
helpBook.readMetaInfo();
|
||||
}
|
||||
addBookToLibrary(helpBook);
|
||||
fireModelChangedEvent(ChangeListener.Code.BookAdded);
|
||||
|
||||
// Step 5: save changes into database
|
||||
fileInfos.save();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue