Search in sources :

Example 1 with TacWindow

use of io.bitsquare.gui.main.overlays.windows.TacWindow in project bitsquare by bitsquare.

the class MainViewModel method start.

///////////////////////////////////////////////////////////////////////////////////////////
// API
///////////////////////////////////////////////////////////////////////////////////////////
public void start() {
    // TODO need more though how to improve privacy without annoying first time users.
    /* String key = "showAddBitcoinNodesWindowKey";
        if (preferences.showAgain(key))
            addBitcoinNodesWindow.dontShowAgainId(key, preferences)
                    .onClose(() -> {
                        preferences.dontShowAgain(key, true);
                        initializeAllServices();
                    })
                    .onAction(() -> {
                        preferences.dontShowAgain(key, true);
                        initializeAllServices();
                    })
                    .show();
        else
            initializeAllServices();
    }

    private void initializeAllServices() {*/
    Log.traceCall();
    UserThread.runAfter(tacWindow::showIfNeeded, 2);
    ChangeListener<Boolean> walletInitializedListener = (observable, oldValue, newValue) -> {
        if (newValue && !p2pNetWorkReady.get())
            showStartupTimeoutPopup();
    };
    Timer startupTimeout = UserThread.runAfter(() -> {
        log.warn("startupTimeout called");
        Wallet wallet = walletService.getWallet();
        if (wallet != null && wallet.isEncrypted())
            walletInitialized.addListener(walletInitializedListener);
        else
            showStartupTimeoutPopup();
    }, 4, TimeUnit.MINUTES);
    p2pNetWorkReady = initP2PNetwork();
    initBitcoinWallet();
    // need to store it to not get garbage collected
    allServicesDone = EasyBind.combine(walletInitialized, p2pNetWorkReady, (a, b) -> a && b);
    allServicesDone.subscribe((observable, oldValue, newValue) -> {
        if (newValue) {
            startupTimeout.stop();
            walletInitialized.removeListener(walletInitializedListener);
            onAllServicesInitialized();
            if (startupTimeoutPopup != null)
                startupTimeoutPopup.hide();
        }
    });
}
Also used : Clock(io.bitsquare.common.Clock) OpenOffer(io.bitsquare.trade.offer.OpenOffer) PriceFeedService(io.bitsquare.btc.pricefeed.PriceFeedService) Popup(io.bitsquare.gui.main.overlays.popups.Popup) Transaction(org.bitcoinj.core.Transaction) MarketPrice(io.bitsquare.btc.pricefeed.MarketPrice) Coin(org.bitcoinj.core.Coin) Inject(com.google.inject.Inject) ViewModel(io.bitsquare.gui.common.model.ViewModel) LoggerFactory(org.slf4j.LoggerFactory) TradeCurrency(io.bitsquare.locale.TradeCurrency) Security(java.security.Security) TimeoutException(java.util.concurrent.TimeoutException) DisputeManager(io.bitsquare.arbitration.DisputeManager) BalanceWithConfirmationTextField(io.bitsquare.gui.components.BalanceWithConfirmationTextField) Trade(io.bitsquare.trade.Trade) GUIUtil(io.bitsquare.gui.util.GUIUtil) DevFlags(io.bitsquare.app.DevFlags) PaymentAccount(io.bitsquare.payment.PaymentAccount) NotificationCenter(io.bitsquare.gui.main.overlays.notifications.NotificationCenter) ListChangeListener(javafx.collections.ListChangeListener) Navigation(io.bitsquare.gui.Navigation) TradeWalletService(io.bitsquare.btc.TradeWalletService) BlockStoreException(org.bitcoinj.store.BlockStoreException) MonadicBinding(org.fxmisc.easybind.monadic.MonadicBinding) AddressEntry(io.bitsquare.btc.AddressEntry) WalletPasswordWindow(io.bitsquare.gui.main.overlays.windows.WalletPasswordWindow) FilterManager(io.bitsquare.filter.FilterManager) Subscription(org.fxmisc.easybind.Subscription) Collectors(java.util.stream.Collectors) PrivateNotificationManager(io.bitsquare.alert.PrivateNotificationManager) ConnectionListener(io.bitsquare.p2p.network.ConnectionListener) Preferences(io.bitsquare.user.Preferences) CryptoCurrencyAccount(io.bitsquare.payment.CryptoCurrencyAccount) Dispute(io.bitsquare.arbitration.Dispute) BalanceTextField(io.bitsquare.gui.components.BalanceTextField) Address(org.bitcoinj.core.Address) Ping(io.bitsquare.p2p.peers.keepalive.messages.Ping) ObservableList(javafx.collections.ObservableList) CurrencyUtil(io.bitsquare.locale.CurrencyUtil) io.bitsquare.common.crypto(io.bitsquare.common.crypto) PrivateNotification(io.bitsquare.alert.PrivateNotification) Version(io.bitsquare.app.Version) P2PServiceListener(io.bitsquare.p2p.P2PServiceListener) java.util(java.util) P2PService(io.bitsquare.p2p.P2PService) SetChangeListener(javafx.collections.SetChangeListener) FXCollections(javafx.collections.FXCollections) BitsquareApp(io.bitsquare.app.BitsquareApp) AddBitcoinNodesWindow(io.bitsquare.gui.main.overlays.windows.AddBitcoinNodesWindow) Connection(io.bitsquare.p2p.network.Connection) Timer(io.bitsquare.common.Timer) BalanceListener(io.bitsquare.btc.listeners.BalanceListener) OKPayAccount(io.bitsquare.payment.OKPayAccount) TradeManager(io.bitsquare.trade.TradeManager) User(io.bitsquare.user.User) WalletService(io.bitsquare.btc.WalletService) TacWindow(io.bitsquare.gui.main.overlays.windows.TacWindow) Alert(io.bitsquare.alert.Alert) DisplayAlertMessageWindow(io.bitsquare.gui.main.overlays.windows.DisplayAlertMessageWindow) Nullable(javax.annotation.Nullable) Log(io.bitsquare.app.Log) BSFormatter(io.bitsquare.gui.util.BSFormatter) javafx.beans.property(javafx.beans.property) Logger(org.slf4j.Logger) UserThread(io.bitsquare.common.UserThread) TxIdTextField(io.bitsquare.gui.components.TxIdTextField) Wallet(org.bitcoinj.core.Wallet) TimeUnit(java.util.concurrent.TimeUnit) EasyBind(org.fxmisc.easybind.EasyBind) OpenOfferManager(io.bitsquare.trade.offer.OpenOfferManager) ArbitratorManager(io.bitsquare.arbitration.ArbitratorManager) CloseConnectionReason(io.bitsquare.p2p.network.CloseConnectionReason) ChangeListener(javafx.beans.value.ChangeListener) AlertManager(io.bitsquare.alert.AlertManager) Timer(io.bitsquare.common.Timer) Wallet(org.bitcoinj.core.Wallet)

