Merge pull request #3539 from devinbileck/fix-btc-valuation-popups

Fix BTC valuation popups
This commit is contained in:
Florian Reimair 2019-11-01 11:36:35 +01:00 committed by GitHub
commit 901cde0ad9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 23 additions and 6 deletions

View File

@ -256,11 +256,12 @@ public class MainView extends InitializableView<StackPane, MainViewModel>
protected Tooltip computeValue() {
String tooltipText = Res.get("mainView.balance.available");
try {
String preferredTradeCurrency = model.getPreferences().getPreferredTradeCurrency().getCode();
double availableBalance = Double.parseDouble(
model.getAvailableBalance().getValue().replace("BTC", ""));
double marketPrice = Double.parseDouble(model.getMarketPrice().getValue());
double marketPrice = Double.parseDouble(model.getMarketPrice(preferredTradeCurrency).getValue());
tooltipText += "\n" + currencyFormat.format(availableBalance * marketPrice) +
" " + model.getPreferences().getPreferredTradeCurrency().getCode();
" " + preferredTradeCurrency;
} catch (NullPointerException | NumberFormatException e) {
// Either the balance or market price is not available yet
}
@ -280,11 +281,12 @@ public class MainView extends InitializableView<StackPane, MainViewModel>
protected Tooltip computeValue() {
String tooltipText = Res.get("mainView.balance.reserved");
try {
String preferredTradeCurrency = model.getPreferences().getPreferredTradeCurrency().getCode();
double reservedBalance = Double.parseDouble(
model.getReservedBalance().getValue().replace("BTC", ""));
double marketPrice = Double.parseDouble(model.getMarketPrice().getValue());
double marketPrice = Double.parseDouble(model.getMarketPrice(preferredTradeCurrency).getValue());
tooltipText += "\n" + currencyFormat.format(reservedBalance * marketPrice) +
" " + model.getPreferences().getPreferredTradeCurrency().getCode();
" " + preferredTradeCurrency;
} catch (NullPointerException | NumberFormatException e) {
// Either the balance or market price is not available yet
}
@ -304,11 +306,12 @@ public class MainView extends InitializableView<StackPane, MainViewModel>
protected Tooltip computeValue() {
String tooltipText = Res.get("mainView.balance.locked");
try {
String preferredTradeCurrency = model.getPreferences().getPreferredTradeCurrency().getCode();
double lockedBalance = Double.parseDouble(
model.getLockedBalance().getValue().replace("BTC", ""));
double marketPrice = Double.parseDouble(model.getMarketPrice().getValue());
double marketPrice = Double.parseDouble(model.getMarketPrice(preferredTradeCurrency).getValue());
tooltipText += "\n" + currencyFormat.format(lockedBalance * marketPrice) +
" " + model.getPreferences().getPreferredTradeCurrency().getCode();
" " + preferredTradeCurrency;
} catch (NullPointerException | NumberFormatException e) {
// Either the balance or market price is not available yet
}

View File

@ -607,6 +607,10 @@ public class MainViewModel implements ViewModel, BisqSetup.BisqSetupListener {
return marketPricePresentation.getMarketPrice();
}
StringProperty getMarketPrice(String currencyCode) {
return marketPricePresentation.getMarketPrice(currencyCode);
}
public ObservableList<PriceFeedComboBoxItem> getPriceFeedComboBoxItems() {
return marketPricePresentation.getPriceFeedComboBoxItems();
}

View File

@ -242,4 +242,14 @@ public class MarketPricePresentation {
public StringProperty getMarketPrice() {
return marketPrice;
}
public StringProperty getMarketPrice(String currencyCode) {
SimpleStringProperty marketPrice = new SimpleStringProperty(Res.get("shared.na"));
try {
marketPrice.set(String.valueOf(priceFeedService.getMarketPrice(currencyCode).getPrice()));
} catch (NullPointerException e) {
// Market price is not available yet
}
return marketPrice;
}
}