void onSelectTrade(PendingTradesListItem item) {
    // clean up previous selectedItem
    selectedItem = item;

    if (item == null) {
      trade = null;
      tradeProperty.set(null);
    } else {
      trade = item.getTrade();
      tradeProperty.set(trade);

      isOfferer = tradeManager.isMyOffer(trade.getOffer());

      if (trade.getDepositTx() != null) txId.set(trade.getDepositTx().getHashAsString());
    }
  }
 private void doWithdrawRequest(String toAddress, KeyParameter aesKey) {
   if (toAddress != null && toAddress.length() > 0) {
     tradeManager.onWithdrawRequest(
         toAddress,
         aesKey,
         trade,
         () ->
             UserThread.execute(
                 () ->
                     navigation.navigateTo(
                         MainView.class, PortfolioView.class, ClosedTradesView.class)),
         (errorMessage, throwable) -> {
           log.error(errorMessage);
           new Popup().error("An error occurred:\n" + throwable.getMessage()).show();
         });
   }
 }
  private void onListChanged() {
    Log.traceCall();
    list.clear();
    list.addAll(
        tradeManager
            .getTrades()
            .stream()
            .map(PendingTradesListItem::new)
            .collect(Collectors.toList()));

    // we sort by date, earliest first
    list.sort((o1, o2) -> o2.getTrade().getDate().compareTo(o1.getTrade().getDate()));

    // TODO improve selectedItem handling
    // selectedItem does not get set to null if we dont have the view visible
    // So if the item gets removed form the list, and a new item is added we need to check if the
    // old
    // selectedItem is in the new list, if not we know it is an invalid one
    if (list.size() == 1) onSelectTrade(list.get(0));
    else if (list.size() > 1 && (selectedItem == null || !list.contains(selectedItem)))
      onSelectTrade(list.get(0));
    else if (list.size() == 0) onSelectTrade(null);
  }
 public Offer.Direction getDirection(Offer offer) {
   // gets called earlier than onSelectTrade event handler
   isOfferer = tradeManager.isMyOffer(offer);
   return isOfferer ? offer.getDirection() : offer.getMirroredDirection();
 }
 @Override
 protected void deactivate() {
   tradeManager.getTrades().removeListener(tradesListChangeListener);
 }
 @Override
 protected void activate() {
   tradeManager.getTrades().addListener(tradesListChangeListener);
   onListChanged();
 }