Add static method getTradeStatisticsForCurrency and

use it instead of updateSelectedTradeStatistics
(preparation for follow up commit)
This commit is contained in:
chimp1984 2021-11-01 21:23:44 +01:00
parent 0271af995b
commit ca145b0eb3
No known key found for this signature in database
GPG Key ID: 9801B4EC591F90E3

View File

@ -168,7 +168,11 @@ class TradesChartsViewModel extends ActivatableViewModel {
this.usdAveragePriceMapsPerTickUnit.clear();
this.usdAveragePriceMapsPerTickUnit.putAll(usdAveragePriceMapsPerTickUnit);
updateSelectedTradeStatistics(getCurrencyCode());
List<TradeStatistics3> list = getTradeStatisticsForCurrency(tradeStatisticsManager.getObservableTradeStatisticsSet(),
getCurrencyCode(),
showAllTradeCurrenciesProperty.get());
selectedTradeStatistics.setAll(list);
updateChartData();
modelReady.set(true);
});
@ -318,6 +322,14 @@ class TradesChartsViewModel extends ActivatableViewModel {
.collect(Collectors.toList()));
}
private static List<TradeStatistics3> getTradeStatisticsForCurrency(Set<TradeStatistics3> tradeStatisticsSet,
String currencyCode,
boolean showAllTradeCurrencies) {
return tradeStatisticsSet.stream()
.filter(e -> showAllTradeCurrencies || e.getCurrency().equals(currencyCode))
.collect(Collectors.toList());
}
private void updateSelectedTradeStatistics(String currencyCode) {
selectedTradeStatistics.setAll(tradeStatisticsManager.getObservableTradeStatisticsSet().stream()
.filter(e -> showAllTradeCurrenciesProperty.get() || e.getCurrency().equals(currencyCode))