dedup createTask

This commit is contained in:
Jan-Peter Klein
2026-01-23 16:09:06 +01:00
parent aa898c634f
commit 8b05ae0a54
3 changed files with 27 additions and 32 deletions

View File

@@ -138,7 +138,7 @@ public class RecoveryKeyCreationController implements FxController {
@FXML
public void restoreWithPasswordAsync() {
Task<Void> task = createTask(this::restoreWithPassword);
Task<Void> task = RecoveryKeyTasks.createTask(this::restoreWithPassword);
task.setOnScheduled(_ -> {
LOG.debug("Restoring vault configuration with password for {}.", vault.getDisplayablePath());
@@ -196,21 +196,6 @@ public class RecoveryKeyCreationController implements FxController {
window.close();
}
@FunctionalInterface
private interface TaskAction {
void run() throws Exception;
}
private Task<Void> createTask(TaskAction action) {
return new Task<Void>() {
@Override
protected Void call() throws Exception {
action.run();
return null;
}
};
}
private class RecoveryKeyCreationTask extends Task<String> {
private RecoveryKeyCreationTask() {

View File

@@ -125,7 +125,7 @@ public class RecoveryKeyResetPasswordController implements FxController {
@FXML
public void restorePasswordAsync() {
Task<Void> task = createTask(this::restorePassword);
Task<Void> task = RecoveryKeyTasks.createTask(this::restorePassword);
task.setOnScheduled(_ -> {
LOG.debug("Restoring vault configuration for {}.", vault.getDisplayablePath());
@@ -196,21 +196,6 @@ public class RecoveryKeyResetPasswordController implements FxController {
executor.submit(task);
}
@FunctionalInterface
private interface TaskAction {
void run() throws Exception;
}
private Task<Void> createTask(TaskAction action) {
return new Task<Void>() {
@Override
protected Void call() throws Exception {
action.run();
return null;
}
};
}
private class ResetPasswordTask extends Task<Void> {
private static final Logger LOG = LoggerFactory.getLogger(ResetPasswordTask.class);

View File

@@ -0,0 +1,25 @@
package org.cryptomator.ui.recoverykey;
import javafx.concurrent.Task;
final class RecoveryKeyTasks {
private RecoveryKeyTasks() {
}
@FunctionalInterface
interface TaskAction {
void run() throws Exception;
}
static Task<Void> createTask(TaskAction action) {
return new Task<Void>() {
@Override
protected Void call() throws Exception {
action.run();
return null;
}
};
}
}