https://github.com/junixapp/okhttpdownloader
a multi-thread downloader for okhttp!
https://github.com/junixapp/okhttpdownloader
multi-thread multi-thread-download okhttp
Last synced: 10 months ago
JSON representation
a multi-thread downloader for okhttp!
- Host: GitHub
- URL: https://github.com/junixapp/okhttpdownloader
- Owner: junixapp
- License: apache-2.0
- Created: 2017-03-27T02:12:03.000Z (almost 9 years ago)
- Default Branch: master
- Last Pushed: 2020-12-25T01:43:59.000Z (about 5 years ago)
- Last Synced: 2025-04-16T08:39:12.852Z (11 months ago)
- Topics: multi-thread, multi-thread-download, okhttp
- Language: Java
- Size: 1 MB
- Stars: 86
- Watchers: 5
- Forks: 16
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# OkhttpDownloader
a multi-thread downloader for okhttp!
# Dependencies
[](https://jitpack.io/#li-xiaojun/OkhttpDownloader)
**Step 1.** Add the JitPack repository to your build file
```groovy
allprojects {
repositories {
...
maven { url 'https://jitpack.io' }
}
}
```
**Step 2.** Add the dependency
```groovy
dependencies {
compile 'com.github.li-xiaojun:OkhttpDownloader:latest release'
}
```
# Screenshot


# Feature
- multi-thread download
- support break-download
- db save downloadInfo
# How To Use
- 下载方法:
```java
//需要自己维护任务id
DownloadEngine.create(this).download(taskId, url, path);
```
- 暂停方法:
```java
DownloadEngine.create(this).pause(taskId);
```
- 设置最大同时运行的任务数量:
```java
DownloadEngine.create(this).setMaxTaskCount(5);
```
- 添加和移除下载监听器:
```java
//添加
DownloadEngine.create(this).addDownloadObserver(new DownloadEngine.DownloadObserver() {
@Override
public void onDownloadUpdate(DownloadInfo downloadInfo) {
}
},taskId...);
//移除
DownloadEngine.create(this).removeDownloadObserver(this);
```
- 获取下载详细数据:
```java
DownloadEngine.create(this).getDownloadInfo(taskId);
```
- 删除下载数据,同时删除数据库记录和本地文件:
```java
DownloadEngine.create(this).deleteDownloadInfo(downloadInfo);
```