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

synchronization with library-service branch

This commit is contained in:
Nikolay Pultsin 2013-01-14 05:03:16 +04:00
parent 8b9530c36b
commit 42b9345d5a
3 changed files with 30 additions and 32 deletions

View file

@ -52,6 +52,36 @@ public final class Library extends AbstractLibrary {
return ourInstance;
}
private final List<ChangeListener> myListeners = Collections.synchronizedList(new LinkedList<ChangeListener>());
public interface ChangeListener {
public enum Code {
BookAdded,
BookRemoved,
StatusChanged,
Found,
NotFound
}
void onLibraryChanged(Code code);
}
public void addChangeListener(ChangeListener listener) {
myListeners.add(listener);
}
public void removeChangeListener(ChangeListener listener) {
myListeners.remove(listener);
}
protected void fireModelChangedEvent(ChangeListener.Code code) {
synchronized (myListeners) {
for (ChangeListener l : myListeners) {
l.onLibraryChanged(code);
}
}
}
private final BooksDatabase myDatabase;
private final Map<ZLFile,Book> myBooks =