diff --git a/rx/src/main/java/net/grandcentrix/thirtyinch/rx/RxTiPresenterSubscriptionHandler.java b/rx/src/main/java/net/grandcentrix/thirtyinch/rx/RxTiPresenterSubscriptionHandler.java index 30d4efc7..eee6bd7b 100644 --- a/rx/src/main/java/net/grandcentrix/thirtyinch/rx/RxTiPresenterSubscriptionHandler.java +++ b/rx/src/main/java/net/grandcentrix/thirtyinch/rx/RxTiPresenterSubscriptionHandler.java @@ -68,7 +68,7 @@ public void manageSubscription(@NonNull final Subscription... subscriptions) { + " when the presenter has reached the DESTROYED state"); } - addSubscriptions(mPresenterSubscriptions, subscriptions); + mPresenterSubscriptions.addAll(subscriptions); } /** @@ -84,23 +84,7 @@ public void manageViewSubscription(@NonNull final Subscription... subscriptions) + " when there is no view"); } - addSubscriptions(mUiSubscriptions, subscriptions); - } - - /** - * Adds all subscriptions to the given compositeSubscription if not already unsubscribed - */ - private static void addSubscriptions(final CompositeSubscription compositeSubscription, - final Subscription... subscriptions) { - //noinspection ForLoopReplaceableByForEach - for (int i = 0; i < subscriptions.length; i++) { - final Subscription subscription = subscriptions[i]; - if (subscription.isUnsubscribed()) { - continue; - } - - compositeSubscription.add(subscriptions[i]); - } + mUiSubscriptions.addAll(subscriptions); } } diff --git a/rx2/src/main/java/net/grandcentrix/thirtyinch/rx2/RxTiPresenterDisposableHandler.java b/rx2/src/main/java/net/grandcentrix/thirtyinch/rx2/RxTiPresenterDisposableHandler.java index ec08524b..8becd414 100644 --- a/rx2/src/main/java/net/grandcentrix/thirtyinch/rx2/RxTiPresenterDisposableHandler.java +++ b/rx2/src/main/java/net/grandcentrix/thirtyinch/rx2/RxTiPresenterDisposableHandler.java @@ -69,7 +69,7 @@ public void manageDisposable(@NonNull final Disposable... disposables) { + " when the presenter has reached the DESTROYED state"); } - addDisposables(mPresenterDisposables, disposables); + mPresenterDisposables.addAll(disposables); } /** @@ -85,23 +85,7 @@ public void manageViewDisposable(@NonNull final Disposable... disposables) { + " when there is no view"); } - addDisposables(mUiDisposables, disposables); - } - - /** - * Adds all disposables to the given compositeDisposable if not already disposed - */ - private static void addDisposables(final CompositeDisposable compositeDisposable, - final Disposable... disposables) { - //noinspection ForLoopReplaceableByForEach - for (int i = 0; i < disposables.length; i++) { - final Disposable disposable = disposables[i]; - if (disposable.isDisposed()) { - continue; - } - - compositeDisposable.add(disposable); - } + mUiDisposables.addAll(disposables); } }