* renamed AutoEpisodeListMatcher to AutoFetchEpisodeListMatcher
* fixed memory leak by not using FunctionList (would need to be disposed)
This commit is contained in:
parent
7b61757fd7
commit
90f58b06ff
|
@ -33,7 +33,7 @@ import net.sourceforge.filebot.web.SearchResult;
|
||||||
import net.sourceforge.tuned.FileUtilities;
|
import net.sourceforge.tuned.FileUtilities;
|
||||||
|
|
||||||
|
|
||||||
class AutoEpisodeListMatcher extends SwingWorker<List<Match<File, Episode>>, Void> {
|
class AutoFetchEpisodeListMatcher extends SwingWorker<List<Match<File, Episode>>, Void> {
|
||||||
|
|
||||||
private final List<File> files;
|
private final List<File> files;
|
||||||
|
|
||||||
|
@ -42,7 +42,7 @@ class AutoEpisodeListMatcher extends SwingWorker<List<Match<File, Episode>>, Voi
|
||||||
private final Collection<SimilarityMetric> metrics;
|
private final Collection<SimilarityMetric> metrics;
|
||||||
|
|
||||||
|
|
||||||
public AutoEpisodeListMatcher(EpisodeListClient client, List<File> files, Collection<SimilarityMetric> metrics) {
|
public AutoFetchEpisodeListMatcher(EpisodeListClient client, List<File> files, Collection<SimilarityMetric> metrics) {
|
||||||
this.client = client;
|
this.client = client;
|
||||||
this.files = new LinkedList<File>(files);
|
this.files = new LinkedList<File>(files);
|
||||||
this.metrics = new ArrayList<SimilarityMetric>(metrics);
|
this.metrics = new ArrayList<SimilarityMetric>(metrics);
|
||||||
|
@ -56,7 +56,7 @@ class AutoEpisodeListMatcher extends SwingWorker<List<Match<File, Episode>>, Voi
|
||||||
|
|
||||||
protected Collection<String> detectSeriesNames(Collection<File> files) {
|
protected Collection<String> detectSeriesNames(Collection<File> files) {
|
||||||
// detect series name(s) from files
|
// detect series name(s) from files
|
||||||
return new SeriesNameMatcher().matchAll(files.toArray(new File[files.size()]));
|
return new SeriesNameMatcher().matchAll(files.toArray(new File[0]));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -109,7 +109,7 @@ class AutoEpisodeListMatcher extends SwingWorker<List<Match<File, Episode>>, Voi
|
||||||
List<Match<File, Episode>> matches = new ArrayList<Match<File, Episode>>();
|
List<Match<File, Episode>> matches = new ArrayList<Match<File, Episode>>();
|
||||||
|
|
||||||
// group by subtitles first and then by files in general
|
// group by subtitles first and then by files in general
|
||||||
for (List<File> filesPerType : mapByFileType(files, MOVIE_FILES, SUBTITLE_FILES).values()) {
|
for (List<File> filesPerType : mapByFileType(mediaFiles, MOVIE_FILES, SUBTITLE_FILES).values()) {
|
||||||
Matcher<File, Episode> matcher = new Matcher<File, Episode>(filesPerType, episodes, metrics);
|
Matcher<File, Episode> matcher = new Matcher<File, Episode>(filesPerType, episodes, metrics);
|
||||||
matches.addAll(matcher.match());
|
matches.addAll(matcher.match());
|
||||||
}
|
}
|
|
@ -34,8 +34,6 @@ import net.sourceforge.filebot.web.TheTVDBClient;
|
||||||
import net.sourceforge.tuned.ExceptionUtil;
|
import net.sourceforge.tuned.ExceptionUtil;
|
||||||
import net.sourceforge.tuned.ui.ActionPopup;
|
import net.sourceforge.tuned.ui.ActionPopup;
|
||||||
import net.sourceforge.tuned.ui.LoadingOverlayPane;
|
import net.sourceforge.tuned.ui.LoadingOverlayPane;
|
||||||
import ca.odell.glazedlists.FunctionList;
|
|
||||||
import ca.odell.glazedlists.FunctionList.Function;
|
|
||||||
import ca.odell.glazedlists.event.ListEvent;
|
import ca.odell.glazedlists.event.ListEvent;
|
||||||
import ca.odell.glazedlists.event.ListEventListener;
|
import ca.odell.glazedlists.event.ListEventListener;
|
||||||
|
|
||||||
|
@ -166,15 +164,14 @@ public class RenamePanel extends FileBotPanel {
|
||||||
// clear names list
|
// clear names list
|
||||||
model.names().clear();
|
model.names().clear();
|
||||||
|
|
||||||
List<File> files = new FunctionList<FileEntry, File>(model.files(), new Function<FileEntry, File>() {
|
// gather File objects from model
|
||||||
|
List<File> files = new ArrayList<File>();
|
||||||
@Override
|
|
||||||
public File evaluate(FileEntry entry) {
|
|
||||||
return entry.getFile();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
AutoEpisodeListMatcher worker = new AutoEpisodeListMatcher(client, files, matchAction.getMetrics()) {
|
for (FileEntry entry : model.files()) {
|
||||||
|
files.add(entry.getFile());
|
||||||
|
}
|
||||||
|
|
||||||
|
AutoFetchEpisodeListMatcher worker = new AutoFetchEpisodeListMatcher(client, files, matchAction.getMetrics()) {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void done() {
|
protected void done() {
|
||||||
|
|
Loading…
Reference in New Issue