From 4cbb855bc6febe6a0a442413775cebb0868051cf Mon Sep 17 00:00:00 2001 From: 0xboobface <0xboobface@gmail.com> Date: Mon, 1 Oct 2018 18:40:43 +0200 Subject: [PATCH] Update the online property of JavaFxModel With the refactoring of the model / chaturbate class, the online property of JavaFxModel was not updated anymore, so that the checkbox in the table would never update. --- src/main/java/ctbrec/ui/JavaFxModel.java | 6 ++++++ src/main/java/ctbrec/ui/RecordedModelsTab.java | 10 +++++++++- 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/src/main/java/ctbrec/ui/JavaFxModel.java b/src/main/java/ctbrec/ui/JavaFxModel.java index fe0f9072..1e9d7579 100644 --- a/src/main/java/ctbrec/ui/JavaFxModel.java +++ b/src/main/java/ctbrec/ui/JavaFxModel.java @@ -1,6 +1,9 @@ package ctbrec.ui; +import java.io.IOException; import java.util.List; +import java.util.Objects; +import java.util.concurrent.ExecutionException; import ctbrec.Model; import javafx.beans.property.BooleanProperty; @@ -16,6 +19,9 @@ public class JavaFxModel extends Model { public JavaFxModel(Model delegate) { this.delegate = delegate; + try { + onlineProperty.set(Objects.equals("public", delegate.getOnlineState(true))); + } catch (IOException | ExecutionException e) {} } @Override diff --git a/src/main/java/ctbrec/ui/RecordedModelsTab.java b/src/main/java/ctbrec/ui/RecordedModelsTab.java index a7fa9843..cde8e52f 100644 --- a/src/main/java/ctbrec/ui/RecordedModelsTab.java +++ b/src/main/java/ctbrec/ui/RecordedModelsTab.java @@ -5,6 +5,7 @@ import java.security.InvalidKeyException; import java.security.NoSuchAlgorithmException; import java.util.Iterator; import java.util.List; +import java.util.Objects; import java.util.concurrent.ExecutionException; import java.util.concurrent.ExecutorService; import java.util.concurrent.Executors; @@ -149,8 +150,15 @@ public class RecordedModelsTab extends Tab implements TabSelectionListener { return; } for (Model model : models) { - if (!observableModels.contains(model)) { + int index = observableModels.indexOf(model); + if (index == -1) { observableModels.add(new JavaFxModel(model)); + } else { + // make sure to update the JavaFX online property, so that the table cell is updated + try { + JavaFxModel javaFxModel = observableModels.get(index); + javaFxModel.getOnlineProperty().set(Objects.equals("public", javaFxModel.getOnlineState())); + } catch (IOException | ExecutionException e) {} } } for (Iterator iterator = observableModels.iterator(); iterator.hasNext();) {