Ticket #23841: 23841.jmapviewer.patch

File 23841.jmapviewer.patch, 2.4 KB (added by taylor.smock, 8 months ago)
  • src/org/openstreetmap/gui/jmapviewer/interfaces/TileCache.java

    Subject: [PATCH] #23841: Bing: Automatically reload all tiles with `Error: Attribution is not loaded yet` after su...
    ---
    IDEA additional info:
    Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
    <+>UTF-8
    diff --git a/src/org/openstreetmap/gui/jmapviewer/interfaces/TileCache.java b/src/org/openstreetmap/gui/jmapviewer/interfaces/TileCache.java
    a b  
    4848     */
    4949    void clear();
    5050
     51    /**
     52     * Removes error tiles from memory.
     53     * This is implementation specific; the default calls {@link #clear()}.
     54     */
     55    default void clearErrorTiles() {
     56        this.clear();
     57    }
     58
    5159    /**
    5260     * Size of the cache.
    5361     * @return maximum number of tiles in cache
  • src/org/openstreetmap/gui/jmapviewer/MemoryTileCache.java

    IDEA additional info:
    Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
    <+>UTF-8
    diff --git a/src/org/openstreetmap/gui/jmapviewer/MemoryTileCache.java b/src/org/openstreetmap/gui/jmapviewer/MemoryTileCache.java
    a b  
    11// License: GPL. For details, see Readme.txt file.
    22package org.openstreetmap.gui.jmapviewer;
    33
     4import java.util.Collection;
    45import java.util.HashMap;
    56import java.util.Map;
    67import java.util.logging.Level;
    78import java.util.logging.Logger;
     9import java.util.stream.Collectors;
    810
    911import org.openstreetmap.gui.jmapviewer.interfaces.TileCache;
    1012import org.openstreetmap.gui.jmapviewer.interfaces.TileSource;
     
    103105        lruTiles.clear();
    104106    }
    105107
     108    @Override
     109    public synchronized void clearErrorTiles() {
     110        Collection<CacheEntry> toRemove = hash.values().stream().filter(cacheEntry -> cacheEntry.tile.hasError()).collect(Collectors.toList());
     111        hash.values().removeAll(toRemove);
     112        toRemove.forEach(lruTiles::removeEntry);
     113    }
     114
    106115    @Override
    107116    public synchronized int getTileCount() {
    108117        return hash.size();