@Test public void onCreate() { purchaseManager.initialize(application); verifyInAppBillingServiceConnected(); verify(purchaseWallet).getActiveLocalInAppPurchases(); }
@SuppressLint("CheckResult") @SuppressWarnings("ResultOfMethodCallIgnored") public void initialize(@NonNull Application application) { Logger.debug(PurchaseManager.this, "Initializing the purchase manager"); application.registerActivityLifecycleCallbacks(new PurchaseManagerActivityLifecycleCallbacks(this)); Observable.fromCallable(purchaseWallet::getActiveLocalInAppPurchases) .subscribeOn(subscribeOnScheduler) .subscribe(); getAllOwnedPurchases() .subscribeOn(subscribeOnScheduler) .subscribe(managedProducts -> Logger.debug(PurchaseManager.this, "Successfully initialized all user owned purchases {}.", managedProducts), throwable -> Logger.error(PurchaseManager.this, "Failed to initialize all user owned purchases.", throwable)); remoteSubscriptionManager.getNewRemoteSubscriptions() .subscribe(newInAppSubscriptions -> { for (RemoteSubscription newRemoteSubscription : newInAppSubscriptions) { for (final PurchaseEventsListener listener : listeners) { listener.onPurchaseSuccess(newRemoteSubscription.getInAppPurchase(), PurchaseSource.Remote); } } }, throwable -> Logger.error(this, "Failed to fetch our remote subscriptions")); }
PurchaseManager { @SuppressLint("CheckResult") @SuppressWarnings("ResultOfMethodCallIgnored") public void initialize(@NonNull Application application) { Logger.debug(PurchaseManager.this, "Initializing the purchase manager"); application.registerActivityLifecycleCallbacks(new PurchaseManagerActivityLifecycleCallbacks(this)); Observable.fromCallable(purchaseWallet::getActiveLocalInAppPurchases) .subscribeOn(subscribeOnScheduler) .subscribe(); getAllOwnedPurchases() .subscribeOn(subscribeOnScheduler) .subscribe(managedProducts -> Logger.debug(PurchaseManager.this, "Successfully initialized all user owned purchases {}.", managedProducts), throwable -> Logger.error(PurchaseManager.this, "Failed to initialize all user owned purchases.", throwable)); remoteSubscriptionManager.getNewRemoteSubscriptions() .subscribe(newInAppSubscriptions -> { for (RemoteSubscription newRemoteSubscription : newInAppSubscriptions) { for (final PurchaseEventsListener listener : listeners) { listener.onPurchaseSuccess(newRemoteSubscription.getInAppPurchase(), PurchaseSource.Remote); } } }, throwable -> Logger.error(this, "Failed to fetch our remote subscriptions")); } }
PurchaseManager { @SuppressLint("CheckResult") @SuppressWarnings("ResultOfMethodCallIgnored") public void initialize(@NonNull Application application) { Logger.debug(PurchaseManager.this, "Initializing the purchase manager"); application.registerActivityLifecycleCallbacks(new PurchaseManagerActivityLifecycleCallbacks(this)); Observable.fromCallable(purchaseWallet::getActiveLocalInAppPurchases) .subscribeOn(subscribeOnScheduler) .subscribe(); getAllOwnedPurchases() .subscribeOn(subscribeOnScheduler) .subscribe(managedProducts -> Logger.debug(PurchaseManager.this, "Successfully initialized all user owned purchases {}.", managedProducts), throwable -> Logger.error(PurchaseManager.this, "Failed to initialize all user owned purchases.", throwable)); remoteSubscriptionManager.getNewRemoteSubscriptions() .subscribe(newInAppSubscriptions -> { for (RemoteSubscription newRemoteSubscription : newInAppSubscriptions) { for (final PurchaseEventsListener listener : listeners) { listener.onPurchaseSuccess(newRemoteSubscription.getInAppPurchase(), PurchaseSource.Remote); } } }, throwable -> Logger.error(this, "Failed to fetch our remote subscriptions")); } @Inject  PurchaseManager(@NonNull Context context,
                           @NonNull RemoteSubscriptionManager remoteSubscriptionManager,
                           @NonNull PurchaseWallet purchaseWallet,
                           @NonNull Analytics analytics); @VisibleForTesting  PurchaseManager(@NonNull Context context,
                    @NonNull RemoteSubscriptionManager remoteSubscriptionManager,
                    @NonNull PurchaseWallet purchaseWallet,
                    @NonNull Analytics analytics,
                    @NonNull Scheduler subscribeOnScheduler,
                    @NonNull Scheduler observeOnScheduler); }
