From 19d83749eb2a2a71540e3d14428e581032c62039 Mon Sep 17 00:00:00 2001 From: woodser Date: Sat, 11 Mar 2023 08:02:08 -0500 Subject: [PATCH] show progress percent while taking offer --- core/src/main/java/haveno/core/trade/HavenoUtils.java | 1 - .../desktop/main/overlays/windows/OfferDetailsWindow.java | 8 ++++++-- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/core/src/main/java/haveno/core/trade/HavenoUtils.java b/core/src/main/java/haveno/core/trade/HavenoUtils.java index dd66e515..d74eab23 100644 --- a/core/src/main/java/haveno/core/trade/HavenoUtils.java +++ b/core/src/main/java/haveno/core/trade/HavenoUtils.java @@ -188,7 +188,6 @@ public class HavenoUtils { try { return xmrToAtomicUnits(new BigDecimal(input).doubleValue()); } catch (Exception e) { - log.warn("Exception at parseXmr: " + e.toString()); return BigInteger.valueOf(0); } } diff --git a/desktop/src/main/java/haveno/desktop/main/overlays/windows/OfferDetailsWindow.java b/desktop/src/main/java/haveno/desktop/main/overlays/windows/OfferDetailsWindow.java index d16bd689..15891c39 100644 --- a/desktop/src/main/java/haveno/desktop/main/overlays/windows/OfferDetailsWindow.java +++ b/desktop/src/main/java/haveno/desktop/main/overlays/windows/OfferDetailsWindow.java @@ -407,7 +407,7 @@ public class OfferDetailsWindow extends Overlay { placeOfferHandlerOptional.ifPresent(Runnable::run); } else { State lastState = Trade.State.ARBITRATOR_PUBLISHED_DEPOSIT_TXS; - spinnerInfoLabel.setText(Res.get("takeOffer.fundsBox.takeOfferSpinnerInfo") + " 1/" + (lastState.ordinal() + 1)); + spinnerInfoLabel.setText(Res.get("takeOffer.fundsBox.takeOfferSpinnerInfo") + " " + getPercentString(0, lastState.ordinal())); takeOfferHandlerOptional.ifPresent(Runnable::run); // update trade state progress @@ -415,7 +415,7 @@ public class OfferDetailsWindow extends Overlay { Trade trade = tradeManager.getTrade(offer.getId()); if (trade == null) return; tradeStateSubscription = EasyBind.subscribe(trade.stateProperty(), newState -> { - String progress = (newState.ordinal() + 1) + "/" + (lastState.ordinal() + 1); + String progress = getPercentString(newState.ordinal(), lastState.ordinal()); spinnerInfoLabel.setText(Res.get("takeOffer.fundsBox.takeOfferSpinnerInfo") + " " + progress); // unsubscribe when done @@ -429,4 +429,8 @@ public class OfferDetailsWindow extends Overlay { } }); } + + private static String getPercentString(int newOrdinal, int lastOrdinal) { + return (int) ((double) newOrdinal / (double) lastOrdinal * 100) + "%"; + } }