From 7de1c94167bcb67766790a4122b7b0d41b900ab5 Mon Sep 17 00:00:00 2001 From: Reinhard Pointner Date: Sun, 19 Jan 2014 15:08:28 +0000 Subject: [PATCH] * refactor --- source/net/sourceforge/filebot/Main.java | 25 +------------------ .../filebot/media/MediaDetection.java | 22 ++++++++++++++++ 2 files changed, 23 insertions(+), 24 deletions(-) diff --git a/source/net/sourceforge/filebot/Main.java b/source/net/sourceforge/filebot/Main.java index a5f87dde..ba22087a 100644 --- a/source/net/sourceforge/filebot/Main.java +++ b/source/net/sourceforge/filebot/Main.java @@ -30,9 +30,6 @@ import java.security.PermissionCollection; import java.security.Permissions; import java.security.Policy; import java.security.ProtectionDomain; -import java.util.Collection; -import java.util.Collections; -import java.util.List; import java.util.Locale; import java.util.Properties; import java.util.Scanner; @@ -240,7 +237,7 @@ public class Main { // pre-load certain resources in the background if (Boolean.parseBoolean(System.getProperty("application.warmup"))) { - warmupCachedResources(); + MediaDetection.warmupCachedResources(); } } catch (Exception e) { // illegal arguments => just print CLI error message and stop @@ -402,26 +399,6 @@ public class Main { Analytics.trackEvent("GUI", "Donate", "r" + currentRev, pane.getValue() == actions[0] ? 1 : 0); } - private static void warmupCachedResources() { - try { - // pre-load filter data - MediaDetection.getClutterFileFilter(); - MediaDetection.getDiskFolderFilter(); - - 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(Main.class.getName()).log(Level.WARNING, e.getMessage(), e); - } - } - private static void restoreWindowBounds(final JFrame window, final Settings settings) { // store bounds on close window.addWindowListener(new WindowAdapter() { diff --git a/source/net/sourceforge/filebot/media/MediaDetection.java b/source/net/sourceforge/filebot/media/MediaDetection.java index 540203d8..b57feda2 100644 --- a/source/net/sourceforge/filebot/media/MediaDetection.java +++ b/source/net/sourceforge/filebot/media/MediaDetection.java @@ -18,6 +18,7 @@ import java.text.CollationKey; import java.text.Collator; import java.util.ArrayList; import java.util.Collection; +import java.util.Collections; import java.util.Comparator; import java.util.HashMap; import java.util.HashSet; @@ -1286,4 +1287,25 @@ public class MediaDetection { } } } + + public static void warmupCachedResources() { + try { + // pre-load filter data + MediaDetection.getClutterFileFilter(); + MediaDetection.getDiskFolderFilter(); + + 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(MediaDetection.class.getName()).log(Level.WARNING, e.getMessage(), e); + } + } + }