An open API service indexing awesome lists of open source software.

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!

Awesome Lists containing this project

README

          

# OkhttpDownloader
a multi-thread downloader for okhttp!

# Dependencies

[![](https://jitpack.io/v/li-xiaojun/OkhttpDownloader.svg)](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

![1](/screenshot/1.gif)

![2](/screenshot/2.gif)

# 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);
```