Skip to content
This repository has been archived by the owner on Mar 16, 2021. It is now read-only.

Commit

Permalink
Merge pull request #64 from StefMa/feature/use_addall_instead_of_fori
Browse files Browse the repository at this point in the history
Use addAll instead of our own fori
  • Loading branch information
StefMa committed Jan 24, 2017
2 parents 2d94cc6 + 3b22b53 commit 53579df
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 36 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

/**
Expand All @@ -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);
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

/**
Expand All @@ -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);
}

}

0 comments on commit 53579df

Please sign in to comment.