show progress percent while taking offer

This commit is contained in:
woodser 2023-03-11 08:02:08 -05:00
parent 9d87e30da0
commit 19d83749eb
2 changed files with 6 additions and 3 deletions

View File

@ -188,7 +188,6 @@ public class HavenoUtils {
try { try {
return xmrToAtomicUnits(new BigDecimal(input).doubleValue()); return xmrToAtomicUnits(new BigDecimal(input).doubleValue());
} catch (Exception e) { } catch (Exception e) {
log.warn("Exception at parseXmr: " + e.toString());
return BigInteger.valueOf(0); return BigInteger.valueOf(0);
} }
} }

View File

@ -407,7 +407,7 @@ public class OfferDetailsWindow extends Overlay<OfferDetailsWindow> {
placeOfferHandlerOptional.ifPresent(Runnable::run); placeOfferHandlerOptional.ifPresent(Runnable::run);
} else { } else {
State lastState = Trade.State.ARBITRATOR_PUBLISHED_DEPOSIT_TXS; 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); takeOfferHandlerOptional.ifPresent(Runnable::run);
// update trade state progress // update trade state progress
@ -415,7 +415,7 @@ public class OfferDetailsWindow extends Overlay<OfferDetailsWindow> {
Trade trade = tradeManager.getTrade(offer.getId()); Trade trade = tradeManager.getTrade(offer.getId());
if (trade == null) return; if (trade == null) return;
tradeStateSubscription = EasyBind.subscribe(trade.stateProperty(), newState -> { 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); spinnerInfoLabel.setText(Res.get("takeOffer.fundsBox.takeOfferSpinnerInfo") + " " + progress);
// unsubscribe when done // unsubscribe when done
@ -429,4 +429,8 @@ public class OfferDetailsWindow extends Overlay<OfferDetailsWindow> {
} }
}); });
} }
private static String getPercentString(int newOrdinal, int lastOrdinal) {
return (int) ((double) newOrdinal / (double) lastOrdinal * 100) + "%";
}
} }