我正在使用设置为 -1.0 的指示器进度来显示loginprocess
运行时的一些加载。但是当我按下 Enter 按钮并使用 启动执行程序时loginProcess
,freezed
即使我使用Plataform.runLater
设置可见我的ProgressIndicator
.
我的按钮事件:
public void initManager(final LoginManager loginManager) {
btnEntrar.setOnAction(new EventHandler<ActionEvent>() {
@Override
public void handle(ActionEvent event) {
String email = loginTxtField.getText().trim();
String token = tokenTxtField.getText().trim();
if (email.equals("")) {
Platform.runLater(new Runnable() {
public void run() {
Dialog.showError("Erro", "Digite o e-mail");
}
});
return;
}
try {
Future future = loginProcess(email, token);
showLoginLoading(future);
future.get();
if (!loginGatewayFailed && !loginTargetAppFailed) {
Login loginTargetApp = new Login(email, null, null);
loginManager.autheticated(loginTargetApp, loginGateway, gateway, file);
} else {
if (loginTargetAppFailed) {
Platform.runLater(new Runnable() {
public void run() {
Dialog.showError("Erro", loginTargetAppFailedCause);
}
});
} else {
if (loginGatewayFailed) {
Platform.runLater(new Runnable() {
public void run() {
Dialog.showError("Erro", loginGatewayFailedCause);
}
});
}
}
}
} catch (final Exception ex) {
Logger.getLogger(LoginController.class.getName()).log(Level.SEVERE, ex.getMessage());
Platform.runLater(new Runnable() {
public void run() {
Dialog.showError("Erro", ex.getMessage());
}
});
}
}
});
}
我的登录过程:
public Future<?> loginProcess(String email, String token) throws Exception {
// MY PROCESS
return Executors.newSingleThreadExecutor().submit(new LoginTask(this, email, token));
} catch (Exception e) {
Logger.getLogger(LoginController.class.getName()).log(Level.SEVERE, e.getMessage());
throw e;
}
}
方法 showLoginLoading:
private void showLoginLoading(Future future) {
while (!future.isDone()) {
Platform.runLater(new Runnable() {
@Override
public void run() {
progressInd.setVisible(true);
// progressInd.setProgress(-1.0);
}
});
}
}