forked from j62/ctbrec
Use model url for key in resolution cache
This commit is contained in:
parent
16dfc07a8e
commit
702de3b772
|
@ -88,7 +88,7 @@ public class ThumbCell extends StackPane {
|
|||
private boolean mouseHovering = false;
|
||||
private boolean recording = false;
|
||||
private static ExecutorService imageLoadingThreadPool = Executors.newFixedThreadPool(30);
|
||||
private static Cache<Model, int[]> resolutionCache = CacheBuilder.newBuilder()
|
||||
private static Cache<String, int[]> resolutionCache = CacheBuilder.newBuilder()
|
||||
.expireAfterAccess(4, TimeUnit.HOURS)
|
||||
.maximumSize(1000)
|
||||
.build();
|
||||
|
@ -277,7 +277,7 @@ public class ThumbCell extends StackPane {
|
|||
return;
|
||||
}
|
||||
|
||||
int[] resolution = resolutionCache.getIfPresent(model);
|
||||
int[] resolution = resolutionCache.getIfPresent(model.getUrl());
|
||||
if (resolution != null) {
|
||||
ThumbOverviewTab.threadPool.submit(() -> {
|
||||
try {
|
||||
|
@ -291,7 +291,7 @@ public class ThumbCell extends StackPane {
|
|||
try {
|
||||
ThumbOverviewTab.resolutionProcessing.add(model);
|
||||
int[] _resolution = model.getStreamResolution(false);
|
||||
resolutionCache.put(model, _resolution);
|
||||
resolutionCache.put(model.getUrl(), _resolution);
|
||||
updateResolutionTag(_resolution);
|
||||
|
||||
// the model is online, but the resolution is 0. probably something went wrong
|
||||
|
@ -324,22 +324,21 @@ public class ThumbCell extends StackPane {
|
|||
}
|
||||
|
||||
private void updateResolutionTag(int[] resolution) throws IOException, ExecutionException, InterruptedException {
|
||||
String _res = "n/a";
|
||||
Paint resolutionBackgroundColor = resolutionOnlineColor;
|
||||
String state = model.getOnlineState(false).toString();
|
||||
final String tagText;
|
||||
if (model.isOnline()) {
|
||||
LOG.trace("Model resolution {} {}x{}", model.getName(), resolution[0], resolution[1]);
|
||||
LOG.trace("Resolution queue size: {}", ThumbOverviewTab.queue.size());
|
||||
final int w = resolution[1];
|
||||
_res = w > 0 ? w != Integer.MAX_VALUE ? Integer.toString(w) : "HD" : state;
|
||||
tagText = w > 0 ? w != Integer.MAX_VALUE ? Integer.toString(w) : "HD" : state;
|
||||
} else {
|
||||
_res = model.getOnlineState(false).toString();
|
||||
tagText = state;
|
||||
resolutionBackgroundColor = resolutionOfflineColor;
|
||||
}
|
||||
final String resText = _res;
|
||||
final Paint c = resolutionBackgroundColor;
|
||||
Platform.runLater(() -> {
|
||||
resolutionTag.setText(resText);
|
||||
resolutionTag.setText(tagText);
|
||||
if(!mouseHovering) {
|
||||
resolutionTag.setVisible(true);
|
||||
resolutionBackground.setVisible(true);
|
||||
|
|
Loading…
Reference in New Issue