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:
parent
8b9530c36b
commit
42b9345d5a
3 changed files with 30 additions and 32 deletions
|
@ -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 =
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue