@Test public void addBalanceListener_StopListener_NoEvents() throws Exception { final int[] eventsCount = {0}; ListenerRegistration listenerRegistration = blockchainEvents .addBalanceListener(new EventListener<Balance>() { @Override public void onEvent(Balance data) { eventsCount[0]++; } }); listenerRegistration.remove(); enqueueCreateAccountResponses(); Thread.sleep(500); assertThat(eventsCount[0], equalTo(0)); }
ListenerRegistration addBalanceListener(@NonNull final EventListener<Balance> listener) { checkNotNull(listener, "listener"); final kin.base.requests.EventListener<TransactionResponse> responseListener = new kin.base.requests.EventListener<TransactionResponse>() { @Override public void onEvent(TransactionResponse transactionResponse) { extractBalanceChangeFromTransaction(transactionResponse, listener); } }; transactionsStream.addListener(responseListener); return new ListenerRegistration(new Runnable() { @Override public void run() { transactionsStream.removeListener(responseListener); } }); }
BlockchainEvents { ListenerRegistration addBalanceListener(@NonNull final EventListener<Balance> listener) { checkNotNull(listener, "listener"); final kin.base.requests.EventListener<TransactionResponse> responseListener = new kin.base.requests.EventListener<TransactionResponse>() { @Override public void onEvent(TransactionResponse transactionResponse) { extractBalanceChangeFromTransaction(transactionResponse, listener); } }; transactionsStream.addListener(responseListener); return new ListenerRegistration(new Runnable() { @Override public void run() { transactionsStream.removeListener(responseListener); } }); } }
BlockchainEvents { ListenerRegistration addBalanceListener(@NonNull final EventListener<Balance> listener) { checkNotNull(listener, "listener"); final kin.base.requests.EventListener<TransactionResponse> responseListener = new kin.base.requests.EventListener<TransactionResponse>() { @Override public void onEvent(TransactionResponse transactionResponse) { extractBalanceChangeFromTransaction(transactionResponse, listener); } }; transactionsStream.addListener(responseListener); return new ListenerRegistration(new Runnable() { @Override public void run() { transactionsStream.removeListener(responseListener); } }); } BlockchainEvents(Server server, String accountId); }
BlockchainEvents { ListenerRegistration addBalanceListener(@NonNull final EventListener<Balance> listener) { checkNotNull(listener, "listener"); final kin.base.requests.EventListener<TransactionResponse> responseListener = new kin.base.requests.EventListener<TransactionResponse>() { @Override public void onEvent(TransactionResponse transactionResponse) { extractBalanceChangeFromTransaction(transactionResponse, listener); } }; transactionsStream.addListener(responseListener); return new ListenerRegistration(new Runnable() { @Override public void run() { transactionsStream.removeListener(responseListener); } }); } BlockchainEvents(Server server, String accountId);  }
BlockchainEvents { ListenerRegistration addBalanceListener(@NonNull final EventListener<Balance> listener) { checkNotNull(listener, "listener"); final kin.base.requests.EventListener<TransactionResponse> responseListener = new kin.base.requests.EventListener<TransactionResponse>() { @Override public void onEvent(TransactionResponse transactionResponse) { extractBalanceChangeFromTransaction(transactionResponse, listener); } }; transactionsStream.addListener(responseListener); return new ListenerRegistration(new Runnable() { @Override public void run() { transactionsStream.removeListener(responseListener); } }); } BlockchainEvents(Server server, String accountId);   }