Use layer to set download listeners for continuous download

Signed-off-by: Taylor Smock <taylor.smock@kaart.com>
pull/1/head
Taylor Smock 2020-05-29 09:32:33 -06:00
rodzic 588508b73f
commit 4c15c59df5
Nie znaleziono w bazie danych klucza dla tego podpisu
ID klucza GPG: 625F6A74A3E4311A
3 zmienionych plików z 8 dodań i 2 usunięć

Wyświetl plik

@ -62,6 +62,6 @@ public final class DownloadListener implements DataSourceListener, Destroyable {
* Destroy all download listeners for MapWithAI
*/
public static void destroyAll() {
LISTENERS.forEach(DownloadListener::destroy);
new HashSet<>(LISTENERS).forEach(DownloadListener::destroy);
}
}

Wyświetl plik

@ -47,7 +47,6 @@ public class MapWithAIAction extends JosmAction {
.collect(Collectors.toList());
final OsmDataLayer layer = getOsmLayer(osmLayers);
if ((layer != null) && MapWithAIDataUtils.getMapWithAIData(MapWithAIDataUtils.getLayer(true), layer)) {
new DownloadListener(layer.getDataSet());
final Notification notification = createMessageDialog();
if (notification != null) {
notification.show();

Wyświetl plik

@ -284,6 +284,13 @@ public class MapWithAILayer extends OsmDataLayer implements ActiveLayerChangeLis
@Override
public void actionPerformed(ActionEvent e) {
layer.continuousDownload = !layer.continuousDownload;
if (layer.continuousDownload) {
for (OsmDataLayer data : MainApplication.getLayerManager().getLayersOfType(OsmDataLayer.class)) {
new DownloadListener(data.getDataSet());
}
} else {
DownloadListener.destroyAll();
}
}
@Override