move processing off UserThread for smoother experience

This commit is contained in:
woodser 2023-12-17 09:38:30 -05:00
parent ba9a9a3dcc
commit e6775f3b58
16 changed files with 276 additions and 215 deletions

View file

@ -20,6 +20,7 @@ package haveno.desktop.main.funds.deposit;
import com.google.common.base.Supplier;
import com.google.common.base.Suppliers;
import haveno.common.UserThread;
import haveno.core.locale.Res;
import haveno.core.trade.HavenoUtils;
import haveno.core.util.coin.CoinFormatter;
@ -65,9 +66,11 @@ class DepositListItem {
balanceListener = new XmrBalanceListener(addressEntry.getSubaddressIndex()) {
@Override
public void onBalanceChanged(BigInteger balance) {
DepositListItem.this.balanceAsBI = balance;
DepositListItem.this.balance.set(HavenoUtils.formatXmr(balanceAsBI));
updateUsage(addressEntry.getSubaddressIndex(), null);
UserThread.execute(() -> {
DepositListItem.this.balanceAsBI = balance;
DepositListItem.this.balance.set(HavenoUtils.formatXmr(balanceAsBI));
updateUsage(addressEntry.getSubaddressIndex(), null);
});
}
};
xmrWalletService.addBalanceListener(balanceListener);

View file

@ -902,13 +902,15 @@ public class TakeOfferView extends ActivatableViewAndModel<AnchorPane, TakeOffer
takeOfferBox.getChildren().add(takeOfferButton);
takeOfferBox.visibleProperty().addListener((observable, oldValue, newValue) -> {
if (newValue) {
fundingHBox.getChildren().remove(cancelButton2);
takeOfferBox.getChildren().add(cancelButton2);
} else if (!fundingHBox.getChildren().contains(cancelButton2)) {
takeOfferBox.getChildren().remove(cancelButton2);
fundingHBox.getChildren().add(cancelButton2);
}
UserThread.execute(() -> {
if (newValue) {
fundingHBox.getChildren().remove(cancelButton2);
takeOfferBox.getChildren().add(cancelButton2);
} else if (!fundingHBox.getChildren().contains(cancelButton2)) {
takeOfferBox.getChildren().remove(cancelButton2);
fundingHBox.getChildren().add(cancelButton2);
}
});
});
cancelButton2 = new AutoTooltipButton(Res.get("shared.cancel"));