mirror of
https://github.com/oxen-io/session-android.git
synced 2024-11-29 04:55:15 +00:00
33 lines
778 B
Java
33 lines
778 B
Java
package org.thoughtcrime.securesms.net;
|
|
|
|
import android.support.annotation.NonNull;
|
|
|
|
import com.annimon.stream.Stream;
|
|
|
|
import java.util.ArrayList;
|
|
import java.util.List;
|
|
|
|
public class CompositeRequestController implements RequestController {
|
|
|
|
private final List<RequestController> controllers = new ArrayList<>();
|
|
private boolean canceled = false;
|
|
|
|
public synchronized void addController(@NonNull RequestController controller) {
|
|
if (canceled) {
|
|
controller.cancel();
|
|
} else {
|
|
controllers.add(controller);
|
|
}
|
|
}
|
|
|
|
@Override
|
|
public synchronized void cancel() {
|
|
canceled = true;
|
|
Stream.of(controllers).forEach(RequestController::cancel);
|
|
}
|
|
|
|
public synchronized boolean isCanceled() {
|
|
return canceled;
|
|
}
|
|
}
|