mirror of
https://github.com/haveno-dex/haveno.git
synced 2025-07-24 07:30:54 -04:00
sort traditional currencies after fiat currencies in combined pull down (#1864)
This commit is contained in:
parent
fd664d1d30
commit
12483df705
3 changed files with 13 additions and 4 deletions
|
@ -93,7 +93,7 @@ public class CurrencyUtil {
|
|||
public static Collection<TraditionalCurrency> getAllSortedFiatCurrencies(Comparator comparator) {
|
||||
return getAllSortedTraditionalCurrencies(comparator).stream()
|
||||
.filter(currency -> CurrencyUtil.isFiatCurrency(currency.getCode()))
|
||||
.collect(Collectors.toList()); // sorted by currency name
|
||||
.collect(Collectors.toList()); // sorted by currency name
|
||||
}
|
||||
|
||||
public static List<TradeCurrency> getAllFiatCurrencies() {
|
||||
|
@ -105,11 +105,11 @@ public class CurrencyUtil {
|
|||
public static List<TradeCurrency> getAllSortedFiatCurrencies() {
|
||||
return getAllSortedTraditionalCurrencies().stream()
|
||||
.filter(currency -> CurrencyUtil.isFiatCurrency(currency.getCode()))
|
||||
.collect(Collectors.toList()); // sorted by currency name
|
||||
.collect(Collectors.toList()); // sorted by currency name
|
||||
}
|
||||
|
||||
public static Collection<TraditionalCurrency> getAllSortedTraditionalCurrencies() {
|
||||
return traditionalCurrencyMapSupplier.get().values(); // sorted by currency name
|
||||
return traditionalCurrencyMapSupplier.get().values(); // sorted by currency name
|
||||
}
|
||||
|
||||
public static List<TradeCurrency> getAllTraditionalCurrencies() {
|
||||
|
|
|
@ -65,6 +65,7 @@ public class CurrencyList {
|
|||
|
||||
private List<CurrencyListItem> getPartitionedSortedItems(List<TradeCurrency> currencies) {
|
||||
Map<TradeCurrency, Integer> tradesPerCurrency = countTrades(currencies);
|
||||
List<CurrencyListItem> fiatCurrencies = new ArrayList<>();
|
||||
List<CurrencyListItem> traditionalCurrencies = new ArrayList<>();
|
||||
List<CurrencyListItem> cryptoCurrencies = new ArrayList<>();
|
||||
|
||||
|
@ -73,7 +74,9 @@ public class CurrencyList {
|
|||
Integer count = entry.getValue();
|
||||
CurrencyListItem item = new CurrencyListItem(currency, count);
|
||||
|
||||
if (predicates.isTraditionalCurrency(currency)) {
|
||||
if (predicates.isFiatCurrency(currency)) {
|
||||
fiatCurrencies.add(item);
|
||||
} else if (predicates.isTraditionalCurrency(currency)) {
|
||||
traditionalCurrencies.add(item);
|
||||
}
|
||||
|
||||
|
@ -83,10 +86,12 @@ public class CurrencyList {
|
|||
}
|
||||
|
||||
Comparator<CurrencyListItem> comparator = getComparator();
|
||||
fiatCurrencies.sort(comparator);
|
||||
traditionalCurrencies.sort(comparator);
|
||||
cryptoCurrencies.sort(comparator);
|
||||
|
||||
List<CurrencyListItem> result = new ArrayList<>();
|
||||
result.addAll(fiatCurrencies);
|
||||
result.addAll(traditionalCurrencies);
|
||||
result.addAll(cryptoCurrencies);
|
||||
|
||||
|
|
|
@ -25,6 +25,10 @@ class CurrencyPredicates {
|
|||
return CurrencyUtil.isCryptoCurrency(currency.getCode());
|
||||
}
|
||||
|
||||
boolean isFiatCurrency(TradeCurrency currency) {
|
||||
return CurrencyUtil.isFiatCurrency(currency.getCode());
|
||||
}
|
||||
|
||||
boolean isTraditionalCurrency(TradeCurrency currency) {
|
||||
return CurrencyUtil.isTraditionalCurrency(currency.getCode());
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue