private void setInstalledAndNotifyObserver() { if (!installationComplete) { installationComplete = true; observer.handleInstall(); } }
@Override public void run() { try { if (autofetchInformation) { loadSkusAndFillPurchaseInformation(); } } catch (Exception e) { // TODO: this situation not yet unit-tested. Log.e(LOG_TAG, "Failed to load skus in onServiceConnected()", e); } observer.handleInstall(); } });
private void notifyObserverWhenInstalled() { if (installed()) observer.handleInstall(); }
@Test public void shouldInstallWhenConnectAndGetSkuDetailsSucceeds() throws Exception { bindFetchNewConnectionAndInstallPurchaseSystem(); assertRunAsyncCalledAndReset(); verify(purchaseObserver).handleInstall(); assertTrue(purchaseManager.installed()); }
@Test public void shouldInstallEvenIfPreloadInformationFails() throws Exception { connectToBillingService(); verifyBillingGetSkuDetailsCalled(); assertRunAsyncCalledAndReset(); verify(purchaseObserver).handleInstall(); assertTrue(purchaseManager.installed()); }
observer.handleInstall();
@Override public void didReceiveResponse (SKProductsRequest request, SKProductsResponse response) { // Received the registered products from AppStore. products = response.getProducts(); log(LOGTYPELOG, "Products successfully received!"); final SKPaymentQueue defaultQueue = SKPaymentQueue.getDefaultQueue(); // Create and register our apple transaction observer. appleObserver = new AppleTransactionObserver(); defaultQueue.addTransactionObserver(appleObserver); defaultQueue.addStrongRef(appleObserver); log(LOGTYPELOG, "Purchase observer successfully installed!"); // notify of success... observer.handleInstall(); // complete unfinished transactions final NSArray<SKPaymentTransaction> transactions = defaultQueue.getTransactions(); log(LOGTYPELOG, "There are " + transactions.size() + " unfinished transactions. Try to finish..."); appleObserver.updatedTransactions(defaultQueue, transactions); }