From fd90002a606c442be23b4de68555d9c15b0faffe Mon Sep 17 00:00:00 2001 From: myk Date: Wed, 20 Mar 2013 17:13:19 +0000 Subject: [PATCH] invalidate the image cache after downloading new images so the new images can be loaded if they were previously cached as not found --- src/main/java/forge/ImageCache.java | 5 +++++ src/main/java/forge/gui/download/GuiDownloader.java | 6 ++++-- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/src/main/java/forge/ImageCache.java b/src/main/java/forge/ImageCache.java index 3afc749601b..c3150e60b54 100644 --- a/src/main/java/forge/ImageCache.java +++ b/src/main/java/forge/ImageCache.java @@ -83,6 +83,11 @@ public class ImageCache { e.printStackTrace(); } } + + public static void clear() { + CACHE.invalidateAll(); + } + /** * retrieve an image from the cache. returns null if the image is not found in the cache * and cannot be loaded from disk. pass -1 for width and/or height to avoid resizing in that dimension. diff --git a/src/main/java/forge/gui/download/GuiDownloader.java b/src/main/java/forge/gui/download/GuiDownloader.java index a87c0e01627..19eca72396f 100644 --- a/src/main/java/forge/gui/download/GuiDownloader.java +++ b/src/main/java/forge/gui/download/GuiDownloader.java @@ -55,6 +55,7 @@ import org.apache.commons.lang3.tuple.Pair; import com.esotericsoftware.minlog.Log; import forge.Command; +import forge.ImageCache; import forge.error.BugReporter; import forge.gui.SOverlayUtils; import forge.gui.toolbox.FButton; @@ -70,12 +71,14 @@ import forge.util.MyRandom; @SuppressWarnings("serial") public abstract class GuiDownloader extends DefaultBoundedRangeModel implements Runnable { - public static final Proxy.Type[] TYPES = Proxy.Type.values(); /** */ + public static final Proxy.Type[] TYPES = Proxy.Type.values(); // Actions and commands private final ActionListener actStartDownload = new ActionListener() { @Override public void actionPerformed(final ActionEvent e) { + // invalidate image cache so newly downloaded images will be loaded + ImageCache.clear(); new Thread(GuiDownloader.this).start(); btnStart.setEnabled(false); } @@ -374,5 +377,4 @@ public abstract class GuiDownloader extends DefaultBoundedRangeModel implements } } } - }