From 50a92d3faaa721e0c6b79fa7cdee27b6967508a0 Mon Sep 17 00:00:00 2001 From: Reinhard Pointner Date: Sun, 12 Jan 2014 19:22:14 +0000 Subject: [PATCH] * refactoring --- source/net/sourceforge/filebot/Main.java | 52 ++++++++++-------------- 1 file changed, 21 insertions(+), 31 deletions(-) diff --git a/source/net/sourceforge/filebot/Main.java b/source/net/sourceforge/filebot/Main.java index d9e449fa..f73b1aac 100644 --- a/source/net/sourceforge/filebot/Main.java +++ b/source/net/sourceforge/filebot/Main.java @@ -218,6 +218,7 @@ public class Main { // pre-load media.types and JNA/GIO (when loaded during DnD it will freeze the UI for a few hundred milliseconds) MediaTypes.getDefault(); + if (useGVFS()) { try { GVFS.getDefaultVFS(); @@ -226,11 +227,6 @@ public class Main { } } - // pre-load certain resources in the background - if (Boolean.parseBoolean(System.getProperty("application.warmup"))) { - warmupCachedResources(); - } - // check for application updates (only when installed, i.e. not running via fatjar or webstart) if (!"skip".equals(System.getProperty("application.update"))) { try { @@ -239,6 +235,11 @@ public class Main { Logger.getLogger(Main.class.getName()).log(Level.WARNING, "Failed to check for updates", e); } } + + // pre-load certain resources in the background + if (Boolean.parseBoolean(System.getProperty("application.warmup"))) { + warmupCachedResources(); + } } catch (Exception e) { // illegal arguments => just print CLI error message and stop System.err.println(e.getMessage()); @@ -400,34 +401,23 @@ public class Main { } private static void warmupCachedResources() { - Thread warmup = new Thread("warmupCachedResources") { + try { + // pre-load filter data + MediaDetection.getClutterFileFilter(); + MediaDetection.getDiskFolderFilter(); - @Override - public void run() { - try { - // pre-load filter data - MediaDetection.getClutterFileFilter(); - MediaDetection.getDiskFolderFilter(); + Collection empty = Collections.emptyList(); + MediaDetection.matchSeriesByDirectMapping(empty); - Collection empty = Collections.emptyList(); - MediaDetection.matchSeriesByDirectMapping(empty); - - // pre-load movie/series index - List dummy = Collections.singletonList(""); - MediaDetection.stripReleaseInfo(dummy, true); - MediaDetection.matchSeriesByName(dummy, -1, MediaDetection.getSeriesIndex()); - MediaDetection.matchSeriesByName(dummy, -1, MediaDetection.getAnimeIndex()); - MediaDetection.matchMovieName(dummy, true, -1); - } catch (Exception e) { - Logger.getLogger(getClass().getName()).log(Level.WARNING, e.getMessage(), e); - } - } - }; - - // start background thread - warmup.setDaemon(true); - warmup.setPriority(Thread.MIN_PRIORITY); - warmup.start(); + // pre-load movie/series index + List dummy = Collections.singletonList(""); + MediaDetection.stripReleaseInfo(dummy, true); + MediaDetection.matchSeriesByName(dummy, -1, MediaDetection.getSeriesIndex()); + MediaDetection.matchSeriesByName(dummy, -1, MediaDetection.getAnimeIndex()); + MediaDetection.matchMovieName(dummy, true, -1); + } catch (Exception e) { + Logger.getLogger(Main.class.getName()).log(Level.WARNING, e.getMessage(), e); + } } private static void restoreWindowBounds(final JFrame window, final Settings settings) {