PurchaseManager { @SuppressLint("CheckResult") @SuppressWarnings("ResultOfMethodCallIgnored") public void initialize(@NonNull Application application) { Logger.debug(PurchaseManager.this, "Initializing the purchase manager"); application.registerActivityLifecycleCallbacks(new PurchaseManagerActivityLifecycleCallbacks(this)); Observable.fromCallable(purchaseWallet::getActiveLocalInAppPurchases) .subscribeOn(subscribeOnScheduler) .subscribe(); getAllOwnedPurchases() .subscribeOn(subscribeOnScheduler) .subscribe(managedProducts -> Logger.debug(PurchaseManager.this, "Successfully initialized all user owned purchases {}.", managedProducts), throwable -> Logger.error(PurchaseManager.this, "Failed to initialize all user owned purchases.", throwable)); remoteSubscriptionManager.getNewRemoteSubscriptions() .subscribe(newInAppSubscriptions -> { for (RemoteSubscription newRemoteSubscription : newInAppSubscriptions) { for (final PurchaseEventsListener listener : listeners) { listener.onPurchaseSuccess(newRemoteSubscription.getInAppPurchase(), PurchaseSource.Remote); } } }, throwable -> Logger.error(this, "Failed to fetch our remote subscriptions")); } @Inject  PurchaseManager(@NonNull Context context,
                           @NonNull RemoteSubscriptionManager remoteSubscriptionManager,
                           @NonNull PurchaseWallet purchaseWallet,
                           @NonNull Analytics analytics); @VisibleForTesting  PurchaseManager(@NonNull Context context,
                    @NonNull RemoteSubscriptionManager remoteSubscriptionManager,
                    @NonNull PurchaseWallet purchaseWallet,
                    @NonNull Analytics analytics,
                    @NonNull Scheduler subscribeOnScheduler,
                    @NonNull Scheduler observeOnScheduler); void addEventListener(@NonNull PurchaseEventsListener listener); void removeEventListener(@NonNull PurchaseEventsListener listener); @SuppressLint("CheckResult") @SuppressWarnings("ResultOfMethodCallIgnored") void initialize(@NonNull Application application); void onActivityResumed(@NonNull Activity activity); void onActivityPaused(); void initiatePurchase(@NonNull final InAppPurchase inAppPurchase, @NonNull final PurchaseSource purchaseSource); @VisibleForTesting void sendMockPurchaseRequest(@NonNull InAppPurchase inAppPurchase); boolean onActivityResult(int requestCode, int resultCode, @Nullable Intent data); @NonNull Observable<Set<ManagedProduct>> getAllOwnedPurchases(); @NonNull Observable<Set<AvailablePurchase>> getAllAvailablePurchases(); @NonNull Observable<Set<InAppPurchase>> getAllAvailablePurchaseSkus(); @NonNull Completable consumePurchase(@NonNull final ConsumablePurchase consumablePurchase); }
PurchaseManager { @SuppressLint("CheckResult") @SuppressWarnings("ResultOfMethodCallIgnored") public void initialize(@NonNull Application application) { Logger.debug(PurchaseManager.this, "Initializing the purchase manager"); application.registerActivityLifecycleCallbacks(new PurchaseManagerActivityLifecycleCallbacks(this)); Observable.fromCallable(purchaseWallet::getActiveLocalInAppPurchases) .subscribeOn(subscribeOnScheduler) .subscribe(); getAllOwnedPurchases() .subscribeOn(subscribeOnScheduler) .subscribe(managedProducts -> Logger.debug(PurchaseManager.this, "Successfully initialized all user owned purchases {}.", managedProducts), throwable -> Logger.error(PurchaseManager.this, "Failed to initialize all user owned purchases.", throwable)); remoteSubscriptionManager.getNewRemoteSubscriptions() .subscribe(newInAppSubscriptions -> { for (RemoteSubscription newRemoteSubscription : newInAppSubscriptions) { for (final PurchaseEventsListener listener : listeners) { listener.onPurchaseSuccess(newRemoteSubscription.getInAppPurchase(), PurchaseSource.Remote); } } }, throwable -> Logger.error(this, "Failed to fetch our remote subscriptions")); } @Inject  PurchaseManager(@NonNull Context context,
                           @NonNull RemoteSubscriptionManager remoteSubscriptionManager,
                           @NonNull PurchaseWallet purchaseWallet,
                           @NonNull Analytics analytics); @VisibleForTesting  PurchaseManager(@NonNull Context context,
                    @NonNull RemoteSubscriptionManager remoteSubscriptionManager,
                    @NonNull PurchaseWallet purchaseWallet,
                    @NonNull Analytics analytics,
                    @NonNull Scheduler subscribeOnScheduler,
                    @NonNull Scheduler observeOnScheduler); void addEventListener(@NonNull PurchaseEventsListener listener); void removeEventListener(@NonNull PurchaseEventsListener listener); @SuppressLint("CheckResult") @SuppressWarnings("ResultOfMethodCallIgnored") void initialize(@NonNull Application application); void onActivityResumed(@NonNull Activity activity); void onActivityPaused(); void initiatePurchase(@NonNull final InAppPurchase inAppPurchase, @NonNull final PurchaseSource purchaseSource); @VisibleForTesting void sendMockPurchaseRequest(@NonNull InAppPurchase inAppPurchase); boolean onActivityResult(int requestCode, int resultCode, @Nullable Intent data); @NonNull Observable<Set<ManagedProduct>> getAllOwnedPurchases(); @NonNull Observable<Set<AvailablePurchase>> getAllAvailablePurchases(); @NonNull Observable<Set<InAppPurchase>> getAllAvailablePurchaseSkus(); @NonNull Completable consumePurchase(@NonNull final ConsumablePurchase consumablePurchase); static final int REQUEST_CODE; }