Rename getClosedTradables and getFailedTrades to getObservableList

This commit is contained in:
chimp1984 2020-10-01 22:24:46 -05:00
parent c789650d0b
commit 32238f2050
No known key found for this signature in database
GPG Key ID: 9801B4EC591F90E3
10 changed files with 19 additions and 19 deletions

View File

@ -87,12 +87,12 @@ public class ClosedTradableManager implements PersistedDataHost {
return offer.isMyOffer(keyRing);
}
public ObservableList<Tradable> getClosedTradables() {
public ObservableList<Tradable> getObservableList() {
return closedTradables.getObservableList();
}
public List<Trade> getClosedTrades() {
return ImmutableList.copyOf(getClosedTradables().stream()
return ImmutableList.copyOf(getObservableList().stream()
.filter(e -> e instanceof Trade)
.map(e -> (Trade) e)
.collect(Collectors.toList()));

View File

@ -101,7 +101,7 @@ public class FailedTradesManager implements PersistedDataHost {
return offer.isMyOffer(keyRing);
}
public ObservableList<Trade> getFailedTrades() {
public ObservableList<Trade> getObservableList() {
return failedTrades.getObservableList();
}

View File

@ -374,8 +374,8 @@ public class XmrTxProofService implements AssetTxProofService {
// We need to prevent that a user tries to scam by reusing a txKey and txHash of a previous XMR trade with
// the same user (same address) and same amount. We check only for the txKey as a same txHash but different
// txKey is not possible to get a valid result at proof.
Stream<Trade> failedAndOpenTrades = Stream.concat(activeTrades.stream(), failedTradesManager.getFailedTrades().stream());
Stream<Trade> closedTrades = closedTradableManager.getClosedTradables().stream()
Stream<Trade> failedAndOpenTrades = Stream.concat(activeTrades.stream(), failedTradesManager.getObservableList().stream());
Stream<Trade> closedTrades = closedTradableManager.getObservableList().stream()
.filter(tradable -> tradable instanceof Trade)
.map(tradable -> (Trade) tradable);
Stream<Trade> allTrades = Stream.concat(failedAndOpenTrades, closedTrades);

View File

@ -52,8 +52,8 @@ public class TradableRepository {
return ImmutableSet.<Tradable>builder()
.addAll(openOfferManager.getObservableList())
.addAll(tradeManager.getObservableList())
.addAll(closedTradableManager.getClosedTradables())
.addAll(failedTradesManager.getFailedTrades())
.addAll(closedTradableManager.getObservableList())
.addAll(failedTradesManager.getObservableList())
.build();
}
}

View File

@ -613,7 +613,7 @@ class OfferBookViewModel extends ActivatableViewModel {
}
int getNumTrades(Offer offer) {
return closedTradableManager.getClosedTradables().stream()
return closedTradableManager.getObservableList().stream()
.filter(e -> {
final NodeAddress tradingPeerNodeAddress = e instanceof Trade ? ((Trade) e).getTradingPeerNodeAddress() : null;
return tradingPeerNodeAddress != null &&

View File

@ -127,11 +127,11 @@ public class PortfolioView extends ActivatableView<TabPane, Void> {
@Override
protected void activate() {
failedTradesManager.getFailedTrades().addListener((ListChangeListener<Trade>) c -> {
if (failedTradesManager.getFailedTrades().size() > 0 && root.getTabs().size() == 3)
failedTradesManager.getObservableList().addListener((ListChangeListener<Trade>) c -> {
if (failedTradesManager.getObservableList().size() > 0 && root.getTabs().size() == 3)
root.getTabs().add(failedTradesTab);
});
if (failedTradesManager.getFailedTrades().size() > 0 && root.getTabs().size() == 3)
if (failedTradesManager.getObservableList().size() > 0 && root.getTabs().size() == 3)
root.getTabs().add(failedTradesTab);
root.getSelectionModel().selectedItemProperty().addListener(tabChangeListener);

View File

@ -48,12 +48,12 @@ class ClosedTradesDataModel extends ActivatableDataModel {
@Override
protected void activate() {
applyList();
closedTradableManager.getClosedTradables().addListener(tradesListChangeListener);
closedTradableManager.getObservableList().addListener(tradesListChangeListener);
}
@Override
protected void deactivate() {
closedTradableManager.getClosedTradables().removeListener(tradesListChangeListener);
closedTradableManager.getObservableList().removeListener(tradesListChangeListener);
}
public ObservableList<ClosedTradableListItem> getList() {
@ -67,7 +67,7 @@ class ClosedTradesDataModel extends ActivatableDataModel {
private void applyList() {
list.clear();
list.addAll(closedTradableManager.getClosedTradables().stream().map(ClosedTradableListItem::new).collect(Collectors.toList()));
list.addAll(closedTradableManager.getObservableList().stream().map(ClosedTradableListItem::new).collect(Collectors.toList()));
// we sort by date, earliest first
list.sort((o1, o2) -> o2.getTradable().getDate().compareTo(o1.getTradable().getDate()));

View File

@ -184,7 +184,7 @@ class ClosedTradesViewModel extends ActivatableWithDataModel<ClosedTradesDataMod
int getNumPastTrades(Tradable tradable) {
//noinspection ConstantConditions
return dataModel.closedTradableManager.getClosedTradables().stream()
return dataModel.closedTradableManager.getObservableList().stream()
.filter(e -> e instanceof Trade &&
tradable instanceof Trade &&
((Trade) e).getTradingPeerNodeAddress() != null &&

View File

@ -52,12 +52,12 @@ class FailedTradesDataModel extends ActivatableDataModel {
@Override
protected void activate() {
applyList();
failedTradesManager.getFailedTrades().addListener(tradesListChangeListener);
failedTradesManager.getObservableList().addListener(tradesListChangeListener);
}
@Override
protected void deactivate() {
failedTradesManager.getFailedTrades().removeListener(tradesListChangeListener);
failedTradesManager.getObservableList().removeListener(tradesListChangeListener);
}
public ObservableList<FailedTradesListItem> getList() {
@ -71,7 +71,7 @@ class FailedTradesDataModel extends ActivatableDataModel {
private void applyList() {
list.clear();
list.addAll(failedTradesManager.getFailedTrades().stream().map(FailedTradesListItem::new).collect(Collectors.toList()));
list.addAll(failedTradesManager.getObservableList().stream().map(FailedTradesListItem::new).collect(Collectors.toList()));
// we sort by date, earliest first
list.sort((o1, o2) -> o2.getTrade().getDate().compareTo(o1.getTrade().getDate()));

View File

@ -348,7 +348,7 @@ public class PendingTradesViewModel extends ActivatableWithDataModel<PendingTrad
}
public int getNumPastTrades(Trade trade) {
return closedTradableManager.getClosedTradables().stream()
return closedTradableManager.getObservableList().stream()
.filter(e -> {
if (e instanceof Trade) {
Trade t = (Trade) e;