private int cancelAllRequests(@NotNull List<Request> list) { int count = 0; for (Request request : list) { count++; request.cancel(); } list.clear(); return count; }
private void cancelRequest(@NotNull Runnable request, @NotNull List<Request> list) { for (int i = list.size() - 1; i >= 0; i--) { Request r = list.get(i); if (r.getTask() == request) { r.cancel(); list.remove(i); } } }