mirror of
https://github.com/cryptomator/cryptomator.git
synced 2026-05-21 20:21:27 +00:00
dedup createTask
This commit is contained in:
@@ -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() {
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user