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.
This commit is contained in:
0xboobface 2018-10-01 18:40:43 +02:00
parent 1dadd6b94b
commit 4cbb855bc6
2 changed files with 15 additions and 1 deletions

View File

@ -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

View File

@ -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<JavaFxModel> iterator = observableModels.iterator(); iterator.hasNext();) {