public void removePeriodicUpdater( UIUpdatable updateable ) { synchronized( perioidic_updateables ){ perioidic_updateables.remove( updateable ); if ( perioidic_updateables.isEmpty()) { pu_counter++; } } } }
@Override public void downloadComplete(DownloadManager manager) { if (this.completion_listeners.isEmpty()) {return;} Iterator itr = this.completion_listeners.iterator(); DownloadCompletionListener dcl; while (itr.hasNext()) { dcl = (DownloadCompletionListener)itr.next(); long startTime = SystemTime.getCurrentTime(); try {dcl.onCompletion(this);} catch (Throwable t) {Debug.printStackTrace(t);} long diff = SystemTime.getCurrentTime() - startTime; if (diff > 1000) { System.out.println("Plugin should move long processes (" + diff + "ms) off of Download's onCompletion listener trigger. " + dcl); } } }
@Override public void removeAttributeListener(DownloadAttributeListener listener, TorrentAttribute attr, int event_type) { String attribute = convertAttribute(attr); if (attribute == null) {return;} CopyOnWriteMap attr_map = this.getAttributeMapForType(event_type); CopyOnWriteList listener_list = (CopyOnWriteList)attr_map.get(attribute); boolean remove_self = false; if (listener_list != null) { listener_list.remove(listener); remove_self = listener_list.isEmpty(); } if (remove_self) { download_manager.getDownloadState().removeListener(this, attribute, event_type); } }
@Override public void addAttributeListener(DownloadAttributeListener listener, TorrentAttribute attr, int event_type) { String attribute = convertAttribute(attr); if (attribute == null) {return;} CopyOnWriteMap attr_map = this.getAttributeMapForType(event_type); CopyOnWriteList listener_list = (CopyOnWriteList)attr_map.get(attribute); boolean add_self = false; if (listener_list == null) { listener_list = new CopyOnWriteList(); attr_map.put(attribute, listener_list); } add_self = listener_list.isEmpty(); listener_list.add(listener); if (add_self) { download_manager.getDownloadState().addListener(this, attribute, event_type); } }