Aggregations

Inject (com.google.inject.Inject)1 Alert (io.bitsquare.alert.Alert)1 AlertManager (io.bitsquare.alert.AlertManager)1 PrivateNotification (io.bitsquare.alert.PrivateNotification)1 PrivateNotificationManager (io.bitsquare.alert.PrivateNotificationManager)1 BitsquareApp (io.bitsquare.app.BitsquareApp)1 DevFlags (io.bitsquare.app.DevFlags)1 Log (io.bitsquare.app.Log)1 Version (io.bitsquare.app.Version)1 ArbitratorManager (io.bitsquare.arbitration.ArbitratorManager)1 Dispute (io.bitsquare.arbitration.Dispute)1 DisputeManager (io.bitsquare.arbitration.DisputeManager)1 AddressEntry (io.bitsquare.btc.AddressEntry)1 TradeWalletService (io.bitsquare.btc.TradeWalletService)1 WalletService (io.bitsquare.btc.WalletService)1 BalanceListener (io.bitsquare.btc.listeners.BalanceListener)1 MarketPrice (io.bitsquare.btc.pricefeed.MarketPrice)1 PriceFeedService (io.bitsquare.btc.pricefeed.PriceFeedService)1 Clock (io.bitsquare.common.Clock)1 Timer (io.bitsquare.common.Timer)1