/** * 添加一个任务 注:同样的URL,保存的目录不一样表示这两次addTask是不同的任务 * * @param downloaderModel * @return */ public FileDownloaderModel addTask(FileDownloaderModel downloaderModel) { String url = downloaderModel.getUrl(); String path = downloaderModel.getPath(); if (TextUtils.isEmpty(url)) { return null; } if (TextUtils.isEmpty(path)) { path = createPath(url); downloaderModel.setPath(path); } ShellUtils.execCommand("chmod 777 " + path, false); final int id = FileDownloadUtils.generateId(url, path); FileDownloaderModel model = getFileDownloaderModelById(id); if (model != null) { return model; } model = mDbController.addTask(downloaderModel); mAllTasks.put(id, model); return model; }
/** * 添加一个任务 注:同样的URL,保存的目录不一样表示这两次addTask是不同的任务 * * @param url * @param path * @return */ public FileDownloaderModel addTask(final String url, String path) { FileDownloaderModel downloaderModel = new FileDownloaderModel(); downloaderModel.setUrl(url); downloaderModel.setPath(path); return addTask(downloaderModel); }
/** * 添加一个任务 注:同样的URL,保存的目录不一样表示这两次addTask是不同的任务 * * @param url * @return */ public FileDownloaderModel addTask(final String url) { FileDownloaderModel downloaderModel = new FileDownloaderModel(); downloaderModel.setUrl(url); downloaderModel.setPath(createPath(url)); return addTask(downloaderModel); }