* refactoring

This commit is contained in:
Reinhard Pointner 2014-01-12 19:22:14 +00:00
parent 47982a63f6
commit 50a92d3faa
1 changed files with 21 additions and 31 deletions

View File

@ -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<File> empty = Collections.emptyList();
MediaDetection.matchSeriesByDirectMapping(empty);
Collection<File> empty = Collections.emptyList();
MediaDetection.matchSeriesByDirectMapping(empty);
// pre-load movie/series index
List<String> 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<String> 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) {