@Test public void addPaymentListener_StopListener_NoEvents() throws Exception { enqueueTransactionsResponses(); final CountDownLatch latch = new CountDownLatch(1); final int[] eventsCount = {0}; ListenerRegistration listenerRegistration = blockchainEvents .addPaymentListener(new EventListener<PaymentInfo>() { @Override public void onEvent(PaymentInfo data) { eventsCount[0]++; if (eventsCount[0] == 2) { latch.countDown(); } } }); assertTrue(latch.await(1, TimeUnit.SECONDS)); listenerRegistration.remove(); enqueueTransactionsResponses(); enqueueTransactionsResponses(); Thread.sleep(500); assertThat(eventsCount[0], equalTo(2)); }
ListenerRegistration addPaymentListener(@NonNull final EventListener<PaymentInfo> listener) { checkNotNull(listener, "listener"); final kin.base.requests.EventListener<TransactionResponse> responseListener = new kin.base.requests.EventListener<TransactionResponse>() { @Override public void onEvent(TransactionResponse transactionResponse) { extractPaymentsFromTransaction(transactionResponse, listener); } }; transactionsStream.addListener(responseListener); return new ListenerRegistration(new Runnable() { @Override public void run() { transactionsStream.removeListener(responseListener); } }); }
BlockchainEvents { ListenerRegistration addPaymentListener(@NonNull final EventListener<PaymentInfo> listener) { checkNotNull(listener, "listener"); final kin.base.requests.EventListener<TransactionResponse> responseListener = new kin.base.requests.EventListener<TransactionResponse>() { @Override public void onEvent(TransactionResponse transactionResponse) { extractPaymentsFromTransaction(transactionResponse, listener); } }; transactionsStream.addListener(responseListener); return new ListenerRegistration(new Runnable() { @Override public void run() { transactionsStream.removeListener(responseListener); } }); } }
BlockchainEvents { ListenerRegistration addPaymentListener(@NonNull final EventListener<PaymentInfo> listener) { checkNotNull(listener, "listener"); final kin.base.requests.EventListener<TransactionResponse> responseListener = new kin.base.requests.EventListener<TransactionResponse>() { @Override public void onEvent(TransactionResponse transactionResponse) { extractPaymentsFromTransaction(transactionResponse, listener); } }; transactionsStream.addListener(responseListener); return new ListenerRegistration(new Runnable() { @Override public void run() { transactionsStream.removeListener(responseListener); } }); } BlockchainEvents(Server server, String accountId); }
BlockchainEvents { ListenerRegistration addPaymentListener(@NonNull final EventListener<PaymentInfo> listener) { checkNotNull(listener, "listener"); final kin.base.requests.EventListener<TransactionResponse> responseListener = new kin.base.requests.EventListener<TransactionResponse>() { @Override public void onEvent(TransactionResponse transactionResponse) { extractPaymentsFromTransaction(transactionResponse, listener); } }; transactionsStream.addListener(responseListener); return new ListenerRegistration(new Runnable() { @Override public void run() { transactionsStream.removeListener(responseListener); } }); } BlockchainEvents(Server server, String accountId);  }
BlockchainEvents { ListenerRegistration addPaymentListener(@NonNull final EventListener<PaymentInfo> listener) { checkNotNull(listener, "listener"); final kin.base.requests.EventListener<TransactionResponse> responseListener = new kin.base.requests.EventListener<TransactionResponse>() { @Override public void onEvent(TransactionResponse transactionResponse) { extractPaymentsFromTransaction(transactionResponse, listener); } }; transactionsStream.addListener(responseListener); return new ListenerRegistration(new Runnable() { @Override public void run() { transactionsStream.removeListener(responseListener); } }); } BlockchainEvents(Server server, String accountId);   }