/** * 将一个等待中的任务从下等待队列中移除 * * @param downloadId */ protected synchronized void removeWaitQueueTask(int downloadId) { Iterator<FileDownloaderModel> iterator = mWaitQueue.iterator(); while (iterator.hasNext()) { FileDownloaderModel model = iterator.next(); if (model != null && model.getId() == downloadId) { try { iterator.remove(); } catch (Exception e) { ILogger.e(e); } return; } } }
/** * 添加任务并启动 * * @param downloaderModel * @return */ public FileDownloaderModel addTaskAndStart(FileDownloaderModel downloaderModel) { FileDownloaderModel model = addTask(downloaderModel); startTask(model.getId()); return model; }
/** * 添加任务并启动 * * @param url * @param path * @return */ public FileDownloaderModel addTaskAndStart(final String url, String path) { FileDownloaderModel model = addTask(url, path); startTask(model.getId()); return model; }
/** * 添加任务并启动 * * @param url * @return */ public FileDownloaderModel addTaskAndStart(String url) { FileDownloaderModel model = addTask(url); startTask(model.getId()); return model; }