mirror of
https://github.com/boldsuck/haveno.git
synced 2024-12-23 04:29:22 +00:00
init offer address entry off user thread to prevent blocking
This commit is contained in:
parent
e956114239
commit
49ee3b19b1
2 changed files with 12 additions and 12 deletions
|
@ -95,7 +95,6 @@ public abstract class MutableOfferDataModel extends OfferDataModel {
|
||||||
private final CoinFormatter btcFormatter;
|
private final CoinFormatter btcFormatter;
|
||||||
private final Navigation navigation;
|
private final Navigation navigation;
|
||||||
private final String offerId;
|
private final String offerId;
|
||||||
private final XmrBalanceListener xmrBalanceListener;
|
|
||||||
private final SetChangeListener<PaymentAccount> paymentAccountsChangeListener;
|
private final SetChangeListener<PaymentAccount> paymentAccountsChangeListener;
|
||||||
|
|
||||||
protected OfferDirection direction;
|
protected OfferDirection direction;
|
||||||
|
@ -128,6 +127,7 @@ public abstract class MutableOfferDataModel extends OfferDataModel {
|
||||||
protected long triggerPrice;
|
protected long triggerPrice;
|
||||||
@Getter
|
@Getter
|
||||||
protected boolean reserveExactAmount;
|
protected boolean reserveExactAmount;
|
||||||
|
private XmrBalanceListener xmrBalanceListener;
|
||||||
|
|
||||||
|
|
||||||
///////////////////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
@ -163,20 +163,12 @@ public abstract class MutableOfferDataModel extends OfferDataModel {
|
||||||
|
|
||||||
offerId = OfferUtil.getRandomOfferId();
|
offerId = OfferUtil.getRandomOfferId();
|
||||||
shortOfferId = Utilities.getShortId(offerId);
|
shortOfferId = Utilities.getShortId(offerId);
|
||||||
addressEntry = xmrWalletService.getOrCreateAddressEntry(offerId, XmrAddressEntry.Context.OFFER_FUNDING);
|
|
||||||
|
|
||||||
reserveExactAmount = preferences.getSplitOfferOutput();
|
reserveExactAmount = preferences.getSplitOfferOutput();
|
||||||
|
|
||||||
useMarketBasedPrice.set(preferences.isUsePercentageBasedPrice());
|
useMarketBasedPrice.set(preferences.isUsePercentageBasedPrice());
|
||||||
buyerSecurityDepositPct.set(Restrictions.getMinBuyerSecurityDepositAsPercent());
|
buyerSecurityDepositPct.set(Restrictions.getMinBuyerSecurityDepositAsPercent());
|
||||||
|
|
||||||
xmrBalanceListener = new XmrBalanceListener(getAddressEntry().getSubaddressIndex()) {
|
|
||||||
@Override
|
|
||||||
public void onBalanceChanged(BigInteger balance) {
|
|
||||||
updateBalance();
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
paymentAccountsChangeListener = change -> fillPaymentAccounts();
|
paymentAccountsChangeListener = change -> fillPaymentAccounts();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -212,6 +204,14 @@ public abstract class MutableOfferDataModel extends OfferDataModel {
|
||||||
|
|
||||||
// called before activate()
|
// called before activate()
|
||||||
public boolean initWithData(OfferDirection direction, TradeCurrency tradeCurrency) {
|
public boolean initWithData(OfferDirection direction, TradeCurrency tradeCurrency) {
|
||||||
|
addressEntry = xmrWalletService.getOrCreateAddressEntry(offerId, XmrAddressEntry.Context.OFFER_FUNDING);
|
||||||
|
xmrBalanceListener = new XmrBalanceListener(getAddressEntry().getSubaddressIndex()) {
|
||||||
|
@Override
|
||||||
|
public void onBalanceChanged(BigInteger balance) {
|
||||||
|
updateBalance();
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
this.direction = direction;
|
this.direction = direction;
|
||||||
this.tradeCurrency = tradeCurrency;
|
this.tradeCurrency = tradeCurrency;
|
||||||
|
|
||||||
|
|
|
@ -210,9 +210,6 @@ public abstract class MutableOfferViewModel<M extends MutableOfferDataModel> ext
|
||||||
|
|
||||||
paymentLabel = Res.get("createOffer.fundsBox.paymentLabel", dataModel.shortOfferId);
|
paymentLabel = Res.get("createOffer.fundsBox.paymentLabel", dataModel.shortOfferId);
|
||||||
|
|
||||||
if (dataModel.getAddressEntry() != null) {
|
|
||||||
addressAsString = dataModel.getAddressEntry().getAddressString();
|
|
||||||
}
|
|
||||||
createListeners();
|
createListeners();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -568,6 +565,9 @@ public abstract class MutableOfferViewModel<M extends MutableOfferDataModel> ext
|
||||||
|
|
||||||
boolean initWithData(OfferDirection direction, TradeCurrency tradeCurrency) {
|
boolean initWithData(OfferDirection direction, TradeCurrency tradeCurrency) {
|
||||||
boolean result = dataModel.initWithData(direction, tradeCurrency);
|
boolean result = dataModel.initWithData(direction, tradeCurrency);
|
||||||
|
if (dataModel.getAddressEntry() != null) {
|
||||||
|
addressAsString = dataModel.getAddressEntry().getAddressString();
|
||||||
|
}
|
||||||
if (dataModel.paymentAccount != null)
|
if (dataModel.paymentAccount != null)
|
||||||
xmrValidator.setMaxValue(dataModel.paymentAccount.getPaymentMethod().getMaxTradeLimit(dataModel.getTradeCurrencyCode().get()));
|
xmrValidator.setMaxValue(dataModel.paymentAccount.getPaymentMethod().getMaxTradeLimit(dataModel.getTradeCurrencyCode().get()));
|
||||||
xmrValidator.setMaxTradeLimit(BigInteger.valueOf(dataModel.getMaxTradeLimit()));
|
xmrValidator.setMaxTradeLimit(BigInteger.valueOf(dataModel.getMaxTradeLimit()));
|
||||||
|
|
Loading…
Reference in a new issue