All Projects → xwdz → QuietDownload

xwdz / QuietDownload

Licence: other
🔥下载可以很简单。单任务下载、多任务下载、暂停全部任务、自动恢复下载、断点续传、任何一个界面监听进度等

Programming Languages

java
68154 projects - #9 most used programming language

Projects that are alternatives of or similar to QuietDownload

Pyload
The free and open-source Download Manager written in pure Python
Stars: ✭ 2,393 (+5597.62%)
Mutual labels:  download, downloadmanager
Docker Jdownloader
JDownloader 2 Docker Image (Multiarch) - Passed 40M Downloads
Stars: ✭ 85 (+102.38%)
Mutual labels:  download, downloadmanager
Fast Android Networking
🚀 A Complete Fast Android Networking Library that also supports HTTP/2 🚀
Stars: ✭ 5,346 (+12628.57%)
Mutual labels:  download, downloadmanager
DownloadManagerPlus
Using faster and easier than Android Download Manager
Stars: ✭ 80 (+90.48%)
Mutual labels:  download, downloadmanager
download water data
Downloader for the Global Surface Water Data of the Copernicus Programme
Stars: ✭ 25 (-40.48%)
Mutual labels:  download
Spotifarr
Spotifarr
Stars: ✭ 35 (-16.67%)
Mutual labels:  download
Floatplane-Downloader
Project for automatically organizing and downloading Floatplane videos for plex.
Stars: ✭ 94 (+123.81%)
Mutual labels:  download
bandcamp-dl
A browser automation script to batch download your private bandcamp collection.
Stars: ✭ 30 (-28.57%)
Mutual labels:  download
Waifu2x-Image-Saver
A Firefox extension to download any image and process them with Waifu2x with one click.
Stars: ✭ 13 (-69.05%)
Mutual labels:  download
OneDriveShareLinkPushAria2
Extract download URLs from OneDrive or SharePoint share links and push them to aria2, even on systems without a GUI.
Stars: ✭ 256 (+509.52%)
Mutual labels:  download
fastdownload
Easily download, verify, and extract archives
Stars: ✭ 35 (-16.67%)
Mutual labels:  download
crunchyroll-dl
A fast, modern, and beautiful Crunchyroll downloader.
Stars: ✭ 111 (+164.29%)
Mutual labels:  download
dslrbrowser-ios
DSLR Browser iOS app to discover and connect to your Wi-Fi and DLNA enabled (Canon) camera
Stars: ✭ 17 (-59.52%)
Mutual labels:  download
download
Dateidownloads von Files aus dem Medienpool über PHP oder X-SendFile
Stars: ✭ 30 (-28.57%)
Mutual labels:  download
qobuz-dl
A complete Lossless and Hi-Res music downloader for Qobuz
Stars: ✭ 531 (+1164.29%)
Mutual labels:  download
Google-Images-Search
[PYTHON] Search for image using Google Custom Search API and resize & crop afterwards
Stars: ✭ 121 (+188.1%)
Mutual labels:  download
nrk api
API to interact with NRK, also includes a cli.
Stars: ✭ 22 (-47.62%)
Mutual labels:  download
vsco-scraper
Easily allows for scraping a VSCO
Stars: ✭ 106 (+152.38%)
Mutual labels:  download
gamesearch
A Simple Search Engine to help you find FREE Download Links to your Favourite Games
Stars: ✭ 30 (-28.57%)
Mutual labels:  download
NovelScraper
Download manager & library for translated light novels.
Stars: ✭ 70 (+66.67%)
Mutual labels:  download

QuiteDownload

如果你觉得这个lib对你有用,随手给个Star,让我知道它是对你有帮助的,我会继续更新和维护它。

image

功能

  • 任何一个界面检测进度
  • 单个任务下载
  • 多个任务下载
  • 取消单个任务
  • 取消全部任务
  • 暂停所有任务
  • 支持队列
  • 队列最大同时下载任务数,超过则进入等待队列
  • 自动恢复上一次下载任务

使用方法

downloader 权限相关

    <uses-permission android:name="android.permission.INTERNET"/>

添加依赖

根项目的build.gradle:

allprojects {
    repositories {
        jcenter()
        maven { url "https://jitpack.io" }
    }
}

$lastVersion =

implementation 'com.j256.ormlite:ormlite-android:4.48'
implementation 'com.xwdz:QuietDownloader:$lastVersion'

配置

