mirror of
https://github.com/haveno-dex/haveno.git
synced 2025-04-19 23:36:00 -04:00
Fix bug with total amount
This commit is contained in:
parent
b71ce2fc37
commit
530b15147c
@ -76,7 +76,6 @@ class MarketsStatisticViewModel extends ActivatableViewModel {
|
||||
offersByCurrencyMap.get(currencyCode).add(offer);
|
||||
}
|
||||
marketStatisticItems.clear();
|
||||
long totalAmount = 0;
|
||||
for (String currencyCode : offersByCurrencyMap.keySet()) {
|
||||
List<Offer> offers = offersByCurrencyMap.get(currencyCode);
|
||||
List<Offer> buyOffers = offers
|
||||
@ -105,14 +104,11 @@ class MarketsStatisticViewModel extends ActivatableViewModel {
|
||||
Fiat bestSellOfferPrice = sellOffers.isEmpty() ? null : sellOffers.get(0).getPrice();
|
||||
|
||||
Fiat spread = null;
|
||||
if (bestBuyOfferPrice != null && bestSellOfferPrice != null) {
|
||||
if (bestBuyOfferPrice != null && bestSellOfferPrice != null)
|
||||
spread = bestSellOfferPrice.subtract(bestBuyOfferPrice);
|
||||
}
|
||||
|
||||
for (Offer offer : offers) {
|
||||
totalAmount += offer.getAmount().getValue();
|
||||
}
|
||||
marketStatisticItems.add(new MarketStatisticItem(currencyCode, offers.size(), spread, Coin.valueOf(totalAmount)));
|
||||
Coin totalAmount = Coin.valueOf(offers.stream().mapToLong(offer -> offer.getAmount().getValue()).sum());
|
||||
marketStatisticItems.add(new MarketStatisticItem(currencyCode, offers.size(), spread, totalAmount));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -206,10 +206,14 @@ public class MarketsStatisticsView extends ActivatableViewAndModel<GridPane, Mar
|
||||
@Override
|
||||
public void updateItem(final MarketStatisticItem item, boolean empty) {
|
||||
super.updateItem(item, empty);
|
||||
if (item != null && !empty && item.spread != null)
|
||||
setText(formatter.formatFiatWithCode(item.spread));
|
||||
else
|
||||
if (item != null && !empty) {
|
||||
if (item.spread != null)
|
||||
setText(formatter.formatFiatWithCode(item.spread));
|
||||
else
|
||||
setText("-");
|
||||
} else {
|
||||
setText("");
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user