1
0
Fork 0
mirror of https://github.com/geometer/FBReaderJ.git synced 2025-10-05 19:42:17 +02:00

added book deleting

fixed synchronization problem in ZLTextView



git-svn-id: https://only.mawhrin.net/repos/FBReaderJ/trunk@989 6a642e6f-84f6-412e-ac94-c4a38d5a04b0
This commit is contained in:
Nikolay Pultsin 2009-06-21 09:40:55 +00:00
parent f89c7c64a0
commit dfece0b383
19 changed files with 281 additions and 113 deletions

View file

@ -311,4 +311,33 @@ public final class Library {
}
db.saveRecentBookIds(ids);
}
public boolean canDeleteBook(Book book) {
ZLFile file = book.File;
if (file.getPhysicalFile() == null) {
return false;
}
while (file instanceof ZLArchiveEntryFile) {
file = file.getParent();
if (file.children().size() != 1) {
return false;
}
}
return true;
}
public void deleteBook(Book book) {
synchronize();
myBooks.remove(book);
myLibraryByAuthor.removeBook(book);
myLibraryByTag.removeBook(book);
if (myRecentBooks.removeBook(book)) {
final BooksDatabase db = BooksDatabase.Instance();
final List<Long> ids = db.listRecentBookIds();
ids.remove(book.getId());
db.saveRecentBookIds(ids);
}
mySearchResult.removeBook(book);
book.File.getPhysicalFile().delete();
}
}