mirror of
https://github.com/HMCL-dev/HMCL.git
synced 2025-09-16 07:16:27 -04:00
feat: show spinner while refreshing account
This commit is contained in:
parent
e3fa7428bf
commit
454cc1e702
@ -100,7 +100,7 @@ public class AccountListItem extends RadioButton {
|
|||||||
return new AccountListItemSkin(this);
|
return new AccountListItemSkin(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
private Task<?> refreshAsync() {
|
public Task<?> refreshAsync() {
|
||||||
return Task.runAsync(() -> {
|
return Task.runAsync(() -> {
|
||||||
account.clearCache();
|
account.clearCache();
|
||||||
try {
|
try {
|
||||||
@ -121,10 +121,6 @@ public class AccountListItem extends RadioButton {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
public void refresh() {
|
|
||||||
refreshAsync().whenComplete(e -> {}).start();
|
|
||||||
}
|
|
||||||
|
|
||||||
public ObservableBooleanValue canUploadSkin() {
|
public ObservableBooleanValue canUploadSkin() {
|
||||||
if (account instanceof YggdrasilAccount) {
|
if (account instanceof YggdrasilAccount) {
|
||||||
if (account instanceof AuthlibInjectorAccount) {
|
if (account instanceof AuthlibInjectorAccount) {
|
||||||
|
@ -89,11 +89,18 @@ public class AccountListItemSkin extends SkinBase<AccountListItem> {
|
|||||||
right.setAlignment(Pos.CENTER_RIGHT);
|
right.setAlignment(Pos.CENTER_RIGHT);
|
||||||
|
|
||||||
JFXButton btnRefresh = new JFXButton();
|
JFXButton btnRefresh = new JFXButton();
|
||||||
btnRefresh.setOnMouseClicked(e -> skinnable.refresh());
|
SpinnerPane spinnerRefresh = new SpinnerPane();
|
||||||
|
btnRefresh.setOnMouseClicked(e -> {
|
||||||
|
spinnerRefresh.showSpinner();
|
||||||
|
skinnable.refreshAsync()
|
||||||
|
.whenComplete(ex -> spinnerRefresh.hideSpinner())
|
||||||
|
.start();
|
||||||
|
});
|
||||||
btnRefresh.getStyleClass().add("toggle-icon4");
|
btnRefresh.getStyleClass().add("toggle-icon4");
|
||||||
btnRefresh.setGraphic(SVG.refresh(Theme.blackFillBinding(), -1, -1));
|
btnRefresh.setGraphic(SVG.refresh(Theme.blackFillBinding(), -1, -1));
|
||||||
runInFX(() -> FXUtils.installFastTooltip(btnRefresh, i18n("button.refresh")));
|
runInFX(() -> FXUtils.installFastTooltip(btnRefresh, i18n("button.refresh")));
|
||||||
right.getChildren().add(btnRefresh);
|
spinnerRefresh.setContent(btnRefresh);
|
||||||
|
right.getChildren().add(spinnerRefresh);
|
||||||
|
|
||||||
JFXButton btnUpload = new JFXButton();
|
JFXButton btnUpload = new JFXButton();
|
||||||
SpinnerPane spinnerUpload = new SpinnerPane();
|
SpinnerPane spinnerUpload = new SpinnerPane();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user