forked from j62/ctbrec
1
0
Fork 0

Improve filter updates

Filter matches are now updated as soon, as the stream resolution has
been determined for a model
This commit is contained in:
0xboobface 2020-03-19 15:21:57 +01:00
parent 243d2757b0
commit ad06218b78
2 changed files with 8 additions and 4 deletions

View File

@ -96,7 +96,7 @@ public class ThumbCell extends StackPane {
private boolean mouseHovering = false; private boolean mouseHovering = false;
private boolean recording = false; private boolean recording = false;
private static ExecutorService imageLoadingThreadPool = Executors.newFixedThreadPool(30); private static ExecutorService imageLoadingThreadPool = Executors.newFixedThreadPool(30);
private static LoadingCache<Model, int[]> resolutionCache = CacheBuilder.newBuilder() static LoadingCache<Model, int[]> resolutionCache = CacheBuilder.newBuilder()
.expireAfterAccess(5, TimeUnit.MINUTES) .expireAfterAccess(5, TimeUnit.MINUTES)
.maximumSize(10000) .maximumSize(10000)
.build(CacheLoader.from(ThumbCell::getStreamResolution)); .build(CacheLoader.from(ThumbCell::getStreamResolution));
@ -309,6 +309,7 @@ public class ThumbCell extends StackPane {
final String text = tagText; final String text = tagText;
final Paint c = resolutionBackgroundColor; final Paint c = resolutionBackgroundColor;
Platform.runLater(() -> { Platform.runLater(() -> {
String oldText = resolutionTag.getText();
resolutionTag.setText(text); resolutionTag.setText(text);
if (!mouseHovering) { if (!mouseHovering) {
resolutionTag.setVisible(true); resolutionTag.setVisible(true);
@ -316,6 +317,9 @@ public class ThumbCell extends StackPane {
} }
resolutionBackground.setWidth(resolutionTag.getBoundsInLocal().getWidth() + 4); resolutionBackground.setWidth(resolutionTag.getBoundsInLocal().getWidth() + 4);
resolutionBackground.setFill(c); resolutionBackground.setFill(c);
if (!Objects.equals(oldText, text)) {
parent.filter();
}
}); });
}); });
} }

View File

@ -101,7 +101,7 @@ public class ThumbOverviewTab extends Tab implements TabSelectionListener {
List<ThumbCell> filteredThumbCells = Collections.synchronizedList(new ArrayList<>()); List<ThumbCell> filteredThumbCells = Collections.synchronizedList(new ArrayList<>());
Recorder recorder; Recorder recorder;
String filter; private String filter;
ReentrantLock gridLock = new ReentrantLock(); ReentrantLock gridLock = new ReentrantLock();
ScrollPane scrollPane = new ScrollPane(); ScrollPane scrollPane = new ScrollPane();
boolean loginRequired; boolean loginRequired;
@ -711,7 +711,7 @@ public class ThumbOverviewTab extends Tab implements TabSelectionListener {
alert.showAndWait(); alert.showAndWait();
} }
private void filter() { void filter() {
Collections.sort(filteredThumbCells, (o1, o2) -> { Collections.sort(filteredThumbCells, (o1, o2) -> {
ThumbCell c1 = o1; ThumbCell c1 = o1;
ThumbCell c2 = o2; ThumbCell c2 = o2;
@ -794,7 +794,7 @@ public class ThumbOverviewTab extends Tab implements TabSelectionListener {
} }
private boolean modelPropertiesMatchToken(String token, Model m) throws IOException, ExecutionException { private boolean modelPropertiesMatchToken(String token, Model m) throws IOException, ExecutionException {
int[] resolution = Optional.ofNullable(m.getStreamResolution(true)).orElse(new int[2]); int[] resolution = Optional.ofNullable(ThumbCell.resolutionCache.getIfPresent(m)).orElse(new int[2]);
String searchText = createSearchText(m); String searchText = createSearchText(m);
boolean tokensMissing = false; boolean tokensMissing = false;
if (token.matches(">\\d+")) { if (token.matches(">\\d+")) {