mirror of
https://github.com/haveno-dex/haveno.git
synced 2025-07-27 08:55:22 -04:00
refactor buy/sell tab functionality #1351
This commit is contained in:
parent
f470112cae
commit
0c76c48c65
24 changed files with 363 additions and 351 deletions
|
@ -73,14 +73,6 @@ public class CurrencyUtil {
|
|||
|
||||
private static String baseCurrencyCode = "XMR";
|
||||
|
||||
private static List<TraditionalCurrency> getTraditionalNonFiatCurrencies() {
|
||||
return Arrays.asList(
|
||||
new TraditionalCurrency("XAG", "Silver"),
|
||||
new TraditionalCurrency("XAU", "Gold"),
|
||||
new TraditionalCurrency("XGB", "Goldback")
|
||||
);
|
||||
}
|
||||
|
||||
// Calls to isTraditionalCurrency and isCryptoCurrency are very frequent so we use a cache of the results.
|
||||
// The main improvement was already achieved with using memoize for the source maps, but
|
||||
// the caching still reduces performance costs by about 20% for isCryptoCurrency (1752 ms vs 2121 ms) and about 50%
|
||||
|
@ -124,6 +116,14 @@ public class CurrencyUtil {
|
|||
return new ArrayList<>(traditionalCurrencyMapSupplier.get().values());
|
||||
}
|
||||
|
||||
public static List<TraditionalCurrency> getTraditionalNonFiatCurrencies() {
|
||||
return Arrays.asList(
|
||||
new TraditionalCurrency("XAG", "Silver"),
|
||||
new TraditionalCurrency("XAU", "Gold"),
|
||||
new TraditionalCurrency("XGB", "Goldback")
|
||||
);
|
||||
}
|
||||
|
||||
public static Collection<TraditionalCurrency> getAllSortedTraditionalCurrencies(Comparator comparator) {
|
||||
return (List<TraditionalCurrency>) getAllSortedTraditionalCurrencies().stream()
|
||||
.sorted(comparator)
|
||||
|
|
|
@ -139,6 +139,10 @@ public abstract class PaymentAccount implements PersistablePayload {
|
|||
return getSingleTradeCurrency() == null || CurrencyUtil.isFiatCurrency(getSingleTradeCurrency().getCode()); // TODO: check if trade currencies contain fiat
|
||||
}
|
||||
|
||||
public boolean isCryptoCurrency() {
|
||||
return getSingleTradeCurrency() != null && CurrencyUtil.isCryptoCurrency(getSingleTradeCurrency().getCode());
|
||||
}
|
||||
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////////////
|
||||
// PROTO BUFFER
|
||||
|
|
|
@ -566,6 +566,16 @@ public final class Preferences implements PersistedDataHost, BridgeAddressProvid
|
|||
requestPersistence();
|
||||
}
|
||||
|
||||
public void setBuyScreenOtherCurrencyCode(String buyScreenCurrencyCode) {
|
||||
prefPayload.setBuyScreenOtherCurrencyCode(buyScreenCurrencyCode);
|
||||
requestPersistence();
|
||||
}
|
||||
|
||||
public void setSellScreenOtherCurrencyCode(String sellScreenCurrencyCode) {
|
||||
prefPayload.setSellScreenOtherCurrencyCode(sellScreenCurrencyCode);
|
||||
requestPersistence();
|
||||
}
|
||||
|
||||
public void setIgnoreTradersList(List<String> ignoreTradersList) {
|
||||
prefPayload.setIgnoreTradersList(ignoreTradersList);
|
||||
requestPersistence();
|
||||
|
|
|
@ -77,6 +77,10 @@ public final class PreferencesPayload implements PersistableEnvelope {
|
|||
private String buyScreenCryptoCurrencyCode;
|
||||
@Nullable
|
||||
private String sellScreenCryptoCurrencyCode;
|
||||
@Nullable
|
||||
private String buyScreenOtherCurrencyCode;
|
||||
@Nullable
|
||||
private String sellScreenOtherCurrencyCode;
|
||||
private int tradeStatisticsTickUnitIndex = 3;
|
||||
private boolean resyncSpvRequested;
|
||||
private boolean sortMarketCurrenciesNumerically = true;
|
||||
|
@ -212,6 +216,8 @@ public final class PreferencesPayload implements PersistableEnvelope {
|
|||
Optional.ofNullable(sellScreenCurrencyCode).ifPresent(builder::setSellScreenCurrencyCode);
|
||||
Optional.ofNullable(buyScreenCryptoCurrencyCode).ifPresent(builder::setBuyScreenCryptoCurrencyCode);
|
||||
Optional.ofNullable(sellScreenCryptoCurrencyCode).ifPresent(builder::setSellScreenCryptoCurrencyCode);
|
||||
Optional.ofNullable(buyScreenOtherCurrencyCode).ifPresent(builder::setBuyScreenOtherCurrencyCode);
|
||||
Optional.ofNullable(sellScreenOtherCurrencyCode).ifPresent(builder::setSellScreenOtherCurrencyCode);
|
||||
Optional.ofNullable(selectedPaymentAccountForCreateOffer).ifPresent(
|
||||
account -> builder.setSelectedPaymentAccountForCreateOffer(selectedPaymentAccountForCreateOffer.toProtoMessage()));
|
||||
Optional.ofNullable(bridgeAddresses).ifPresent(builder::addAllBridgeAddresses);
|
||||
|
@ -260,6 +266,8 @@ public final class PreferencesPayload implements PersistableEnvelope {
|
|||
ProtoUtil.stringOrNullFromProto(proto.getSellScreenCurrencyCode()),
|
||||
ProtoUtil.stringOrNullFromProto(proto.getBuyScreenCryptoCurrencyCode()),
|
||||
ProtoUtil.stringOrNullFromProto(proto.getSellScreenCryptoCurrencyCode()),
|
||||
ProtoUtil.stringOrNullFromProto(proto.getBuyScreenOtherCurrencyCode()),
|
||||
ProtoUtil.stringOrNullFromProto(proto.getSellScreenOtherCurrencyCode()),
|
||||
proto.getTradeStatisticsTickUnitIndex(),
|
||||
proto.getResyncSpvRequested(),
|
||||
proto.getSortMarketCurrenciesNumerically(),
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue