From 8917df94ee3b3bbfba72531865d60822c5fbde9a Mon Sep 17 00:00:00 2001 From: lukasz Date: Thu, 21 Nov 2019 15:16:38 +0100 Subject: [PATCH] Refactor OfferView constructor --- .../main/java/bisq/desktop/main/offer/BuyOfferView.java | 5 +++-- .../src/main/java/bisq/desktop/main/offer/OfferView.java | 7 ++++--- .../main/java/bisq/desktop/main/offer/SellOfferView.java | 5 +++-- 3 files changed, 10 insertions(+), 7 deletions(-) diff --git a/desktop/src/main/java/bisq/desktop/main/offer/BuyOfferView.java b/desktop/src/main/java/bisq/desktop/main/offer/BuyOfferView.java index 9da1283a115..47675d68223 100644 --- a/desktop/src/main/java/bisq/desktop/main/offer/BuyOfferView.java +++ b/desktop/src/main/java/bisq/desktop/main/offer/BuyOfferView.java @@ -21,6 +21,7 @@ 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 BuyOfferView(ViewLoader viewLoader, preferences, arbitratorManager, user, - p2PService); + p2PService, + OfferPayload.Direction.BUY); } } - diff --git a/desktop/src/main/java/bisq/desktop/main/offer/OfferView.java b/desktop/src/main/java/bisq/desktop/main/offer/OfferView.java index 66d86c2882e..1004a9389b3 100644 --- a/desktop/src/main/java/bisq/desktop/main/offer/OfferView.java +++ b/desktop/src/main/java/bisq/desktop/main/offer/OfferView.java @@ -83,13 +83,14 @@ protected OfferView(ViewLoader viewLoader, 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 @@ else if (removedTabs.get(0).getContent().equals(takeOfferPane)) @Override protected void activate() { - Optional tradeCurrencyOptional = (this instanceof SellOfferView) ? + Optional tradeCurrencyOptional = (this.direction == OfferPayload.Direction.SELL) ? CurrencyUtil.getTradeCurrency(preferences.getSellScreenCurrencyCode()) : CurrencyUtil.getTradeCurrency(preferences.getBuyScreenCurrencyCode()); tradeCurrency = tradeCurrencyOptional.orElseGet(GlobalSettings::getDefaultTradeCurrency); diff --git a/desktop/src/main/java/bisq/desktop/main/offer/SellOfferView.java b/desktop/src/main/java/bisq/desktop/main/offer/SellOfferView.java index 7c8e57f78b6..d88fb8c9dd9 100644 --- a/desktop/src/main/java/bisq/desktop/main/offer/SellOfferView.java +++ b/desktop/src/main/java/bisq/desktop/main/offer/SellOfferView.java @@ -21,6 +21,7 @@ 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 SellOfferView(ViewLoader viewLoader, preferences, arbitratorManager, user, - p2PService); + p2PService, + OfferPayload.Direction.SELL); } } -