Merge pull request #3655 from lusarz/refactor-offer-view

Refactor OfferView constructor
This commit is contained in:
Christoph Atteneder 2019-11-22 14:11:49 +01:00 committed by GitHub
commit c0108b83af
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 10 additions and 7 deletions

View File

@ -21,6 +21,7 @@ import bisq.desktop.Navigation;
import bisq.desktop.common.view.FxmlView;
import bisq.desktop.common.view.ViewLoader;
import bisq.core.offer.OfferPayload;
import bisq.core.support.dispute.arbitration.arbitrator.ArbitratorManager;
import bisq.core.user.Preferences;
import bisq.core.user.User;
@ -44,7 +45,7 @@ public class BuyOfferView extends OfferView {
preferences,
arbitratorManager,
user,
p2PService);
p2PService,
OfferPayload.Direction.BUY);
}
}

View File

@ -83,13 +83,14 @@ public abstract class OfferView extends ActivatableView<TabPane, Void> {
Preferences preferences,
ArbitratorManager arbitratorManager,
User user,
P2PService p2PService) {
P2PService p2PService,
OfferPayload.Direction direction) {
this.viewLoader = viewLoader;
this.navigation = navigation;
this.preferences = preferences;
this.user = user;
this.p2PService = p2PService;
this.direction = (this instanceof BuyOfferView) ? OfferPayload.Direction.BUY : OfferPayload.Direction.SELL;
this.direction = direction;
this.arbitratorManager = arbitratorManager;
}
@ -133,7 +134,7 @@ public abstract class OfferView extends ActivatableView<TabPane, Void> {
@Override
protected void activate() {
Optional<TradeCurrency> tradeCurrencyOptional = (this instanceof SellOfferView) ?
Optional<TradeCurrency> tradeCurrencyOptional = (this.direction == OfferPayload.Direction.SELL) ?
CurrencyUtil.getTradeCurrency(preferences.getSellScreenCurrencyCode()) :
CurrencyUtil.getTradeCurrency(preferences.getBuyScreenCurrencyCode());
tradeCurrency = tradeCurrencyOptional.orElseGet(GlobalSettings::getDefaultTradeCurrency);

View File

@ -21,6 +21,7 @@ import bisq.desktop.Navigation;
import bisq.desktop.common.view.FxmlView;
import bisq.desktop.common.view.ViewLoader;
import bisq.core.offer.OfferPayload;
import bisq.core.support.dispute.arbitration.arbitrator.ArbitratorManager;
import bisq.core.user.Preferences;
import bisq.core.user.User;
@ -44,7 +45,7 @@ public class SellOfferView extends OfferView {
preferences,
arbitratorManager,
user,
p2PService);
p2PService,
OfferPayload.Direction.SELL);
}
}