1. 在您的Application处调用初始化代码:

    DownloadConfig downloadConfig = new DownloadConfig(this);
    
    // 自定义配置 均有默认值
    
    // downloadConfig.setMaxDownloadTasks(); 队列最大同时下载任务数,超过则进入等待队列 默认:3
    // downloadConfig.setMaxDownloadThreads() 最大线程下载数   默认:3
    // downloadConfig.setDownloadDir() 下载文件路径
        ...省略若干
    
   QuietDownloader.initializeDownloader(downloadConfig);

DownloadEntry.Status的几种状态

状态 说明
IDLE 空闲
WAITING 等待
CONNECTING 连接
CONNECT_SUCCESSFUL 连接成功
DOWNLOADING 开始下载
PAUSED 暂停
CANCELLED 取消
COMPLETED 完成
ERROR 发生错误

使用方法


private final DownloadEntry downloadEntry = new DownloadEntry("url","name");

QuietDownloader.download(downloadEntry)
  ... 省略代码
  
常用静态方法 参数 说明
download downloadEntry 下载一个任务
pause downloadEntry 在听一个任务
cancel downloadEntry 取消一个任务
resume downloadEntry 恢复一个下载任务
recoverAll 恢复所有下载任务
pauseAll 暂停所有任务
queryAll 查询所有下载任务返回一个list
queryById id 查询一个downloadEntry从数据库中
deleteById id 从数据库中删除一个downloadEntry
getDBDao 返回Dao<DownloadEntry, String>自定义进行数据查询

......

监听

QuietDownloader 并没有采用传统listener方式,而是使用了观察者模式,如需要在某个界面监听下载进度

    private final DataUpdatedWatcher mDataUpdateReceiver = new DataUpdatedWatcher() {
        @Override
        public void notifyUpdate(DownloadEntry entry) {
            // calback mainUIThread 
            // do something
            // 可根据 entry status来判断一些列状态
            if(entry.status == DownloadEntry.pause || DownloadEntry.downloading ...)
        }
    };
    
    // 省略若干代码
    
    //监听下载状态
    @Override
    protected void onResume() {
        super.onResume();
        QuietDownloader.addObserver(mDataUpdateReceiver);
    }
    
    @Override
    protected void onPause() {
        super.onPause();
        QuietDownloader.removeObserver(mDataUpdateReceiver);
    }
    

关于DownloadEntry

public class DownloadEntry implements Serializable {

    public String id;
    public String name;
    public String url;
    public int currentLength;
    public int totalLength;
        // ... 省略代码

    /**
     * @param url  下载地址
     * @param name 文件名称(带后缀)
     */
    public DownloadEntry(String url, String name) {
        this.url = url;
        this.id = url;
        this.name = name;
        this.filePath = QuietDownloader.getImpl().getConfigs().getDownloadFile(name).getAbsolutePath();
    }
       
    // ... 省略代码
    
    @Override
        public boolean equals(Object o) {
            return o.hashCode() == this.hashCode();
        }
    
        @Override
        public int hashCode() {
            final int PRIME = 31;
            int result = 1;
            result = PRIME * result + id.hashCode();
            return result;
    }
}

注意

  • DownloadEntry 实体类重写其 equals 以及 hashCode 方法,使用其 id hashCode 来作为其标准
  • QuietDownloader 内部使用DownloadEntry实体类进行关联
  • QuietDownEntryname属性最终作为下载文件名称
  • 如果自定义了downloadConfig.setDownloadDir()下载位置注意申请读写权限

TODO

  • 重试机制
  • 拦截器实现

Stargazers


版本历史

v1.0.8-beta

v1.0.61-beta

  • 不再需要声明组件Service
  • 初始化直接可使用静态方法`QuietDownloader.initializeDownloader(downloadConfig);
  • 增加自动重试机制

v1.0.6-beta

  • 内部增加检查当前DownloadEntry.status机制,如果正在下载则忽略事件
  • HTTP增加Connect Header

v1.0.3

  • 新增配置QuietDownloader.setReadTimeoutMillis(),QuietDownloader.setConnTimeMillis

v1.0.2

v1.0.1

  • DownloadConfig提供自定义下载目录
  • Fix Issues3

v0.0.6

  • QuietDownloader 可通过getDBDao()拿到Dao<DownloadEntry, String>对象操作数据库
  • QuietDownloader 提供查询所有方法数据库DownloadEntry queryAll()

v0.0.5

  • 修复默认使用url作为文件名称url长度过长问题

v0.0.4

  • 新增DownloadStatus连接成功CONNECT_SUCCESSFUL枚举
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].