public static void addDefaultExtensionHandler( long id, byte[] message_id ) { default_entension_handlers.put( (byte)id, message_id ); }
public void addExtensionHandler( byte id, byte[] message_id ) { extension_handlers.put( id, message_id ); }
@Override public Proxy setProxy( InetSocketAddress address, Proxy proxy ) { List<Proxy> p = new ArrayList<>(); p.add( proxy ); String address_str = AddressUtils.getHostNameNoResolve( address ) + ":" + address.getPort(); List<Proxy> old = explicit_proxy_map.put( address_str, Collections.unmodifiableList( p )); if ( old != null ){ return( old.get(0)); }else{ return( null ); } }
public static void addGlobalListener( DownloadManagerStateAttributeListener l, String attribute, int event_type) { CopyOnWriteMap<String,CopyOnWriteList<DownloadManagerStateAttributeListener>> map_to_use = (event_type == DownloadManagerStateAttributeListener.WILL_BE_READ) ? global_listeners_read_map_cow : global_listeners_write_map_cow; CopyOnWriteList<DownloadManagerStateAttributeListener> lst = map_to_use.get(attribute); if (lst == null) { lst = new CopyOnWriteList<>(); map_to_use.put(attribute, lst); } lst.add(l); }
/** * * @param l Listener to fire * @param attribute attribute to listen for (null for all) * @param event_type {@link DownloadManagerStateAttributeListener#WILL_BE_READ} or {@link DownloadManagerStateAttributeListener#WRITTEN} */ @Override public void addListener(DownloadManagerStateAttributeListener l, String attribute, int event_type) { CopyOnWriteMap<String,CopyOnWriteList<DownloadManagerStateAttributeListener>> map_to_use = (event_type == DownloadManagerStateAttributeListener.WILL_BE_READ) ? this.listeners_read_map_cow : this.listeners_write_map_cow; CopyOnWriteList<DownloadManagerStateAttributeListener> lst = map_to_use.get(attribute); if (lst == null) { lst = new CopyOnWriteList<>(); map_to_use.put(attribute, lst); } lst.add(l); }
@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); } }
skin_file ); subviews.put(currentView, new ViewHolder( currentView, skin ));