1
0
Fork 0
mirror of https://github.com/geometer/FBReaderJ.git synced 2025-10-05 10:49:24 +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

@ -19,8 +19,7 @@
package org.geometerplus.fbreader.library;
import java.util.Collections;
import java.util.List;
import java.util.*;
import org.geometerplus.zlibrary.core.tree.ZLTree;
@ -91,4 +90,24 @@ public abstract class LibraryTree extends ZLTree<LibraryTree> implements Compara
}
}
}
public boolean removeBook(Book book) {
final LinkedList<LibraryTree> toRemove = new LinkedList<LibraryTree>();
for (LibraryTree tree : this) {
if ((tree instanceof BookTree) && ((BookTree)tree).Book.equals(book)) {
toRemove.add(tree);
}
}
for (LibraryTree tree : toRemove) {
tree.removeSelf();
LibraryTree parent = tree.Parent;
for (; (parent != null) && !parent.hasChildren(); parent = parent.Parent) {
parent.removeSelf();
}
for (; parent != null; parent = parent.Parent) {
parent.myChildrenString = null;
}
}
return !toRemove.isEmpty();
}
}