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

Use addAll instead of our own fori #64

Merged
merged 1 commit into from
Jan 24, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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);
}

}