/** * release resources */ public static void release() { if (FileDownloadManager.getFileDownloadConfiguration() != null && isInit()) { getFileDownloadManager().release(); } }
/** * pause a download * * @param url file url */ public static void pause(String url) { getFileDownloadManager().pause(url); }
/** * move a download file * * @param url file url * @param newDirPath new dir path * @param onMoveDownloadFileListener OnMoveDownloadFileListener impl */ public static void move(String url, String newDirPath, OnMoveDownloadFileListener onMoveDownloadFileListener) { getFileDownloadManager().move(url, newDirPath, onMoveDownloadFileListener); }
/** * get AppContext */ private Context getAppContext() { Context appContext = null; if (FileDownloader.isInit()) { FileDownloadConfiguration configuration = FileDownloader.getFileDownloadConfiguration(); appContext = configuration != null ? configuration.getContext() : null; } return appContext; }
/** * init with a Configuration * * @param configuration Configuration */ public static void init(FileDownloadConfiguration configuration) { if (configuration == null) { return; } Context context = configuration.getContext(); FileDownloadManager.getInstance(context).init(configuration); }
/** * get download save dir * * @return download save dir */ public static String getDownloadDir() { return getFileDownloadManager().getDownloadDir(); }
/** * register an OnFileDownloadStatusListener * * @param onFileDownloadStatusListener OnFileDownloadStatusListener impl, or use {@link * OnRetryableFileDownloadStatusListener}, which can retry download when * download failed once when use {@link FileDownloadConfiguration * .Builder#configRetryDownloadTimes(int)} to config the retry times */ public static void registerDownloadStatusListener(OnFileDownloadStatusListener onFileDownloadStatusListener) { getFileDownloadManager().registerDownloadStatusListener(onFileDownloadStatusListener); }
/** * pause all downloads */ public static void pauseAll() { getFileDownloadManager().pauseAll(); }
/** * delete a download file * * @param url file url * @param deleteDownloadedFileInPath whether delete file in path * @param onDeleteDownloadFileListener OnDeleteDownloadFileListener impl */ public static void delete(String url, boolean deleteDownloadedFileInPath, OnDeleteDownloadFileListener onDeleteDownloadFileListener) { getFileDownloadManager().delete(url, deleteDownloadedFileInPath, onDeleteDownloadFileListener); }
/** * get download file save dir * * @return download file save dir */ public String getDownloadDir() { checkInit(); return mConfiguration.getFileDownloadDir(); }
/** * get DownloadFile by file url * * @param url file url * @return DownloadFile */ public static DownloadFileInfo getDownloadFile(String url) { return getFileDownloadManager().getDownloadFile(url); }
/** * get DownloadFile by save file path * * @param savePath save file path * @return DownloadFile */ public static DownloadFileInfo getDownloadFileBySavePath(String savePath) { return getFileDownloadManager().getDownloadFileBySavePath(savePath); }
/** * get all DownloadFiles * * @return all DownloadFiles */ public static List<DownloadFileInfo> getDownloadFiles() { return getFileDownloadManager().getDownloadFiles(); }
/** * detect a big url file, which means can detect the url file bigger than 2G * * @param url file url * @param onDetectBigUrlFileListener OnDetectBigUrlFileListener impl * @since 0.3.0 */ public static void detect(String url, OnDetectBigUrlFileListener onDetectBigUrlFileListener) { getFileDownloadManager().detect(url, onDetectBigUrlFileListener); }
/** * register a DownloadFileChangeListener with Configuration * * @param onDownloadFileChangeListener OnDownloadFileChangeListener impl * @param downloadFileChangeConfiguration Configuration for the OnDownloadFileChangeListener impl * @since 0.3.0 */ public static void registerDownloadFileChangeListener(OnDownloadFileChangeListener onDownloadFileChangeListener, DownloadFileChangeConfiguration downloadFileChangeConfiguration) { getFileDownloadManager().registerDownloadFileChangeListener(onDownloadFileChangeListener, downloadFileChangeConfiguration); }
/** * get DownloadFile by temp file path * * @param tempPath temp file path * @return DownloadFile */ public static DownloadFileInfo getDownloadFileByTempPath(String tempPath) { return getFileDownloadManager().getDownloadFileByTempPath(tempPath); }
/** * unregister an OnFileDownloadStatusListener * * @param onFileDownloadStatusListener registered OnFileDownloadStatusListener or * OnRetryableFileDownloadStatusListener impl */ public static void unregisterDownloadStatusListener(OnFileDownloadStatusListener onFileDownloadStatusListener) { getFileDownloadManager().unregisterDownloadStatusListener(onFileDownloadStatusListener); }
/** * unregister an OnDownloadFileChangeListener * * @param onDownloadFileChangeListener registered OnDownloadFileChangeListener impl */ public static void unregisterDownloadFileChangeListener(OnDownloadFileChangeListener onDownloadFileChangeListener) { getFileDownloadManager().unregisterDownloadFileChangeListener(onDownloadFileChangeListener); }
/** * pause multi downloads * * @param urls file urls */ public static void pause(List<String> urls) { getFileDownloadManager().pause(urls); }
/** * move multi download files * * @param urls file urls * @param newDirPath new dir path * @param onMoveDownloadFilesListener OnMoveDownloadFilesListener impl * @return a control for the operation */ public static Control move(List<String> urls, String newDirPath, OnMoveDownloadFilesListener onMoveDownloadFilesListener) { return getFileDownloadManager().move(urls, newDirPath, onMoveDownloadFilesListener); }