Ignore:
Timestamp:
2015-09-01T22:57:30+02:00 (9 years ago)
Author:
wiktorn
Message:

Do not block in EDT thread, when waiting for attribution download. Closes: #11821

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/openstreetmap/josm/data/imagery/CachedAttributionBingAerialTileSource.java

    r8624 r8714  
    1010
    1111import org.openstreetmap.gui.jmapviewer.tilesources.BingAerialTileSource;
     12import org.openstreetmap.gui.jmapviewer.tilesources.TileSourceInfo;
    1213import org.openstreetmap.josm.Main;
     14import org.openstreetmap.josm.gui.util.GuiHelper;
    1315import org.openstreetmap.josm.io.CacheCustomContent;
    1416import org.openstreetmap.josm.io.UTFInputStreamReader;
     
    2325 */
    2426public class CachedAttributionBingAerialTileSource extends BingAerialTileSource {
     27    private Runnable attributionDownloadedTask;
     28
    2529    /**
    2630     * Creates tile source
     
    3034        super(info);
    3135    }
     36
     37    /**
     38     * Creates tile source
     39     * @param info ImageryInfo description of this tile source
     40     * @param attributionDownloadedTask runnable to be executed once attribution is loaded
     41     */
     42
     43    public CachedAttributionBingAerialTileSource(TileSourceInfo info, Runnable attributionDownloadedTask) {
     44        super(info);
     45        this.attributionDownloadedTask = attributionDownloadedTask;
     46    }
     47
    3248
    3349    class BingAttributionData extends CacheCustomContent<IOException> {
     
    5975                    try {
    6076                        String xml = attributionLoader.updateIfRequiredString();
    61                         return parseAttributionText(new InputSource(new StringReader((xml))));
     77                        List<Attribution> ret = parseAttributionText(new InputSource(new StringReader((xml))));
     78                        if (attributionDownloadedTask != null) {
     79                            GuiHelper.runInEDT(attributionDownloadedTask);
     80                            attributionDownloadedTask = null;
     81                        }
     82                        return ret;
    6283                    } catch (IOException ex) {
    6384                        Main.warn("Could not connect to Bing API. Will retry in " + waitTimeSec + " seconds.");
Note: See TracChangeset for help on using the changeset viewer.