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();
}
});
}
Aggregations