Forráskód Böngészése

optimised cellSize binding and removed unused imports

Jan-Peter Klein 8 hónapja
szülő
commit
2d96d2e5c6

+ 0 - 2
src/main/java/org/cryptomator/ui/mainwindow/VaultListCellController.java

@@ -10,8 +10,6 @@ import org.cryptomator.ui.controls.FontAwesome5Icon;
 import org.cryptomator.ui.controls.FontAwesome5IconView;
 
 import javax.inject.Inject;
-import javafx.beans.binding.Bindings;
-import javafx.beans.binding.BooleanBinding;
 import javafx.beans.property.ObjectProperty;
 import javafx.beans.property.SimpleObjectProperty;
 import javafx.beans.value.ObservableValue;

+ 9 - 6
src/main/java/org/cryptomator/ui/mainwindow/VaultListController.java

@@ -71,8 +71,7 @@ public class VaultListController implements FxController {
 	private final BooleanProperty draggingVaultOver = new SimpleBooleanProperty();
 	private final ResourceBundle resourceBundle;
 	private final FxApplicationWindows appWindows;
-	private final Settings settings;
-
+	private final ObservableValue<Double> cellSize;
 	public ListView<Vault> vaultList;
 	public StackPane root;
 	@FXML
@@ -102,20 +101,17 @@ public class VaultListController implements FxController {
 		this.vaultListManager = vaultListManager;
 		this.resourceBundle = resourceBundle;
 		this.appWindows = appWindows;
-		this.settings = settings;
 
 		this.emptyVaultList = Bindings.isEmpty(vaults);
 
 		selectedVault.addListener(this::selectedVaultDidChange);
+		cellSize = settings.compactMode.map(compact -> compact ? 30.0 : 60.0);
 	}
 
 	public void initialize() {
 		vaultList.setItems(vaults);
 		vaultList.setCellFactory(cellFactory);
 
-		vaultList.fixedCellSizeProperty().bind(Bindings.createDoubleBinding(() ->
-				settings.compactMode.get() ? 30.0 : 60.0, settings.compactMode));
-
 		selectedVault.bind(vaultList.getSelectionModel().selectedItemProperty());
 		vaults.addListener((ListChangeListener.Change<? extends Vault> c) -> {
 			while (c.next()) {
@@ -280,5 +276,12 @@ public class VaultListController implements FxController {
 		return draggingVaultOver.get();
 	}
 
+	public ObservableValue<Double> cellSizeProperty() {
+		return cellSize;
+	}
+
+	public Double getCellSize() {
+		return cellSize.getValue();
+	}
 
 }

+ 1 - 1
src/main/resources/fxml/vault_list.fxml

@@ -18,7 +18,7 @@
 		   minWidth="206">
 	<VBox>
 		<StackPane VBox.vgrow="ALWAYS">
-			<ListView fx:id="vaultList" editable="true" fixedCellSize="60">
+			<ListView fx:id="vaultList" editable="true" fixedCellSize="${controller.cellSize}">
 				<contextMenu>
 					<fx:include source="vault_list_contextmenu.fxml"/>
 				</contextMenu>