/** * Cancels all requests in this queue for which the given filter applies. * * <p>取消当前请求集合中所有符合条件的请求。 filter 参数表示可以按照自定义的过滤器过滤需要取消的请求。 * * @param filter The filtering function to use */ public void cancelAll(RequestFilter filter) { synchronized (mCurrentRequests) { for (Request<?> request : mCurrentRequests) { if (filter.apply(request)) { request.cancel(); } } } }
@Override public synchronized boolean cancel(boolean mayInterruptIfRunning) { if (mRequest == null) { return false; } if (!isDone()) { mRequest.cancel(); return true; } else { return false; } }