Fix a casting issue

This commit is contained in:
Kai S. K. Engelbart 2020-07-31 22:52:42 +02:00
parent f339b8ed99
commit 6050e344fb
Signed by: kske
GPG Key ID: D905AB5048D69F06

View File

@ -15,6 +15,7 @@ import java.util.logging.Logger;
import javafx.animation.RotateTransition; import javafx.animation.RotateTransition;
import javafx.application.Platform; import javafx.application.Platform;
import javafx.collections.FXCollections; import javafx.collections.FXCollections;
import javafx.collections.ObservableList;
import javafx.collections.transformation.FilteredList; import javafx.collections.transformation.FilteredList;
import javafx.fxml.FXML; import javafx.fxml.FXML;
import javafx.scene.Node; import javafx.scene.Node;
@ -132,8 +133,8 @@ public final class ChatScene implements Restorable {
private static final Image DEFAULT_ATTACHMENT_VIEW_IMAGE = IconUtil.loadIconThemeSensitive("attachment_present", 20); private static final Image DEFAULT_ATTACHMENT_VIEW_IMAGE = IconUtil.loadIconThemeSensitive("attachment_present", 20);
private static final int MAX_MESSAGE_LENGTH = 255; private static final int MAX_MESSAGE_LENGTH = 255;
private static final int DEFAULT_ICON_SIZE = 16; private static final int DEFAULT_ICON_SIZE = 16;
private FilteredList<? extends Chat> chats; private FilteredList<Chat> chats;
/** /**
* Initializes the appearance of certain visual components. * Initializes the appearance of certain visual components.
@ -245,7 +246,7 @@ public final class ChatScene implements Restorable {
this.localDB = localDB; this.localDB = localDB;
this.client = client; this.client = client;
this.writeProxy = writeProxy; this.writeProxy = writeProxy;
chats = new FilteredList<>(FXCollections.observableList(localDB.getChats())); chats = new FilteredList<>(FXCollections.observableList(localDB.getChats()));
chatList.setItems(chats); chatList.setItems(chats);
contactLabel.setText(localDB.getUser().getName()); contactLabel.setText(localDB.getUser().getName());
@ -552,7 +553,7 @@ public final class ChatScene implements Restorable {
// Moving currentChat to the top // Moving currentChat to the top
Platform.runLater(() -> { Platform.runLater(() -> {
chats.getSource().remove(currentChat); chats.getSource().remove(currentChat);
chats.getSource().add(0, currentChat); ((ObservableList<Chat>) chats.getSource()).add(0, currentChat);
chatList.getSelectionModel().select(0); chatList.getSelectionModel().select(0);
localDB.getChats().remove(currentChat); localDB.getChats().remove(currentChat);
localDB.getChats().add(0, currentChat); localDB.getChats().add(0, currentChat);
@ -623,7 +624,7 @@ public final class ChatScene implements Restorable {
updateRemainingCharsLabel(); updateRemainingCharsLabel();
postButton.setDisable(messageText.isBlank()); postButton.setDisable(messageText.isBlank());
} }
@FXML @FXML
private void searchContacts() { private void searchContacts() {
chats.setPredicate(contactSearch.getText().isBlank() ? c -> true chats.setPredicate(contactSearch.getText().isBlank() ? c -> true